My Predict
Returns the predicted values.
mypredict(object, newx)
object |
An object from mls, Lasso, LassoOLS or PartialRidge. |
newx |
Matrix of the values of variables/predictors for doing prediction; each row is an observation vector. |
The predicted values for a give newx matrix is returned.
library("mvtnorm") ## generate the data set.seed(2015) n <- 200 # number of obs p <- 500 s <- 10 beta <- rep(0, p) beta[1:s] <- runif(s, 1/3, 1) x <- rmvnorm(n = n, mean = rep(0, p), method = "svd") signal <- sqrt(mean((x %*% beta)^2)) sigma <- as.numeric(signal / sqrt(10)) # SNR=10 y <- x %*% beta + rnorm(n) ## modified Least Squares set.seed(0) obj <- mls(x = x[, 1:20], y = y) # the OLS estimate of the regression coefficients obj$beta # intercept term obj$beta0 # prediction mypredict(obj, newx = matrix(rnorm(10*20), 10, 20))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.