Learn R Programming

midasml (version 0.0.6)

predict.panel_sgl: Computes prediction for the sg-LASSO panel regression model

Description

Computes prediction for the sg-LASSO panel regression model

Usage

# S3 method for panel_sgl
predict(object, newX, newZ = NULL, regress_choice = c("re", "fe"), ...)

Arguments

object

fit object from panel_sgl.

newX

matrix of out-of-sample covariate observations.

newZ

optional matrix of dummies for panel data model.

regress_choice

choose between `re` and `fe`. Must be consistent with object.

...

currently ignored optional parameters.

Value

a list of these variables:

pred - overall prediction.

predZ - dummies prediction.

predX - covariates prediction.

Examples

Run this code
# NOT RUN {
set.seed(1)
t <- 10; n = 5; p = 20; size.groups = 4 
index <- ceiling(1:p / size.groups)
X <- matrix(rnorm(n * t * p), ncol = p, nrow = n*t)
beta <- c(5,4,3,2,1)
y <- X[,1:5] %*% beta + 5*rnorm(n*t)
Z <- kronecker(diag(n), rep(1, times = t))
entity_indices <- sort(rep(1:n,times=t-1))
fit <- panel_sgl(X = X, Z = Z, y = y, index = index, 
         entity_indices = entity_indices, gamma_w = 1, 
         regress_choice = "fe", method_choice = "ic", 
         num_cores = 2, verbose = FALSE)
predict.panel_sgl(object = fit, newX = X, newZ = Z, regress_choice = "fe")$pred
# }

Run the code above in your browser using DataLab