# 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
# The function adjpin(xdata, initialsets="CL") allows the user to directly
# estimate the AdjPIN model using the full set of initial parameter sets
# generated using the algorithm Cheng and Lai (2021)
# \donttest{
estimate.1 <- adjpin(xdata, initialsets="CL", verbose = FALSE)
# }
# Obtaining the set of initial parameter sets using initials_adjpin_cl
# allows us to estimate the PIN model using a subset of these initial sets.
# Use initials_adjpin_cl() to generate 256 initial parameter sets using the
# algorithm of Cheng and Lai (2021).
initials_cl <- initials_adjpin_cl(xdata, verbose = FALSE)
# Use 20 randonly chosen initial sets from the dataframe 'initials_cl' in
# order to estimate the AdjPIN model using the function adjpin() with custom
# initial parameter sets
numberofsets <- nrow(initials_cl)
selectedsets <- initials_cl[sample(numberofsets, 20),]
estimate.2 <- adjpin(xdata, initialsets = selectedsets, verbose = FALSE)
# Compare the parameters and the pin values of both specifications
# \donttest{
comparison <- rbind(
c(estimate.1@parameters, adjpin = estimate.1@adjpin, psos = estimate.1@psos),
c(estimate.2@parameters, estimate.2@adjpin, estimate.2@psos))
rownames(comparison) <- c("all", "50")
show(comparison)
# }
Run the code above in your browser using DataLab