This function conducts a leave-one-out cross-validation approach to determine the best bandwidth for the data.

pois_vcm_cv(
  formula,
  data,
  time,
  id = NULL,
  bandwidths = NULL,
  kernel = "epanechnikov"
)

Arguments

formula

A formula class object. Provides information about the names of the response and predictor variables.

data

A data frame containing the variables needed for the function.

time

The name of the variable indicating the time points for each observation.

id

The name of the variable to group observations. Necessary when dealing with repeated measurements such as longitudinal data.

bandwidths

A vector containing the bandwidth values for the cross-validation. Default is tests 50 bandwidths from ranging from double the smallest time point difference to range of time points.

kernel

The name of the kernel function used to estimate the varying-coefficient values. Default is Epanechnikov.

Value

pois_vcm_cv returns a list containing the results from the cross-validation

  • recommended_bandwidth: The bandwidth with the smallest negative log-likelihood.

  • value: value of negative log-likelihood at recommended bandwidth

  • neg_logliks: The tested bandwidths and their corresponding negative log-likelihood value.

Author

Isaac Quintanilla Salinas

Examples

cv_fit <- pois_vcm_cv(formula = Y~x1+x2, data = pois_data, time = time, id = id) summary(cv_fit)
#> [1] "Recommended Bandwidth: 0.0833333333333333" #> [1] "Negative Log-Likelihood Value: 2993.83371402404"