Description Usage Arguments Value Examples
Returns the predicted values.
1 | 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.