Title: | Calculates the Probability of Informed Trading (PIN) |
---|---|
Description: | Estimates the probability of informed trading (PIN) initially introduced by Easley et. al. (1996) <doi:10.1111/j.1540-6261.1996.tb04074.x> . Contribution of the package is that it uses likelihood factorizations of Easley et. al. (2010) <doi:10.1017/S0022109010000074> (EHO factorization) and Lin and Ke (2011) <doi:10.1016/j.finmar.2011.03.001> (LK factorization). Moreover, the package uses different estimation algorithms. Specifically, the grid-search algorithm proposed by Yan and Zhang (2012) <doi:10.1016/j.jbankfin.2011.08.003> , hierarchical agglomerative clustering approach proposed by Gan et. al. (2015) <doi:10.1080/14697688.2015.1023336> and later extended by Ersan and Alici (2016) <doi:10.1016/j.intfin.2016.04.001> . |
Authors: | Duygu Celik and Murat Tinic |
Maintainer: | Murat Tinic <[email protected]> |
License: | GPL-3 |
Version: | 1.2 |
Built: | 2025-02-15 05:24:52 UTC |
Source: | https://github.com/cran/InfoTrad |
Estimates the probability of informed trading (PIN) initially introduced by Easley et. al. (1996) <doi:10.1111/j.1540-6261.1996.tb04074.x> . Contribution of the package is that it uses likelihood factorizations of Easley et. al. (2010) <doi:10.1017/S0022109010000074> (EHO factorization) and Lin and Ke (2011) <doi:10.1016/j.finmar.2011.03.001> (LK factorization). Moreover, the package uses different estimation algorithms. Specifically, the grid-search algorithm proposed by Yan and Zhang (2012) <doi:10.1016/j.jbankfin.2011.08.003> , hierarchical agglomerative clustering approach proposed by Gan et. al. (2015) <doi:10.1080/14697688.2015.1023336> and later extended by Ersan and Alici (2016) <doi:10.1016/j.intfin.2016.04.001> .
Duygu Celik and Murat Tinic
Maintainer: Murat Tinic <[email protected]>
D. Easley, N. M. Kiefer, M. O'Hara, and J.B. Paperman. Liquidity, information, and infrequently traded stocks. The Journal of Finance, 51(4):1405-1436, 1996
D. Easley, S. Hvidkjaer, and M. O'Hara. Is information risk a determinant of asset returns? The Journal of Finance, 57(5): 2185-2221, 2002.
D. Easley, S. Hvidkjaer, and M. O'Hara. Factoring information into returns. Journal of Financial and Quantitative Analysis, 45(2): 293-309, 2010.
Ersan, O., and Alici, A. An unbiased computation methodology for estimating the probability of informed trading (PIN). Journal of International Financial Markets, Institutions and Money, 43(1):74-94, 2016.
Q. Gan, W.C. Wei, and D. Johnstone. A faster estimation method for the probability of informed trading using hierarhical agglomerative clustering. Quantitative Finance, 15(11):1805-1821, 2015
H.W. W. Lin and W. C. Ke. A computing bias in estimating the probability of informed trading. Journal of Financial Markets, 14(4):625-640, 2011.
D. Mullner. fastcluster: Fast hierarchical, agglomerative clustering routines for r and python. Journal of Statistical Software, 53(9):1-18, 2013.
Y. Yan and S. Zhang. An improved estimation method and empirical properties of the probability of informed trading. Journal of Banking & Finance, 36(2):454-467, 2012.
It estimates PIN using Ersan and Alici (2016) modified clustering algorithm.
EA(data, likelihood = c("LK", "EHO")) ## S3 method for class 'EA_class' print(obj)
EA(data, likelihood = c("LK", "EHO")) ## S3 method for class 'EA_class' print(obj)
data |
Data frame with 2 variables |
likelihood |
Character strings for likelihood algorithm. Default is "LK". |
obj |
object variable |
Argument for data must be a data frame with 2 columns that only contain numbers. Not any other type. You do not have to give names to the columns. We will assign first one as "Buy" and second as "Sell", therefore you should put order numbers with respect to this order.
Returns a list of parameter estimates (output)
alpha |
A Number |
delta |
A Number |
mu |
A Number |
eb |
A Number |
es |
A Number |
LikVal |
A Number |
PIN |
A Number |
This function does not handle NA values. Therefore the datasets should not contain any missing value. This function do not conduct the iterative estimation procedure proposed in the same paper.
Duygu Celik and Murat Tinic
Ersan, Oguz, and Asli Alici . "An unbiased computation methodology for estimating the probability of informed trading (PIN)." Journal of International Financial Markets, Institutions and Money 43 (2016): 74-94.
# Sample Data # Buy Sell #1 350 382 #2 250 500 #3 500 463 #4 552 550 #5 163 200 #6 345 323 #7 847 456 #8 923 342 #9 123 578 #10 349 455 Buy=c(350,250,500,552,163,345,847,923,123,349) Sell=c(382,500,463,550,200,323,456,342,578,455) data=cbind(Buy,Sell) # Parameter estimates using the LK factorization of Lin and Ke (2011) # with the modified clustering algorithm of Ersan and Alici (2016). # Default factorization is set to be "LK" result=EA(data) print(result) # Alpha: 0.9511418 # Delta: 0.2694005 # Mu: 76.7224 # Epsilon_b: 493.7045 # Epsilon_s: 377.4877 # Likelihood Value: 43973.71 # PIN: 0.07728924 # Parameter estimates using the EHO factorization of Easley et. al. (2010) # with the modified clustering algorithm of Ersan and Alici (2016). result=EA(data,likelihood="EHO") print(result) # Alpha: 0.9511418 # Delta: 0.2694005 # Mu: 76.7224 # Epsilon_b: 493.7045 # Epsilon_s: 377.4877 # Likelihood Value: 43973.71 # PIN: 0.07728924
# Sample Data # Buy Sell #1 350 382 #2 250 500 #3 500 463 #4 552 550 #5 163 200 #6 345 323 #7 847 456 #8 923 342 #9 123 578 #10 349 455 Buy=c(350,250,500,552,163,345,847,923,123,349) Sell=c(382,500,463,550,200,323,456,342,578,455) data=cbind(Buy,Sell) # Parameter estimates using the LK factorization of Lin and Ke (2011) # with the modified clustering algorithm of Ersan and Alici (2016). # Default factorization is set to be "LK" result=EA(data) print(result) # Alpha: 0.9511418 # Delta: 0.2694005 # Mu: 76.7224 # Epsilon_b: 493.7045 # Epsilon_s: 377.4877 # Likelihood Value: 43973.71 # PIN: 0.07728924 # Parameter estimates using the EHO factorization of Easley et. al. (2010) # with the modified clustering algorithm of Ersan and Alici (2016). result=EA(data,likelihood="EHO") print(result) # Alpha: 0.9511418 # Delta: 0.2694005 # Mu: 76.7224 # Epsilon_b: 493.7045 # Epsilon_s: 377.4877 # Likelihood Value: 43973.71 # PIN: 0.07728924
The function calculates the likelihood factorization of Easley et. al. (2010) and computes paramaters for estimation of PIN value.
EHO(data, fixed = c(FALSE, FALSE, FALSE, FALSE, FALSE))
EHO(data, fixed = c(FALSE, FALSE, FALSE, FALSE, FALSE))
data |
Data frame with 2 variables |
fixed |
Initial values for parameters in the following order: alpha, delta, mu, epsilon_b, epsilon_s |
In order to use EHO's return in optimization functions, please omit second argument. With this way, EHO will return a function instead of a value. Moreover, argument for data must be a data frame with 2 columns that contain numbers. Not any other type.
LK_out |
Returns an optim() object including parameter estimates for the likelihood factorization of Easley et. al. (2010) |
This function does not handle NA values. Therefore the datasets should not contain any missing values.
Duygu Celik and Murat Tinic
Easley, D., Hvidkjaer, S., & O'Hara, M. Factoring information into returns. Journal of Financial and Quantitative Analysis, 45(2):293-309,2010.
# Sample Data # Buy Sell #1 350 382 #2 250 500 #3 500 463 #4 552 550 #5 163 200 #6 345 323 #7 847 456 #8 923 342 #9 123 578 #10 349 455 Buy<-c(350,250,500,552,163,345,847,923,123,349) Sell<-c(382,500,463,550,200,323,456,342,578,455) data=cbind(Buy,Sell) # Initial parameter values # par0 = (alpha, delta, mu, epsilon_b, epsilon_s) par0 = c(0.5,0.5,300,400,500) # Call EHO function EHO_out = EHO(data) model = optim(par0, EHO_out, gr = NULL, method = c("Nelder-Mead"), hessian = FALSE) ## Parameter Estimates model$par[1] # Estimate for alpha # [1] 0.9111102 model$par[2] # Estimate for delta #[1] 0.0001231429 model$par[3] # Estimate for mu # [1] 417.1497 model$par[4] # Estimate for eb # [1] 336.075 model$par[5] # Estimate for es # [1] 466.2539 ## Estimate for PIN (model$par[1]*model$par[3])/((model$par[1]*model$par[3])+model$par[4]+model$par[5]) # [1] 0.3214394 ####
# Sample Data # Buy Sell #1 350 382 #2 250 500 #3 500 463 #4 552 550 #5 163 200 #6 345 323 #7 847 456 #8 923 342 #9 123 578 #10 349 455 Buy<-c(350,250,500,552,163,345,847,923,123,349) Sell<-c(382,500,463,550,200,323,456,342,578,455) data=cbind(Buy,Sell) # Initial parameter values # par0 = (alpha, delta, mu, epsilon_b, epsilon_s) par0 = c(0.5,0.5,300,400,500) # Call EHO function EHO_out = EHO(data) model = optim(par0, EHO_out, gr = NULL, method = c("Nelder-Mead"), hessian = FALSE) ## Parameter Estimates model$par[1] # Estimate for alpha # [1] 0.9111102 model$par[2] # Estimate for delta #[1] 0.0001231429 model$par[3] # Estimate for mu # [1] 417.1497 model$par[4] # Estimate for eb # [1] 336.075 model$par[5] # Estimate for es # [1] 466.2539 ## Estimate for PIN (model$par[1]*model$par[3])/((model$par[1]*model$par[3])+model$par[4]+model$par[5]) # [1] 0.3214394 ####
It estimates PIN using hierarchical agglomertaive clustering.
GAN(data, likelihood = c("LK", "EHO")) ## S3 method for class 'GAN_class' print(obj)
GAN(data, likelihood = c("LK", "EHO")) ## S3 method for class 'GAN_class' print(obj)
data |
Data frame with 2 variables |
likelihood |
Character strings for likelihood algorithm. Default is "LK". |
obj |
object variable |
Argument for data must be a data frame with 2 columns that only contain numbers. Not any other type. You do not have to give names to the columns. We will assign first one as "Buy" and second as "Sell", therefore you should put order numbers with respect to this order. This package uses the hclust() function of Mullner (2013) to cluster the data at default settings.
Returns a list of parameter estimates (output)
alpha |
A Number |
delta |
A Number |
mu |
A Number |
eb |
A Number |
es |
A Number |
LikVal |
A Number |
PIN |
A Number |
This function does not handle NA values. Therefore, the dataset should not contain any missing values.
Duygu Celik and Murat Tinic
D. Mullner. fastcluster: Fast hierarchical, agglomerative clustering routines for r and python. Journal of Statistical Software, 53(9):1-18, 2013.
Gan, Q., Wei, W. C., & Johnstone, D. A faster estimation method for the probability of informed trading using hierarchical agglomerative clustering. Quantitative Finance, 15(11), 1805-1821, 2015.
# Sample Data # Buy Sell #1 350 382 #2 250 500 #3 500 463 #4 552 550 #5 163 200 #6 345 323 #7 847 456 #8 923 342 #9 123 578 #10 349 455 Buy<-c(350,250,500,552,163,345,847,923,123,349) Sell<-c(382,500,463,550,200,323,456,342,578,455) data<-cbind(Buy,Sell) # Parameter estimates using the LK factorization of Lin and Ke (2011) # with the algorithm of Gan et. al. (2015). # Default factorization is set to be "LK" result=GAN(data) print(result) # Alpha: 0.3999998 # Delta: 0 # Mu: 442.1667 # Epsilon_b: 263.3333 # Epsilon_s: 424.9 # Likelihood Value: 44371.84 # PIN: 0.2044464 # Parameter estimates using the EHO factorization of Easley et. al. (2010) # with the algorithm of Gan et. al. (2015) result=GAN(data, likelihood="EHO") print(result) # Alpha: 0.3230001 # Delta: 0.4780001 # Mu: 481.3526 # Epsilon_b: 356.6359 # Epsilon_s: 313.136 # Likelihood Value: Inf # PIN: 0.1884001
# Sample Data # Buy Sell #1 350 382 #2 250 500 #3 500 463 #4 552 550 #5 163 200 #6 345 323 #7 847 456 #8 923 342 #9 123 578 #10 349 455 Buy<-c(350,250,500,552,163,345,847,923,123,349) Sell<-c(382,500,463,550,200,323,456,342,578,455) data<-cbind(Buy,Sell) # Parameter estimates using the LK factorization of Lin and Ke (2011) # with the algorithm of Gan et. al. (2015). # Default factorization is set to be "LK" result=GAN(data) print(result) # Alpha: 0.3999998 # Delta: 0 # Mu: 442.1667 # Epsilon_b: 263.3333 # Epsilon_s: 424.9 # Likelihood Value: 44371.84 # PIN: 0.2044464 # Parameter estimates using the EHO factorization of Easley et. al. (2010) # with the algorithm of Gan et. al. (2015) result=GAN(data, likelihood="EHO") print(result) # Alpha: 0.3230001 # Delta: 0.4780001 # Mu: 481.3526 # Epsilon_b: 356.6359 # Epsilon_s: 313.136 # Likelihood Value: Inf # PIN: 0.1884001
The function calculates the likelihood factorization of Lin and Ke (2011) and computes paramaters for estimation of PIN value.
LK(data, fixed = c(FALSE, FALSE, FALSE, FALSE, FALSE))
LK(data, fixed = c(FALSE, FALSE, FALSE, FALSE, FALSE))
data |
Data frame with 2 variables |
fixed |
Initial values for parameters in the following order: alpha, delta, mu, epsilon_b, epsilon_s |
In order to use LK's return in optimization functions, please omit second argument. With this way, LK will return a function instead of a value. Moreover, argument for data must be a data frame with 2 columns that contain numbers. Not any other type.
LK_out |
Returns an optim() object including parameter estimates for the likelihood factorization of Lin and Ke (2011) |
This function does not handle NA values. Therefore the datasets should not contain any missing value
Duygu Celik and Murat Tinic
Lin, H.W.W. and Ke, W.C. A computing bias in estimating the probability of informed trading. Journal of Financial Markets, 14(4), pp.625-640, 2011.
# Sample Data # Buy Sell #1 350 382 #2 250 500 #3 500 463 #4 552 550 #5 163 200 #6 345 323 #7 847 456 #8 923 342 #9 123 578 #10 349 455 Buy<-c(350,250,500,552,163,345,847,923,123,349) Sell<-c(382,500,463,550,200,323,456,342,578,455) data=cbind(Buy,Sell) # Initial parameter values # par0 = (alpha, delta, mu, epsilon_b, epsilon_s) par0 = c(0.5,0.5,300,400,500) # Call LK function LK_out = LK(data) model = optim(par0, LK_out, gr = NULL, method = c("Nelder-Mead"), hessian = FALSE) ## Parameter Estimates model$par[1] # Estimate for alpha # [1] 0.480277 model$par[2] # Estimate for delta # [1] 0.830850 model$par[3] # Estimate for mu # [1] 315.259805 model$par[4] # Estimate for eb # [1] 296.862318 model$par[5] # Estimate for es # [1] 434.3046 ## Estimate for PIN (model$par[1]*model$par[3])/((model$par[1]*model$par[3])+model$par[4]+model$par[5]) # [1] 0.178391 ####
# Sample Data # Buy Sell #1 350 382 #2 250 500 #3 500 463 #4 552 550 #5 163 200 #6 345 323 #7 847 456 #8 923 342 #9 123 578 #10 349 455 Buy<-c(350,250,500,552,163,345,847,923,123,349) Sell<-c(382,500,463,550,200,323,456,342,578,455) data=cbind(Buy,Sell) # Initial parameter values # par0 = (alpha, delta, mu, epsilon_b, epsilon_s) par0 = c(0.5,0.5,300,400,500) # Call LK function LK_out = LK(data) model = optim(par0, LK_out, gr = NULL, method = c("Nelder-Mead"), hessian = FALSE) ## Parameter Estimates model$par[1] # Estimate for alpha # [1] 0.480277 model$par[2] # Estimate for delta # [1] 0.830850 model$par[3] # Estimate for mu # [1] 315.259805 model$par[4] # Estimate for eb # [1] 296.862318 model$par[5] # Estimate for es # [1] 434.3046 ## Estimate for PIN (model$par[1]*model$par[3])/((model$par[1]*model$par[3])+model$par[4]+model$par[5]) # [1] 0.178391 ####
It estimates PIN using Yan and Zhang (2012) algorithm.
YZ(data, likelihood = c("LK", "EHO")) ## S3 method for class 'YZ_class' print(obj)
YZ(data, likelihood = c("LK", "EHO")) ## S3 method for class 'YZ_class' print(obj)
data |
Data frame with 2 variables |
likelihood |
Character strings for likelihood algorithm. Default is "LK". |
obj |
object variable |
Argument for data must be a data frame with 2 columns that only contain numbers. Not any other type. You do not have to give names to the columns. We will assign first one as "Buy" and second as "Sell", therefore you should put order numbers with respect to this order.
Returns a list of parameter estimates (output)
alpha |
A Number |
delta |
A Number |
mu |
A Number |
eb |
A Number |
es |
A Number |
LikVal |
A Number |
PIN |
A Number |
This function does not handle NA values. Therefore the datasets should not contain any missing value
Duygu Celik and Murat Tinic
Y. Yan and S. Zhang. An improved estimation method and empirical properties of the probability of informed trading. Journal of Banking & Finance, 36(2):454-467, 2012.
# Sample Data # Buy Sell #1 350 382 #2 250 500 #3 500 463 #4 552 550 #5 163 200 #6 345 323 #7 847 456 #8 923 342 #9 123 578 #10 349 455 Buy<-c(350,250,500,552,163,345,847,923,123,349) Sell<-c(382,500,463,550,200,323,456,342,578,455) data<-cbind(Buy,Sell) # Parameter estimates using the LK factorization of Lin and Ke (2011) # with the algorithm of Yan and Zhang (2012). # Default factorization is set to be "LK" result=YZ(data) print(result) # Alpha: 0.3999999 # Delta: 0 # Mu: 442.1667 # Epsilon_b: 263.3333 # Epsilon_s: 424.9 # Likelihood Value: 44371.84 # PIN: 0.2004457 # Parameter estimates using the EHO factorization of Easley et. al. (2010) # with the algorithm of Yan and Zhang (2012). result=YZ(data,likelihood="EHO") print(result) # Alpha: 0.9000001 # Delta: 0.9000001 # Mu: 489.1111 # Epsilon_b: 396.1803 # Epsilon_s: 28.72002 # Likelihood Value: Inf # PIN: 0.3321033
# Sample Data # Buy Sell #1 350 382 #2 250 500 #3 500 463 #4 552 550 #5 163 200 #6 345 323 #7 847 456 #8 923 342 #9 123 578 #10 349 455 Buy<-c(350,250,500,552,163,345,847,923,123,349) Sell<-c(382,500,463,550,200,323,456,342,578,455) data<-cbind(Buy,Sell) # Parameter estimates using the LK factorization of Lin and Ke (2011) # with the algorithm of Yan and Zhang (2012). # Default factorization is set to be "LK" result=YZ(data) print(result) # Alpha: 0.3999999 # Delta: 0 # Mu: 442.1667 # Epsilon_b: 263.3333 # Epsilon_s: 424.9 # Likelihood Value: 44371.84 # PIN: 0.2004457 # Parameter estimates using the EHO factorization of Easley et. al. (2010) # with the algorithm of Yan and Zhang (2012). result=YZ(data,likelihood="EHO") print(result) # Alpha: 0.9000001 # Delta: 0.9000001 # Mu: 489.1111 # Epsilon_b: 396.1803 # Epsilon_s: 28.72002 # Likelihood Value: Inf # PIN: 0.3321033