predict.mr.ash | R Documentation |
This function predicts outcomes (y) given the observed variables (X) and a Mr.ASH model; alternatively, retrieve the estimates of the regression coefficients.
## S3 method for class 'mr.ash'
predict(object, newx = NULL, type = c("response", "coefficients"), ...)
object |
A mr_ash fit, usually the result of calling
|
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
|
type |
The type of output. For |
... |
Additional arguments passed to the default S3 method. |
For type = "response"
, predicted or fitted outcomes
are returned; for type = "coefficients"
, the estimated
coefficients are returned.
## 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)
## predict
Xnew = matrix(rnorm(n*p),n,p)
ypred = predict(fit.mr.ash, Xnew)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.