EVOLUTION-MANAGER
Edit File: predict.bam.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Prediction from fitted Big Additive Model model</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for predict.bam {mgcv}"><tr><td>predict.bam {mgcv}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Prediction from fitted Big Additive Model model</h2> <h3>Description</h3> <p> Essentially a wrapper for <code><a href="predict.gam.html">predict.gam</a></code> for prediction from a model fitted by <code><a href="bam.html">bam</a></code>. Can compute on a parallel cluster. </p> <p>Takes a fitted <code>bam</code> object produced by <code><a href="bam.html">bam</a></code> and produces predictions given a new set of values for the model covariates or the original values used for the model fit. Predictions can be accompanied by standard errors, based on the posterior distribution of the model coefficients. The routine can optionally return the matrix by which the model coefficients must be pre-multiplied in order to yield the values of the linear predictor at the supplied covariate values: this is useful for obtaining credible regions for quantities derived from the model (e.g. derivatives of smooths), and for lookup table prediction outside <code>R</code> (see example code below).</p> <h3>Usage</h3> <pre> ## S3 method for class 'bam' predict(object,newdata,type="link",se.fit=FALSE,terms=NULL, exclude=NULL,block.size=50000,newdata.guaranteed=FALSE, na.action=na.pass,cluster=NULL,discrete=TRUE,n.threads=1,...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>object</code></td> <td> <p> a fitted <code>bam</code> object as produced by <code><a href="bam.html">bam</a></code>. </p> </td></tr> <tr valign="top"><td><code>newdata</code></td> <td> <p> A data frame or list containing the values of the model covariates at which predictions are required. If this is not provided then predictions corresponding to the original data are returned. If <code>newdata</code> is provided then it should contain all the variables needed for prediction: a warning is generated if not. </p> </td></tr> <tr valign="top"><td><code>type</code></td> <td> <p> When this has the value <code>"link"</code> (default) the linear predictor (possibly with associated standard errors) is returned. When <code>type="terms"</code> each component of the linear predictor is returned seperately (possibly with standard errors): this includes parametric model components, followed by each smooth component, but excludes any offset and any intercept. <code>type="iterms"</code> is the same, except that any standard errors returned for smooth components will include the uncertainty about the intercept/overall mean. When <code>type="response"</code> predictions on the scale of the response are returned (possibly with approximate standard errors). When <code>type="lpmatrix"</code> then a matrix is returned which yields the values of the linear predictor (minus any offset) when postmultiplied by the parameter vector (in this case <code>se.fit</code> is ignored). The latter option is most useful for getting variance estimates for quantities derived from the model: for example integrated quantities, or derivatives of smooths. A linear predictor matrix can also be used to implement approximate prediction outside <code>R</code> (see example code, below). </p> </td></tr> <tr valign="top"><td><code>se.fit</code></td> <td> <p> when this is TRUE (not default) standard error estimates are returned for each prediction.</p> </td></tr> <tr valign="top"><td><code>terms</code></td> <td> <p>if <code>type=="terms"</code> or <code>type="iterms"</code> then only results for the terms (smooth or parametric) named in this array will be returned. Otherwise any smooth terms not named in this array will be set to zero. If <code>NULL</code> then all terms are included.</p> </td></tr> <tr valign="top"><td><code>exclude</code></td> <td> <p>if <code>type=="terms"</code> or <code>type="iterms"</code> then terms (smooth or parametric) named in this array will not be returned. Otherwise any smooth terms named in this array will be set to zero. If <code>NULL</code> then no terms are excluded.</p> </td></tr> <tr valign="top"><td><code>block.size</code></td> <td> <p>maximum number of predictions to process per call to underlying code: larger is quicker, but more memory intensive.</p> </td></tr> <tr valign="top"><td><code>newdata.guaranteed</code></td> <td> <p>Set to <code>TRUE</code> to turn off all checking of <code>newdata</code> except for sanity of factor levels: this can speed things up for large prediction tasks, but <code>newdata</code> must be complete, with no <code>NA</code> values for predictors required in the model. </p> </td></tr> <tr valign="top"><td><code>na.action</code></td> <td> <p>what to do about <code>NA</code> values in <code>newdata</code>. With the default <code>na.pass</code>, any row of <code>newdata</code> containing <code>NA</code> values for required predictors, gives rise to <code>NA</code> predictions (even if the term concerned has no <code>NA</code> predictors). <code>na.exclude</code> or <code>na.omit</code> result in the dropping of <code>newdata</code> rows, if they contain any <code>NA</code> values for required predictors. If <code>newdata</code> is missing then <code>NA</code> handling is determined from <code>object$na.action</code>.</p> </td></tr> <tr valign="top"><td><code>cluster</code></td> <td> <p><code>predict.bam</code> can compute in parallel using <a href="../../parallel/html/parLapply.html">parLapply</a> from the <code>parallel</code> package, if it is supplied with a cluster on which to do this (a cluster here can be some cores of a single machine). See details and example code for <code><a href="bam.html">bam</a></code>. </p> </td></tr> <tr valign="top"><td><code>discrete</code></td> <td> <p>if <code>TRUE</code> then discrete prediction methods used with model fitted by discrete methods. <code>FALSE</code> for regular prediction.</p> </td></tr> <tr valign="top"><td><code>n.threads</code></td> <td> <p>if <code>se.fit=TRUE</code> and discrete prediction is used then parallel computation can be used to speed up se calcualtion. This specifies number of htreads to use.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p> other arguments.</p> </td></tr> </table> <h3>Details</h3> <p>The standard errors produced by <code>predict.gam</code> are based on the Bayesian posterior covariance matrix of the parameters <code>Vp</code> in the fitted bam object. </p> <p>To facilitate plotting with <code><a href="../../stats/html/termplot.html">termplot</a></code>, if <code>object</code> possesses an attribute <code>"para.only"</code> and <code>type=="terms"</code> then only parametric terms of order 1 are returned (i.e. those that <code>termplot</code> can handle). </p> <p>Note that, in common with other prediction functions, any offset supplied to <code><a href="gam.html">gam</a></code> as an argument is always ignored when predicting, unlike offsets specified in the gam model formula. </p> <p>See the examples in <code><a href="predict.gam.html">predict.gam</a></code> for how to use the <code>lpmatrix</code> for obtaining credible regions for quantities derived from the model. </p> <h3>Value</h3> <p> If <code>type=="lpmatrix"</code> then a matrix is returned which will give a vector of linear predictor values (minus any offest) at the supplied covariate values, when applied to the model coefficient vector. Otherwise, if <code>se.fit</code> is <code>TRUE</code> then a 2 item list is returned with items (both arrays) <code>fit</code> and <code>se.fit</code> containing predictions and associated standard error estimates, otherwise an array of predictions is returned. The dimensions of the returned arrays depends on whether <code>type</code> is <code>"terms"</code> or not: if it is then the array is 2 dimensional with each term in the linear predictor separate, otherwise the array is 1 dimensional and contains the linear predictor/predicted values (or corresponding s.e.s). The linear predictor returned termwise will not include the offset or the intercept. </p> <p><code>newdata</code> can be a data frame, list or model.frame: if it's a model frame then all variables must be supplied. </p> <h3>WARNING </h3> <p>Predictions are likely to be incorrect if data dependent transformations of the covariates are used within calls to smooths. See examples in <code><a href="predict.gam.html">predict.gam</a></code>. </p> <h3>Author(s)</h3> <p> Simon N. Wood <a href="mailto:simon.wood@r-project.org">simon.wood@r-project.org</a> </p> <p>The design is inspired by the S function of the same name described in Chambers and Hastie (1993) (but is not a clone). </p> <h3>References</h3> <p>Chambers and Hastie (1993) Statistical Models in S. Chapman & Hall. </p> <p>Marra, G and S.N. Wood (2012) Coverage Properties of Confidence Intervals for Generalized Additive Model Components. Scandinavian Journal of Statistics. </p> <p>Wood S.N. (2006b) Generalized Additive Models: An Introduction with R. Chapman and Hall/CRC Press. </p> <h3>See Also</h3> <p><code><a href="bam.html">bam</a></code>, <code><a href="predict.gam.html">predict.gam</a></code></p> <h3>Examples</h3> <pre> ## for parallel computing see examples for ?bam ## for general useage follow examples in ?predict.gam </pre> <hr /><div style="text-align: center;">[Package <em>mgcv</em> version 1.8-28 <a href="00Index.html">Index</a>]</div> </body></html>