predict.manylm
is a function for predictions from the
result of the model fitting function manylm
.## S3 method for class 'manylm':
predict(object, newdata=NULL, se.fit = FALSE,
type = c("response", "terms"), terms = NULL, na.action = na.pass, ...)
manylm
.NA
.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: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.manylm
.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