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"), ...)

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 newx is NULL, the fitted values for the training data are provided.

type

The type of output. For type = "response", predicted or fitted outcomes are returned; for type = "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 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.
## predict Xnew = matrix(rnorm(n*p),n,p) ypred = predict(fit.mr.ash, Xnew)