This function predicts outcomes (y) given the observed variables (X) and a Mr.ASH model; alternatively, retrieve the estimates of the regression coefficients.
Arguments
- object
A mr_ash fit, usually the result of calling
mr.ash.- newx
The input matrix, of dimension (n,p); each column is a single predictor; and each row is an observation vector. Here, n is the number of samples and p is the number of predictors. When
newxisNULL, the fitted values for the training data are provided.- type
The type of output. For
type = "response", predicted or fitted outcomes are returned; fortype = "coefficients", the estimated coefficients are returned.- ...
Additional arguments passed to the default S3 method.
Value
For type = "response", predicted or fitted outcomes
are returned; for type = "coefficients", the estimated
coefficients are returned.
Examples
## generate synthetic data
set.seed(1)
n = 200
p = 300
X = matrix(rnorm(n*p),n,p)
beta = double(p)
beta[1:10] = 1:10
y = X %*% beta + rnorm(n)
## fit mr.ash
fit.mr.ash = mr.ash(X, y)
#> Mr.ASH terminated at iteration 25: max|beta|=1.0032e+01, sigma2=3.0601e+00, pi0=0.7703
## predict
Xnew = matrix(rnorm(n*p),n,p)
ypred = predict(fit.mr.ash, Xnew)