# 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 the initial parameter set for the maximum likelihood estimation
# using the algorithm of Gan et al.(2015).
initparams <- initials_pin_gwj(xdata)
# Use the obtained dataframe to estimate the PIN model using the function
# pin() with custom initial parameter sets
estimate.1 <- pin(xdata, initialsets = initparams, verbose = FALSE)
# pin_gwj() directly estimates the PIN model using an initial parameter set
# generated using the algorithm of Gan et al.(2015).
estimate.2 <- pin_gwj(xdata, "E", 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