# There is a preloaded quarterly dataset called 'dailytrades' with 60
# observations. Each observation corresponds to a day and contains the
# total number of buyer-initiated trades ('B') and seller-initiated
# trades ('S') on that day. To know more, type ?dailytrades
xdata <- dailytrades
# ------------------------------------------------------------------------ #
# Posterior probabilities for PIN estimates #
# ------------------------------------------------------------------------ #
# Estimate PIN using the Ersan and Alici (2016) algorithm and the
# factorization Lin and Ke(2011).
estimate <- pin_ea(xdata, "LK", verbose = FALSE)
# Display the estimated PIN value
estimate@pin
# Store the posterior probabilities in a dataframe variable and display its
# first 6 rows.
modelposteriors <- get_posteriors(estimate)
show(round(head(modelposteriors), 3))
# ------------------------------------------------------------------------ #
# Posterior probabilities for MPIN estimates #
# ------------------------------------------------------------------------ #
# Estimate MPIN via the ECM algorithm, assuming that the dataset has 2
# information layers
estimate <- mpin_ecm(xdata, layers = 2, verbose = FALSE)
# Display the estimated Multilayer PIN value
show(estimate@mpin)
# Store the posterior probabilities in a dataframe variable and display its
# first six rows. The posterior probabilities are contained in a dataframe
# with 7 variables: one for no-information days, and two variables for each
# layer, one for good-information days and one for bad-information days.
modelposteriors <- get_posteriors(estimate)
show(round(head(modelposteriors), 3))
Run the code above in your browser using DataLab