Calculate bandwidth(s) by cross-validation for functions tvSURE, tvVAR and tvLM.

bw(x, ...)

# S3 method for default
bw(
  x,
  y,
  z = NULL,
  cv.block = 0,
  est = c("lc", "ll"),
  tkernel = c("Triweight", "Epa", "Gaussian"),
  singular.ok = TRUE,
  ...
)

# S3 method for list
bw(
  x,
  y,
  z = NULL,
  cv.block = 0,
  est = c("lc", "ll"),
  tkernel = c("Triweight", "Epa", "Gaussian"),
  singular.ok = TRUE,
  ...
)

# S3 method for tvlm
bw(x, ...)

# S3 method for tvar
bw(x, ...)

# S3 method for tvvar
bw(x, ...)

# S3 method for tvsure
bw(x, ...)

# S3 method for tvplm
bw(x, ...)

# S3 method for pdata.frame
bw(
  x,
  z = NULL,
  method,
  cv.block = 0,
  est = c("lc", "ll"),
  tkernel = c("Triweight", "Epa", "Gaussian"),
  ...
)

Arguments

x

An object used to select a method.

...

Other parameters passed to specific methods.

y

A matrix or vector with the dependent variable(s).

z

A vector with the variable over which coefficients are smooth over.

cv.block

A positive scalar with the size of the block in leave-one block-out cross-validation. By default 'cv.block=0' meaning leave-one-out cross-validation.

est

The nonparametric estimation method, one of "lc" (default) for linear constant or "ll" for local linear.

tkernel

A character, either "Triweight" (default), "Epa" or "Gaussian" kernel function.

singular.ok

Logical. If FALSE, a singular model is an error.

method

A character with the choice of panel model/estimation method: If method = tvPOLS (default) then the data is pooled estimated with time-varying OLS. No individual or time effects are estimated If method = tvFE then individual effects which might be correlated with the regressors are estimated. If method = tvRE then individual effects are considered random and independent of the regressors.

Value

bw returns a vector or a scalar with the bandwith to estimate the mean or the covariance residuals, fitted values.

A scalar or a vector of scalars.

A scalar.

Examples

##Generate data tau <- seq(1:200)/200 beta <- data.frame(beta1 = sin(2*pi*tau), beta2 = 2*tau) X <- data.frame(X1 = rnorm(200), X2 = rchisq(200, df = 4)) error <- rt(200, df = 10) y <- apply(X*beta, 1, sum) + error ##Select bandwidth by cross-validation bw <- bw(X, y, est = "ll", tkernel = "Gaussian") data( Kmenta, package = "systemfit" ) ## x is a list of matrices containing the regressors, one matrix for each equation x <- list() x[[1]] <- Kmenta[, c("price", "income")] x[[2]] <- Kmenta[, c("price", "farmPrice", "trend")] ## 'y' is a matrix with one column for each equation y <- cbind(Kmenta$consump, Kmenta$consump) ## Select bandwidth by cross-validation bw <- bw(x = x, y = y) ##One bandwidth per equation print(bw)
#> [1] 19.999999 2.430075