# 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
# Obtain a dataframe of initial parameters for the maximum likelihood
# estimation using the algorithm of Ersan and Alici (2016).
init.sets <- initials_pin_ea(xdata)
# Use the obtained dataframe to estimate the PIN model using the function
# pin() with custom initial parameter sets
estimate.1 <- pin(xdata, initialsets = init.sets, verbose = FALSE)
# pin_ea() directly estimates the PIN model using initial parameter sets
# generated using the algorithm of Ersan & Alici (2016).
estimate.2 <- pin_ea(xdata, verbose = FALSE)
# Check that the obtained results are identical
show(estimate.1@parameters)
show(estimate.2@parameters)
Run the code above in your browser using DataLab