mvabund (version 3.13.1)

predict.manylm: Model Predictions for Multivariate Linear Models

Description

predict.manylm is a function for predictions from the result of the model fitting function manylm.

Usage


# S3 method for manylm
predict(object, newdata=NULL, se.fit = FALSE, 
    type = c("response", "terms"), terms = NULL, na.action = na.pass, ...)

Arguments

object

object of class inheriting from manylm.

newdata

an optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used.

se.fit

a switch indicating if standard errors are required.

type

type of prediction (response or model term), Possible values: "response", "terms".

terms

if type="terms", which terms (default is all terms).

na.action

function determining what should be done with missing values in newdata. The default is to predict NA.

further arguments passed to or from other methods.

Value

predict.manylm produces a matrix of predictions or if interval is set an array of predictions and bounds, where the first dimension has the names: fit, lwr, and upr. If se.fit is TRUE, a list with the following components is returned:

fit

vector or matrix as above

se.fit

a matrix with the standard errors of the predicted means

residual.scale

vector or matrix as a vector of residual standard deviations

df

numeric, the degrees of freedom for residual

Details

predict.manylm produces predicted values, obtained by evaluating the regression function in the frame newdata (which defaults to model.frame(object). If the logical se.fit is TRUE, standard errors of the predictions are calculated. If the numeric argument scale is set (with optional df), it is used as the residual standard deviation in the computation of the standard errors, otherwise this is extracted from the model fit. Setting intervals specifies computation of confidence or prediction (tolerance) intervals at the specified level, sometimes referred to as narrow vs. wide intervals.

If the fit is rank-deficient, some of the columns of the design matrix will have been dropped. Prediction from such a fit only makes sense if newdata is contained in the same subspace as the original data. That cannot be checked accurately, so a warning is issued.

If newdata is omitted the predictions are based on the data used for the fit. In that case how cases with missing values in the original fit is determined by the na.action argument of that fit. If na.action = na.omit omitted cases will not appear in the residuals, whereas if na.action = na.exclude they will appear (in predictions, standard errors or interval limits), with residual value NA. See also napredict.

The prediction intervals are for a single observation at each case in newdata (or by default, the data used for the fit) with error variance(s) pred.var. This can be a multiple of res.var, the estimated value of \(\sigma^2\): the default is to assume that future observations have the same error variance as those used for fitting. If weights is supplied, the inverse of this is used as a scale factor. For a weighted fit, if the prediction is for the original data frame, weights defaults to the weights used for the model fit, with a warning since it might not be the intended result. If the fit was weighted and newdata is given, the default is to assume constant prediction variance, with a warning.

See Also

manylm.

Examples

Run this code
# NOT RUN {
data(spider)
spiddat <- mvabund(spider$abund[1:20, ])
dat = data.frame(spider$x[1:20, ])
manylm.fit <- manylm(spiddat~soil.dry+bare.sand, data=dat)
predict(manylm.fit)
predict(manylm.fit, se.fit = TRUE)

new <- data.frame(spider$x[21:28, ])
predict(manylm.fit, new, se.fit = TRUE)

# }

Run the code above in your browser using DataLab