Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mypredict

My Predict


Description

Returns the predicted values.

Usage

mypredict(object, newx)

Arguments

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.

Value

The predicted values for a give newx matrix is returned.

Examples

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))

HDCI

High Dimensional Confidence Interval Based on Lasso and Bootstrap

v1.0-2
GNU General Public License version 2
Authors
Hanzhong Liu, Xin Xu, Jingyi Jessica Li
Initial release
2017-06-06

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.