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

R语言:smooth.construct.ad.smooth.spec()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 19:24:56 | 显示全部楼层 |阅读模式
smooth.construct.ad.smooth.spec(mgcv)
smooth.construct.ad.smooth.spec()所属R语言包:mgcv

                                        Adaptive smooths in GAMs
                                         自适应平滑,在GAMS

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

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

gam can use adaptive smooths of one or two variables, specified  via terms like s(...,bs="ad",...). (gamm can not use such terms — check out  package AdaptFit if this is a problem.) The basis for such a term is a (tensor product of)  p-spline(s) or cubic regression spline(s). Discrete P-spline type penalties are applied directly to the coefficients  of the basis, but the penalties themselves have a basis representation, allowing the strength of the penalty to vary with the covariates. The coefficients of the penalty basis are the smoothing parameters.
gam可以使用一个或两个变量,通过像s(...,bs="ad",...)指定自适应平滑。 (gamm不能使用等方面 - 检查包AdaptFit如果这是一个问题。)对于这样一个长期的基础是(张产品)P-样条曲线(S)或三次回归样条曲线(S)。直接应用于离散P-样条型处罚的基础上的系数,但刑罚本身有基础的代表性,使刑罚的强度随协变量。处罚的依据系数是平滑参数。

When invoking an adaptive smoother the k argument specifies the dimension of the smoothing basis,  while the m argument specifies the dimension of the penalty basis. For an adaptive smooth of two  variables k is taken as the dimension of both marginal bases: different marginal basis dimensions can be  specified by making k a two element vector. Similarly, in the two dimensional case m is the  dimension of both marginal bases for the penalties, unless it is a two element vector, which specifies different basis dimensions for each marginal (If the penalty basis is based on a thin plate spline then m specifies its dimension directly).
当调用一个自适应平滑k参数指定的维平滑的基础上,而m参数指定的维处罚的依据。对于两个变量的自适应平滑k被视为双方的边际基地的维度:不同的边际的基础上尺寸可以使k两个元素的向量中指定。同样,在二维情况m是两个处罚边际基地的尺寸,除非它是一个两个元素的向量,它指定为每个边缘(如果处罚的依据是基于对薄板的基础不同尺寸的样条,然后m指定其尺寸直接)。

By default, P-splines are used for the smoothing and penalty bases, but this can be modified by supplying a list as argument xt with a character vector xt$bs specifying the smoothing basis type.  Only "ps", "cp", "cc" and "cr" may be used for the smoothing basis. The penalty basis is  always a B-spline, or a cyclic B-spline for cyclic bases.
默认情况下,用于平滑和罚款基地的P-样条线,但可以通过提供一个列表作为参数修改xt与特征向量xt$bs指定平滑的基础类型。只有"ps","cp","cc"和"cr"可用于平滑基础。处罚的依据始终是一个B样条,或一个循环的B样条循环基地。

The total number of smoothing parameters to be estimated for the term will be the dimension of the penalty basis.  Bear in mind that adaptive smoothing places quite severe demands on the data. For example, setting m=10 for a  univariate smooth of 200 data is rather like estimating 10 smoothing parameters, each from a data series of length 20. The problem is particularly serious for smooths of 2 variables, where the number of smoothing parameters required to  get reasonable flexibility in the penalty can grow rather fast, but it often requires a very large smoothing basis  dimension to make good use of this flexibility. In short, adaptive smooths should be used sparingly and with care.
长期估计平滑参数的总数将是维处罚的依据。牢记自适应平滑,置于对数据的需求相当严重。例如,设置m=10,而不是像估计从一个数据长度为20系列10平滑参数,每个为200个数据的单因素顺利。问题是特别严重的2个变量的平滑,需要得到合理的灵活性,最高刑罚可增长较快的平滑参数的数目,但它往往需要一个非常大的平滑的基础上尺寸,利用好这种灵活性。总之,自适应平滑,应谨慎使用和护理。

In practice it is often as effective to simply transform the smoothing covariate as it is to use an adaptive smooth.
在实践中,往往是有效的,简单地变换平滑协,因为它是使用一个自适应的平稳。


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


## S3 method for class 'ad.smooth.spec'
smooth.construct(object, data, knots)



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

参数:object
a smooth specification object, usually generated by a term s(...,bs="ad",...)
平稳规范的对象,通常是由一个长期s(...,bs="ad",...)生成的


参数:data
a list containing just the data (including any by variable) required by this term,  with names corresponding to object$term (and object$by). The by variable  is the last element.  
一个列表,其中包含的数据(包括任何by变)这个词所要求的名称object$term,(object$by)。 by变量是最后一个元素。


参数:knots
a list containing any knots supplied for basis setup — in same order and with same names as data.  Can be NULL
一个列表,其中包含基础设置提供任何节 - 在同一顺序相同的名称为data。可以NULL


Details

详情----------Details----------

The constructor is not normally called directly, but is rather used internally by gam.  To use for basis setup it is recommended to use smooth.construct2.  
构造函数通常不直接调用,但内部而不是使用gam。用于基础设置,建议使用smooth.construct2。

This class can not be used as a marginal basis in a tensor product smooth, nor by gamm.
这个类不能被用来作为一个边际的基础上,在张量积顺利,也不是由gamm。


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

An object of class "pspline.smooth" in the 1D case or "tensor.smooth" in the 2D case.
一个类的对象"pspline.smooth"在1D的情况下或"tensor.smooth"在2D情况下。


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


Simon N. Wood <a href="mailto:simon.wood@r-project.org">simon.wood@r-project.org</a>



举例----------Examples----------


## Comparison using an example taken from AdaptFit[#比较使用从AdaptFit一个例子]
## library(AdaptFit)[#库(AdaptFit)]
set.seed(0)
x <- 1:1000/1000
mu <- exp(-400*(x-.6)^2)+5*exp(-500*(x-.75)^2)/3+2*exp(-500*(x-.9)^2)
y <- mu+0.5*rnorm(1000)

##fit with default knots[#适合用默认的结]
## y.fit &lt;- asp(y~f(x))[#y.fit < -  ASP(Y&#12316;F(X))]

par(mfrow=c(2,2))
## plot(y.fit,main=round(cor(fitted(y.fit),mu),digits=4))[图(主要=轮y.fit(COR(装(y.fit),亩),数字= 4)#)]
## lines(x,mu,col=2)[#线(X,亩,COL = 2)]

b &lt;- gam(y~s(x,bs="ad",k=40,m=5)) ## adaptive[#自适应]
plot(b,shade=TRUE,main=round(cor(fitted(b),mu),digits=4))
lines(x,mu-mean(mu),col=2)

b &lt;- gam(y~s(x,k=40))             ## non-adaptive[#非自适应]
plot(b,shade=TRUE,main=round(cor(fitted(b),mu),digits=4))
lines(x,mu-mean(mu),col=2)

b <- gam(y~s(x,bs="ad",k=40,m=5,xt=list(bs="cr")))
plot(b,shade=TRUE,main=round(cor(fitted(b),mu),digits=4))
lines(x,mu-mean(mu),col=2)

## A 2D example....[#二维的例子....]
par(mfrow=c(2,2),mar=c(1,1,1,1))
x <- seq(-.5, 1.5, length= 60)
z <- x
f3 <- function(x,z,k=15) { r<-sqrt(x^2+z^2);f<-exp(-r^2*k);f}  
f <- outer(x, z, f3)
op <- par(bg = "white")

## Plot truth....[#剧情真相....]
persp(x,z,f,theta=30,phi=30,col="lightblue",ticktype="detailed")

n <- 2000
x <- runif(n)*2-.5
z <- runif(n)*2-.5
f <- f3(x,z)
y <- f + rnorm(n)*.1

## Try tprs for comparison...[#尝试比较TPRS ...]
b0 <- gam(y~s(x,z,k=150))
vis.gam(b0,theta=30,phi=30,ticktype="detailed")

## Tensor product with non-adaptive version of adaptive penalty[#张量积非自适应自适应罚款的版本]
b1 <- gam(y~s(x,z,bs="ad",k=15,m=1),gamma=1.4)
vis.gam(b1,theta=30,phi=30,ticktype="detailed")

## Now adaptive...[#现在自适应...]
b <- gam(y~s(x,z,bs="ad",k=15,m=3),gamma=1.4)
vis.gam(b,theta=30,phi=30,ticktype="detailed")
cor(fitted(b0),f);cor(fitted(b),f)




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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-24 14:00 , Processed in 0.028806 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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