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 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 model fit.mr.ash = mr_ash(X, y)#> Fitting mr.ash model (mr.ash 0.1-61). #> number of samples: 200 #> number of variables: 300 #> number of mixture components: 20 #> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #> Mr.ASH terminated at iteration 109.