smooth.construct.ps.smooth.spec(mgcv)
smooth.construct.ps.smooth.spec()所属R语言包:mgcv
P-splines in GAMs
在GAMS的P-样条
译者:生物统计家园网 机器人LoveR
描述----------Description----------
gam can use univariate P-splines as proposed by Eilers and Marx (1996), specified via terms like s(x,bs="ps"). These terms use B-spline bases penalized by discrete penalties applied directly to the basis coefficients. Cyclic P-splines are specified by model terms like s(x,bs="cp",...). These bases can be used in tensor product smooths (see te).
gam可以使用单因素的P-样条艾勒斯和马克思(1996)通过像s(x,bs="ps")条款“规定,建议。这些条款使用B样条的基地由直接应用的基础系数的离散惩罚的惩罚。像s(x,bs="cp",...)模型计算循环的P-样条指定。这些基地可用于平滑张量积(见te)。
The advantage of P-splines is the flexible way that penalty and basis order can be mixed. This often provides a useful way of "taming" an otherwise poorly behave smooth. However, in regular use, splines with derivative based penalties (e.g. "tp" or "cr" bases) tend to result in slightly better MSE performance, presumably because the good approximation theoretic properties of splines are rather closely connected to the use of derivative penalties.
的P-样条的优点是灵活的方式可以混合使用,罚款和基础秩序。这往往提供了一个有用的方法“驯服”,否则不佳表现平稳。然而,在正常使用,样条衍生工具(例如"tp"或"cr"基地)的处罚往往导致的MSE性能稍微好一点,大概是因为良好的逼近样条曲线的理论性质相当紧密相连的使用衍生工具的处罚。
用法----------Usage----------
## S3 method for class 'ps.smooth.spec'
smooth.construct(object, data, knots)
## S3 method for class 'cp.smooth.spec'
smooth.construct(object, data, knots)
参数----------Arguments----------
参数:object
a smooth specification object, usually generated by a term s(x,bs="ps",...) or s(x,bs="cp",...)
平稳规范的对象,通常由任期s(x,bs="ps",...)或s(x,bs="cp",...)产生
参数: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. See details for further information.
一个列表,其中包含基础设置提供任何节 - 在同一顺序相同的名称为data。可以NULL。进一步信息,请参阅。
Details
详情----------Details----------
A smooth term of the form s(x,bs="ps",m=c(2,3)) specifies a 2nd order P-spline basis (cubic spline), with a third order difference penalty (0th order is a ridge penalty) on the coefficients. If m is a single number then it is taken as the basis order and penalty order. The default is the "cubic spline like" m=c(2,2).
一个平稳长期的形式s(x,bs="ps",m=c(2,3))指定一个2阶的P-样条的基础上(三次样条),与第三阶差分惩罚系数(0号顺序是一垄罚款)。 m如果是单数,那么它为基础的秩序和罚款秩序。默认是“像”的三次样条m=c(2,2)。
The default basis dimension, k, is the larger of 10 and m[1]+1 for a "ps" terms and the larger of 10 and m[1] for a "cp" term. m[1]+1 and m[1] are the lower limits on basis dimension for the two types.
默认尺寸的基础上,k,10m[1]+1"ps"和10m[1]"cp"一词。 m[1]+1和m[1]维度的基础上,下两种类型的限制。
If knots are supplied, then the number of knots should be one more than the basis dimension (i.e. k+1) for a "cp"smooth. For the "ps" basis the number of supplied knots should be k + m[1] + 2, and the range of the middle k-m[1] knots should include all the covariate values. See example.
如果提供了海里,然后结的数量应该是一个比更多的基础层面(即k+1)"cp"顺利。为"ps"的基础上提供的节的数量应该是k + m[1] + 2,中间k-m[1]海里的范围应包括所有协变量的值。见的例子。
Alternatively, for both types of smooth, 2 knots can be supplied, denoting the lower and upper limits between which the spline can be evaluated (Don't make this range too wide, however, or you can end up with no information about some basis coefficients, because the corresponding basis functions have a span that includes no data!). Note that P-splines don't make much sense with uneven knot spacing.
此外,为顺利两种类型,2节可以提供,表示上下之间可以计算的样条的限制(不要让这个范围太广,然而,你可以结束没有一些基础的信息系数,因为相应的基础功能有一个大跨度,包括没有数据!)。请注意,不结间距不均的P-样条的意义不大。
值----------Value----------
An object of class "ps.smooth" or "cp.smooth". See smooth.construct, for the elements that this object will contain.
一个对象类"ps.smooth"或"cp.smooth"。看到smooth.construct,这个对象将包含的元素。
作者(S)----------Author(s)----------
Simon N. Wood <a href="mailto:simon.wood@r-project.org">simon.wood@r-project.org</a>
参考文献----------References----------
Statistical Science, 11(2):89-121
参见----------See Also----------
cSplineDes
cSplineDes
举例----------Examples----------
## see ?gam[#看到了什么?GAM]
## cyclic example ...[#循环的例子...]
set.seed(6)
x <- sort(runif(200)*10)
z <- runif(200)
f <- sin(x*2*pi/10)+.5
y <- rpois(exp(f),exp(f))
## finished simulating data, now fit model...[#完成模拟数据,现在合适的模型...]
b <- gam(y ~ s(x,bs="cp") + s(z,bs="ps"),family=poisson)
## example with supplied knot ranges for x and z (can do just one)[#提供的X和Z结范围的例子(可以只做一)]
b <- gam(y ~ s(x,bs="cp") + s(z,bs="ps"),family=poisson,
knots=list(x=c(0,10),z=c(0,1)))
## example with supplied knots...[#例如提供结...]
bk <- gam(y ~ s(x,bs="cp",k=12) + s(z,bs="ps",k=13),family=poisson,
knots=list(x=seq(0,10,length=13),z=(-3):13/10))
## plot results...[#图的结果......]
par(mfrow=c(2,2))
plot(b,select=1,shade=TRUE);lines(x,f-mean(f),col=2)
plot(b,select=2,shade=TRUE);lines(z,0*z,col=2)
plot(bk,select=1,shade=TRUE);lines(x,f-mean(f),col=2)
plot(bk,select=2,shade=TRUE);lines(z,0*z,col=2)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|