Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/predict.manylm.R

`predict.manylm`

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

.

1 2 3 |

`object` |
object of class inheriting from |

`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 |

`...` |
further arguments passed to or from other methods. |

`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.

`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 |

Variables are first looked for in `newdata`

and then searched for
in the usual way (which will include the environment of the formula
used in the fit). A warning will be given if the
variables found are not of the same length as those in `newdata`

if it was supplied.

Offsets specified by `offset`

in the fit by `lm`

will not be included in predictions, whereas those specified by an
offset term in the formula will be.

Notice that prediction variances and prediction intervals always refer
to *future* observations, possibly corresponding to the same
predictors as used for the fit. The variance of the *residuals*
will be smaller.

Strictly speaking, the formula used for prediction limits assumes that
the degrees of freedom for the fit are the same as those for the
residual variance. This may not be the case if `res.var`

is
not obtained from the fit.

Ulrike Naumann, Yi Wang and David Warton <[email protected]>.

1 2 3 4 5 6 7 8 9 | ```
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)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.