predict.scam(scam)
predict.scam()所属R语言包:scam
Prediction from fitted SCAM model
从装SCAM模型预测
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This function is a clone of the mgcv library code predict.gam with some modifications to adopt shape preserving smooth terms. It takes a fitted scam object produced by scam() 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.
这个函数是一个克隆的mgcv库的代码predict.gam一些修改采用保形光滑条款,。这需要一个装有scam对象scam(),并产生了一套新的模型协变量的值或使用的初始值的模型拟合预测。预测可以伴随着标准误差,基于模型系数的后验分布。
For extrapolation of the response variable values in case of a single univariate shape constrained term see extrapolate.uni.scam.
对于推断的响应变量值的情况下,一个单一的单变量形状的限制,术语看extrapolate.uni.scam。
用法----------Usage----------
## S3 method for class 'scam'
predict(object,newdata,type="link",se.fit=FALSE,terms=NULL,
block.size=1000,newdata.guaranteed=FALSE,na.action=na.pass,...)
参数----------Arguments----------
参数:object
a fitted scam object as produced by scam().
一个装有scam对象产生的scam()。
参数:newdata
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 newdata is provided then it should contain all the variables needed for prediction: a warning is generated if not.
一个数据框或列表,其中包含该模型的值协变量预测需要。如果这是不设置,那么预测对应的原始数据的返回。如果newdata提供,那么它应该包含所有需要的变量的预测:如果不产生一个警告。
参数:type
When this has the value "link" (default) the linear predictor (possibly with associated standard errors) is returned. When type="terms" 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. type="iterms" is the same, except that any standard errors returned for smooth components will include the uncertainty about the intercept/overall mean. When type="response" predictions on the scale of the response are returned (possibly with approximate standard errors). When type="lpmatrix" 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 se.fit 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 R (see example code, below).
当值"link"(默认)的线性预测(可能与相关的标准误差)返回。当type="terms"的线性预测的每个组件返回单独(可能与标准误差):这包括参数的模型组件,然后由每个平滑分量,但不包括任何偏移和任何截距。 type="iterms"是一样的,但任何标准返回的错误平滑分量将包括拦截/整体平均的不确定性。当type="response"预测上规模的响应返回(可能与近似的标准误)。当type="lpmatrix"然后返回矩阵得到的线性预测值的(减去任何偏移)当postmultiplied由参数矢量(在这种情况下se.fit被忽略)。后一种选择的数量从模型中派生得到的方差估计是最有用的,例如:集成的数量,或衍生工具的平滑。线性预测矩阵也可以用来实现近似预测外R(见下面的示例代码,)。
参数:se.fit
when this is TRUE (not default) standard error estimates are returned for each prediction.
这是TRUE(默认值)的标准误差估计每个预测返回。
参数:terms
if type=="terms" then only results for the terms given in this array will be returned.
如果type=="terms"然后将返回结果仅此数组中的条款。
参数:block.size
maximum number of predictions to process per call to underlying code: larger is quicker, but more memory intensive. Set to < 1 to use total number of predictions as this.
最大数量的预测处理每调用底层代码:较大的是更快,但更多的内存密集型的。设置为1,使用总人数的预测。
参数:newdata.guaranteed
Set to TRUE to turn off all checking of newdata except for sanity of factor levels: this can speed things up for large prediction tasks, but newdata must be complete, with no NA values for predictors required in the model.
设置为TRUE关闭所有检查newdata除了理智因子水平,这样可以加快大预测任务,但newdata必须是完整的,没有<X >值模型中所需的预测因子。
参数:na.action
what to do about NA values in newdata. With the default na.pass, any row of newdata containing NA values for required predictors, gives rise to NA predictions (even if the term concerned has no NA predictors). na.exclude or na.omit result in the dropping of newdata rows, if they contain any NA values for required predictors. If newdata is missing then NA handling is determined from object$na.action.
怎么办NA值newdata。使用的默认na.pass,任何行newdataNA所需的预测值,产生NA预测(即使有关的术语有没有NA预测变量)。 na.exclude或na.omit在滴newdata行的结果,如果它们包含任何NA所需的预测值。如果newdata丢失,则NA处理确定object$na.action。
参数:...
other arguments.
其他参数。
Details
详细信息----------Details----------
See predict.gam for details.
见predict.gam的详细信息。
值----------Value----------
If type=="lpmatrix" 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 se.fit is TRUE then a 2 item list is returned with items (both arrays) fit and se.fit containing predictions and associated standard error estimates, otherwise an array of predictions is returned. The dimensions of the returned arrays depends on whether type is "terms" 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.
如果type=="lpmatrix"然后返回矩阵,这将得到的线性预测值的矢量(减去任何offest)在提供的协变量值,当施加到模型系数向量。否则,如果se.fit是TRUE2项列表的项目(包括数组)返回fit和se.fit包含预测和相关的标准误差估计,否则数组预测被返回。返回的数组的尺寸取决于是否type是"terms"或不是:如果是则该数组为2维与单独的线性预测器中的每一项,否则该数组是1维的,并包含线性预测值/预测值(或相应的SES)。返回的线性预测逐项将不包括偏移或拦截。
newdata can be a data frame, list or model.frame: if it's a model frame then all variables must be supplied.
newdata可以是一个数据框,列表或model.frame:如果它是一个模型框架,那么所有的变量都必须提供。
(作者)----------Author(s)----------
Natalya Pya <nat.pya@gmail.com> based partly on <code>mgcv</code> by Simon Wood
参考文献----------References----------
参见----------See Also----------
scam, plot.scam
scam,plot.scam
实例----------Examples----------
## Not run: [#不运行:]
library(scam)
set.seed(2)
n <- 200
x1 <- runif(n)*6-3
f1 <- 3*exp(-x1^2) # unconstrained term[不受约束的术语]
x2 <- runif(n)*4-1;
f2 <- exp(4*x2)/(1+exp(4*x2)) # monotone increasing smooth[单调递增光滑]
f <- f1+f2
y <- f+rnorm(n)*0.2
dat <- data.frame(x1=x1,x2=x2,y=y)
b <- scam(y~s(x1,k=15,bs="cr",m=2)+s(x2,k=30,bs="mpi",m=2),
family=gaussian(link="identity"),data=dat)
newd <- data.frame(x1=seq(-2.9,2.9,length.out=30),x2=seq(-0.9,2.9,length.out=30))
pred <- predict.scam(b,newd)
pred
predict(b,newd,type="terms",se=TRUE)
plot(b,se=TRUE,residuals=TRUE,pages=1)
## obtaining a 'prediction matrix'...[#获得“预测矩阵”...]
newd <- data.frame(x1=c(-2,-1),x2=c(0,1))
Xp <- predict(b,newdata=newd,type="lpmatrix")
fv <- Xp
fv
## End(Not run)[#(不执行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|