找回密码
 注册
查看: 475|回复: 0

R语言 scam包 scam()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-29 22:38:22 | 显示全部楼层 |阅读模式
scam(scam)
scam()所属R语言包:scam

                                        Shape constrained additive models (SCAM) and integrated smoothness selection
                                         形状受限的加性模型(SCAM)和集成的平滑选择

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

This function fits a SCAM to data. Univariate smooths subject to monotonicity, convexity, or monotonicity plus convexity are available as model terms, as well as bivariate smooths with double or single monotonicity. Smoothness selection is estimated as part of the fitting.  Confidence/credible intervals are available for each smooth term.   
此功能适合骗局的数据。单因素模型计算,以及双或单单调二元平滑平滑单调性,凹凸,或单调性加上凸。光滑选择被估计为接头的一部分。可用于每个平滑术语的信心/可信区间。

All the shaped constrained smooths have been added to the mgcv(gam) setup using the smooth.construct function. The routine calls a mgcv{gam} function for the model set up, but there are  separate functions for the model fitting, scam.fit, and smoothing parameter selection,  bfgs_gcv.ubre. Any unconstrained smooth available in gam can be taken  as model terms.
所有形约束平滑mgcv(gam)使用smooth.construct函数的设置已被添加到。程序调用了一个mgcv{gam}函数模型的建立,但也有独立的功能模型拟合,scam.fit,平滑参数的选择,bfgs_gcv.ubre。可在任何无约束光滑gam可以作为模型项。

A function extrapolate.uni.scam  to predict future values of the response variable in case of a single univariate shape constrained term has been added.
的功能extrapolate.uni.scam预测未来的值的响应变量的情况下,一个单一的单变量形状的约束项已被添加。


用法----------Usage----------


scam(formula, family = gaussian(), data = list(), gamma = 1,
      sp = NULL, weights = NULL, offset = NULL,
      optimizer="bfgs", optim.method=c("Nelder-Mead","fd"),
      scale = 0, epsilon = 1e-08, check.analytical=FALSE,
     del=1e-4, start= NULL, etastart, mustart)



参数----------Arguments----------

参数:formula
A SCAM formula.   This is exactly like the formula for a GAM (see formula.gam of the mgcv library) except that monotone smooth terms, can be added in the expression of the form <br> s(x1,k=12,bs="mpi",by=z),<br>  where bs indicates the basis to use for the constrained smooth:  the built in options for the monotonic smooths are described in shape.constrained.smooth.terms,   
公式是一个骗局。这是完全一样的GAM公式(见formula.gammgcv库)除了单调顺利条款,可以被添加在表达形式<br>物理化学学报s(x1,k=12,bs="mpi",by=z),< bs表示的基础使用的约束光滑单调的选项内置的平滑描述shape.constrained.smooth.terms


参数:family
A family object specifying the distribution and link to use in fitting etc. See glm and family for more details.
一个家庭对象指定的分配和使用链接配件等glm和family的详细信息。


参数:data
A data frame or list containing the model response variable and  covariates required by the formula. By default the variables are taken  from  environment(formula): typically the environment from  which gam is called.  
式所需的一个数据框或列表包含模型响应变量,协变量。默认情况下,变量从environment(formula):gam被称为典型的环境。


参数:gamma
A constant multiplier to inflate the model degrees of freedom in the GCV or UBRE/AIC score.
一个常乘数膨胀的GCV或UBRE的/ AIC评分模型的自由度。


参数:sp
A vector of smoothing parameters can be provided here. Smoothing parameters must be supplied in the order that  the smooth terms appear in the model formula. The default sp=NULL indicates that smoothing parameters should be estimated. If length(sp) does not correspond to the number of underlying smoothing parameters or negative values supplied then the vector is ignored and all the smoothing parameters will be estimated.
平滑化参数的一种向量,可以提供在这里。必须提供平滑参数的顺序,顺利的词出现在模型公式。应估计表明,平滑参数的默认sp=NULL。如果length(sp)不对应的数目相关的平滑化参数值或负值的供给,然后该向量被忽略,并且将估计所有的平滑参数。


参数:weights
Prior weights on the data.
上的数据之前的重量。


参数:offset
Can be used to supply a model offset for use in fitting.
可以用来提供一个模型偏移量用于接头。


参数:optimizer
The numerical optimization method to use to optimize the smoothing  parameter estimation criterion. "bfgs" for the built in to scam package routine bfgs_gcv.ubre, "optim", "nlm", "nlm.fd" (based on finite-difference approximation of the derivatives).
数值优化方法,使用,优化平滑参数估计准则。 “的BFGS”为内置的scam包例行bfgs_gcv.ubre,“OPTIM”,“NLM”,“nlm.fd”(基于有限差分近似的衍生工具)。


参数:optim.method
In case of optimizer="optim" this specifies the numerical method to be used in optim in the first element, the second element of optim.method indicates whether the finite difference approximation should be used ("fd") or analytical gradient ("grad"). The default is optim.method=c("Nelder-Mead","fd").
的情况下,optimizer="optim":这个指定的数值计算方法中使用的optim中的第一个元素,第二个元素的optim.method表示是否应采用有限差分近似(“FD” )或解析梯度(“毕业生”)。默认的optim.method=c("Nelder-Mead","fd")。


参数:scale
If this is positive then it is taken as the known scale parameter of the exponential family distribution. Negative value indicates that the scale paraemter is unknown. 0 indicates that the scale parameter is 1  for Poisson and binomial and unknown otherwise. This conforms to the behaviour of gam.  
如果这是肯定的,那么它被当作参数指数族分布已知的规模。负值表示,该的规模paraemter是未知的。 0表示泊松分布和二项分布和未知的,否则,尺度参数为1。符合的行为gam。


参数:epsilon
A positive scalar giving the convergence control for the model fitting algorithm.
一个正标量,模型的拟合算法的收敛控制。


参数:check.analytical
If this is TRUE then finite difference derivatives of GCV/UBRE score will be calculated.  
如果这是TRUE然后差分的衍生产品GCV / UBRE的得分将被计算。


参数:del
A positive scalar (default is 1e-4) giving an increment for finite difference approximation when  check.analytical=TRUE.
一个正标量(默认是1e-4)增量有限差分近似check.analytical=TRUE。


参数:start
Initial values for the model coefficients
为模型系数的初始值


参数:etastart
Initial values for the linear predictor
初始值的线性预测


参数:mustart
Initial values for the expected values
为预期值的初始值


Details

详细信息----------Details----------

A shape constrained additive model (SCAM) is a generalized linear model (GLM)  in which the linear predictor is given by strictly parametric components plus a sum of smooth functions of the covariates where some of the functions are assumed to be shape constrained. For example,
A字形的限制加性模型(SCAM)是一个广义线性模型(GLM)的线性预测给出了严格的参数化组件加上了一笔光滑函数的协变量的一些功能都被假定为形状的限制。例如,

where the independent response variables Y_i follow Poisson distribution with log link function, f_1, m_2, and f_3 are smooth functions of the corresponding covariates, and m_2  is subject to monotone increasing constraint.  
在那里独立的响应变量Y_i服从泊松分布log链接功能,f_1,m_2,f_3是相应的协变量的函数的平滑, m_2是单调递增的约束。

All available shape constrained smooths are decsribed in shape.constrained.smooth.terms.
制约平滑所有可用的形状是shape.constrained.smooth.termsdecsribed的。


值----------Value----------

The function returns an object of class "scam" with the following elements (this agrees with gamObject):
该函数返回一个类的对象"scam"包含下列元素(同意gamObject):


参数:aic
AIC of the fitted model: the degrees of freedom used to calculate this are the effective degrees of freedom of the model, and the likelihood is evaluated at the maximum of the penalized likelihood, not at the MLE.
AIC的拟合模型的自由度用来计算模型的自由,这是有效度,并受到处罚的可能性最大,而不是在最大似然估计的可能性进行评估。


参数:assign
Array whose elements indicate which model term (listed in pterms) each parameter relates to: applies only to non-smooth terms.
数组的元素显示模型项(列在pterms)每个参数涉及:只适用于非光滑。


参数:bfgs.info
If optimizer="bfgs", a list of convergence diagnostics relating to the BFGS method of smoothing parameter selection. The items are:  conv, indicates why the BFGS algorithm of the smoothness selection terminated; iter, number of iterations of BFGS taken to get convergence; grad, the gradient of the GCV/UBRE score at  convergence.  
如果optimizer="bfgs",列表收敛BFGS方法平滑参数选择有关的诊断。件是:conv,表示BFGS算法的平滑选择终止的原因;iter,多采取得到收敛的迭代的BFGS;grad,梯度的GCV / UBRE的得分在收敛。


参数:optim.info
If optimizer="optim", a list of convergence diagnostics relating to the BFGS method of smoothing parameter selection. The items are:  conv, indicates why the BFGS algorithm of the smoothness selection terminated; iter, number of iterations of BFGS taken to get convergence; optim.method, the numerical optimization method used.  
如果optimizer="optim",列表收敛BFGS方法平滑参数选择有关的诊断。的项目是:conv,表示的平滑选择BFGS算法终止的原因;iter,得到收敛;optim.method,使用的数值优化方法的BFGS迭代数。


参数:nlm.info
If optimizer="nlm" or optimizer="nlm.fd", a list of convergence diagnostics relating to the BFGS method of smoothing parameter selection. The items are:  conv, indicates why the BFGS algorithm of the smoothness selection terminated; iter, number of iterations of BFGS taken to get convergence; grad, the gradient of the GCV/UBRE score at  convergence.  
如果optimizer="nlm"或optimizer="nlm.fd",平滑参数选择的BFGS方法的收敛诊断的列表。件是:conv,表示BFGS算法的平滑选择终止的原因;iter,多采取得到收敛的迭代的BFGS;grad,梯度的GCV / UBRE的得分在收敛。


参数:coefficients
the coefficients of the fitted model. Parametric coefficients are  first, followed  by coefficients for each spline term in turn.
拟合模型系数。参数系数分别为第一,其次是每花键词反过来系数。


参数:coefficients.t
the parametrized coefficients of the fitted model (exponentiated for the monotonic smooths).
参数化系数的拟合模型(指数化的单调平滑)。


参数:conv
indicates whether or not the iterative fitting method converged.  
表示是否不是迭代拟合方法会聚。


参数:CPU.time
indicates the real and CPU time (in seconds) taken by the fitting process in case of unknown smoothing parameters
表示的实部和CPU时间(以秒为单位)的嵌合过程中未知的平滑化参数的情况下采取


参数:data
the original supplied data argument.  
最初提供的数据参数。


参数:deviance
model deviance (not penalized deviance).
模型越轨行为(不处罚偏差)。


参数:edf
estimated degrees of freedom for each model parameter. Penalization means that many of these are less than 1.
每个模型参数估计的自由度。刑事罪装置,许多这些都小于1。


参数:family
family object specifying distribution and link used.
家庭指定分配对象和链接。


参数:fitted.values
fitted model predictions of expected value for each datum.
每个数据的预期值拟合模型的预测。


参数:formula
the model formula.
模型公式。


参数:gcv.ubre
the minimized GCV or UBRE score.
最小化的GCV或UBRE的成绩。


参数:dgcv.ubre
the gradient of the GCV or UBRE score.
的梯度的GCV或UBRE的成绩。


参数:iter
number of iterations of the Newton-Raphson method taken to get convergence.
Newton-Raphson方法采取得到收敛的迭代数。


参数:linear.predictors
fitted model prediction of link function of expected value for  each datum.
拟合模型的预测链接功能的每个数据的预期值。


参数:method
"GCV" or "UBRE", depending on the fitting criterion used.
"GCV"或"UBRE",这取决于所使用的配件标准。


参数:model
model frame containing all variables needed in original model fit.
模型框架包含了所有需要的变量在原模型的拟合。


参数:nsdf
number of parametric, non-smooth, model terms including the intercept.
数量的参数,非光滑模型的条件,包括拦截。


参数:null.deviance
deviance for single parameter model.  
单参数模型的离差。


参数:offset
model offset.
模型偏移量。


参数:prior.weights
prior weights on observations.  
在观测前的权重。


参数:pterms
terms object for strictly parametric part of model.
terms对象进行严格的参数化零件的模型。


参数:residuals
the working residuals for the fitted model.
工作的拟合模型的残差。


参数:scale.known
FALSE if the scale parameter was estimated, TRUE otherwise.
FALSE如果尺度参数估计,TRUE否则。


参数:sig2
estimated or supplied variance/scale parameter.
估计或提供的方差/缩放参数。


参数:smooth
list of smooth objects, containing the basis information for each term in the  model formula in the order in which they appear. These smooth objects are returned by the smooth.construct objects.
光滑的对象列表,在它们出现的顺序模型中的公式包含每学期的基础信息。这些光滑的对象返回smooth.construct对象。


参数:sp
estimated smoothing parameters for the model. These are the underlying smoothing parameters, subject to optimization.
平滑化参数为模型估计。这些都是相关的平滑参数,优化。


参数:termcode
an integer indicating why the optimization process of the smoothness selection terminated (see bfgs_gcv.ubre).
一个整数,指示的优化过程中的平滑选择终止的原因(见bfgs_gcv.ubre“)。


参数:terms
terms object of model model frame.
terms对象的model模型框架。


参数:trA
trace of the influence matrix, total number of the estimated degrees of freedom (sum(edf)).
跟踪的影响矩阵,总数的估计自由度(sum(edf))。


参数:Ve
frequentist estimated covariance matrix for the parameter estimators.
频率统计参数估计的协方差矩阵估计。


参数:Vp
estimated covariance matrix for the parameters. This is a Bayesian posterior covariance matrix that results from adopting a particular Bayesian model of the smoothing process.
参数估计的协方差矩阵。这是一个贝叶斯后验协方差矩阵,采用了特殊的贝叶斯模型的平滑处理的结果。


参数:Ve.t
frequentist estimated covariance matrix for the reparametrized parameter estimators obtained using the delta method. Particularly useful for testing whether terms are zero. Not so useful for CI's as smooths are usually biased.
频率统计估计的协方差矩阵的reparametrized使用增量方法得到的参数估计。特别有用的测试是否为零条款的。并非如此有用为CI的平滑的通常是有偏见的。


参数:Vp.t
estimated covariance matrix for the reparametrized parameters obtained using the delta method.  Paricularly useful for creating credible/confidence intervals.
估计协方差矩阵的reparametrized参数获得的使用Delta的方法。 Paricularly创建可信/可信区间。


参数:weights
final weights used in the Newton-Raphson iteration.
在Newton-Raphson迭代的最终权重。


参数:X
model matrix.
模型矩阵。


参数:cmX
column means of the model matrix (with elements corresponding to smooths set to zero).
列装置的模型矩阵(与对应的平滑的元素设置为零)。


参数:y
response data.
响应数据。


(作者)----------Author(s)----------



Natalya Pya &lt;nat.pya@gmail.com&gt; based partly on <code>mgcv</code> by Simon Wood




参考文献----------References----------


additive models. J.R.Statist.Soc.B 70(3):495-518. [Generalized additive model methods]
and Hall/CRC Press.


参见----------See Also----------

scam-package, shape.constrained.smooth.terms,  gam, s, plot.scam, summary.scam, scam.check, predict.scam, extrapolate.uni.scam
scam-package,shape.constrained.smooth.terms,gam,s,plot.scam,summary.scam,scam.check,predict.scam,extrapolate.uni.scam


实例----------Examples----------


##**********************************[#**********************************]
## Gaussian model ....[#高斯模型....]
   ## simulating data...[#模拟数据...]

set.seed(2)
n <- 200
x1 <- runif(n)*6-3
f1 &lt;- 3*exp(-x1^2) # unconstrained term[不受约束的术语]
f1 &lt;- (f1-min(f1))/(max(f1)-min(f1)) # function scaled to have range [0,1][功能缩放到范围[0,1]]
x2 <- runif(n)*4-1;
f2 &lt;- exp(4*x2)/(1+exp(4*x2)) # monotone increasing smooth[单调递增光滑]
f2 &lt;- (f2-min(f2))/(max(f2)-min(f2)) # function scaled to have range [0,1][功能缩放到范围[0,1]]
f <- f1+f2
y <- f+rnorm(n)*0.1
dat <- data.frame(x1=x1,x2=x2,y=y)
  ## fit model, results, and plot...[#拟合模型,结果和图。]
b <- scam(y~s(x1,k=15,bs="cr",m=2)+s(x2,k=25,bs="mpi",m=2),
    family=gaussian(link="identity"),data=dat)
print(b)
summary(b)
plot(b,pages=1)


##************************************[#************************************]
## Gaussian model ....[#高斯模型....]
   ## simulating data...[#模拟数据...]

set.seed(2)
n <- 200
x1 <- runif(n)*4-1;
f1 &lt;- exp(4*x1)/(1+exp(4*x1)) # monotone increasing smooth[单调递增光滑]
x2 <- runif(n)*3-1;
f2 &lt;- exp(-3*x2)/15  # monotone decreasing and convex smooth[单调递减和凸面光滑]
f <- f1+f2
y <- f+ rnorm(n)*0.2
dat <- data.frame(x1=x1,x2=x2,y=y)
  ## fit model, results, and plot...[#拟合模型,结果和图。]
b <- scam(y~ s(x1,k=25,bs="mpi",m=2)+s(x2,k=25,bs="mdcx",m=2),
    family=gaussian(link="identity"),data=dat)
print(b)
summary(b)
plot(b,pages=1,scale=0)

##***********************************[#***********************************]
## Not run: [#不运行:]
## using optim() for smoothing parameter selection...[#使用Optim()为平滑参数的选择...]
b1 <- scam(y~ s(x1,k=25,bs="mpi",m=2)+s(x2,k=25,bs="mdcx",m=2),
    family=gaussian(link="identity"),data=dat, optimizer="optim")
summary(b1)

b2 <- scam(y~ s(x1,k=25,bs="mpi",m=2)+s(x2,k=25,bs="mdcx",m=2),
    family=gaussian(link="identity"),data=dat, optimizer="optim",
    optim.method=c("BFGS","fd"))
summary(b2)

## using nlm()...[#NLM()...]
b3 <- scam(y~ s(x1,k=25,bs="mpi",m=2)+s(x2,k=25,bs="mdcx",m=2),
    family=gaussian(link="identity"),data=dat, optimizer="nlm")
summary(b3)

## End(Not run)[#(不执行)]


##************************************[#************************************]
## Not run: [#不运行:]
## Poisson model ....[#泊松模型....]
   ## simulating data...[#模拟数据...]
set.seed(2)
n <- 200
x1 <- runif(n)*6-3
f1 &lt;- 3*exp(-x1^2) # unconstrained term[不受约束的术语]
x2 <- runif(n)*4-1;
f2 &lt;- exp(4*x2)/(1+exp(4*x2)) # monotone increasing smooth[单调递增光滑]
f <- f1+f2
y <- rpois(n,exp(f))
dat <- data.frame(x1=x1,x2=x2,y=y)
  ## fit model, results, and plot...[#拟合模型,结果和图。]
b <- scam(y~s(x1,k=15,bs="cr",m=2)+s(x2,k=30,bs="mpi",m=2),
      family=poisson(link="log"),data=dat,optimizer="nlm.fd")
print(b)
summary(b)
plot(b,pages=1)
scam.check(b)

## Gamma model...[#Gamma模型...]
   ## simulating data...[#模拟数据...]
set.seed(3)
n <- 200
x1 <- runif(n)*6-3
f1 &lt;- 1.5*sin(1.5*x1) # unconstrained term[不受约束的术语]
x2 <- runif(n)*4-1;
f2 &lt;- 1.5/(1+exp(-10*(x2+0.75)))+1.5/(1+exp(-5*(x2-0.75))) # monotone increasing smooth[单调递增光滑]
x3 <- runif(n)*6-3;
f3 &lt;- 3*exp(-x3^2)  # unconstrained term[不受约束的术语]
f <- f1+f2+f3
y <- rgamma(n,shape=1,scale=exp(f))
dat <- data.frame(x1=x1,x2=x2,x3=x3,y=y)
   ## fit model, results, and plot...[#拟合模型,结果和图。]
b <- scam(y~s(x1,k=15,bs="ps",m=2)+s(x2,k=30,bs="mpi",m=2)+
            s(x3,k=15,bs="ps",m=2),family=Gamma(link="log"),
            data=dat,optimizer="nlm")
print(b)
summary(b)
par(mfrow=c(2,2))
plot(b)

## bivariate example...[#二元的例子...]
## simulating data...[#模拟数据...]
   set.seed(2)
   n <- 30
   x1 <- sort(runif(n)*4-1)
   x2 <- sort(runif(n))
   f1 <- matrix(0,n,n)
   for (i in 1:n) for (j in 1:n)
       { f1[i,j] <- -exp(4*x1[i])/(1+exp(4*x1[i]))+2*sin(pi*x2[j])}
   f <- as.vector(t(f1))
   y <- f+rnorm(length(f))*0.1
   x11 <-  matrix(0,n,n)
   x11[,1:n] <- x1
   x11 <- as.vector(t(x11))
   x22 <- rep(x2,n)
   dat <- list(x1=x11,x2=x22,y=y)
## fit model  and plot ...[#拟合模型和图...]
   b <- scam(y~s(x1,x2,k=c(10,10),bs=c("tesmd1","ps"),m=2),
            family=gaussian(link="identity"), data=dat,sp=NULL)
   summary(b)
   par(mfrow=c(2,2),mar=c(4,4,2,2))
   plot(b,se=TRUE)
   plot(b,pers=TRUE,theta = 30, phi = 40)
   plot(y,b$fitted.values,xlab="Simulated data",ylab="Fitted data")


## End(Not run)[#(不执行)]

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-5-14 14:48 , Processed in 0.157983 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表