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

R语言:t2()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 20:08:32 | 显示全部楼层 |阅读模式
t2(mgcv)
t2()所属R语言包:mgcv

                                        Define alternative tensor product smooths in GAM formulae
                                         张量积定义替代平滑的自由亚齐运动公式

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

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

Alternative to te for defining tensor product smooths in a gam formula. Results in a construction in which the penalties are  non-overlapping multiples of identity matrices (with some rows and columns zeroed).  The construction is analogous to Chong Gu's (2002) Smoothing Spline ANOVA, but using  low rank penalized regression spline marginals. The main advantage of this construction  is that it is useable with gamm4 from package gamm4.
替代te平滑gam公式定义张量积。结果在施工中的刑罚非重叠的身份矩阵的倍数(归零一些行和列)。施工崇谷(2002)平滑样条方差类似,但使用低等级处罚回归样条勉强。这种结构的主要优点是,它是用gamm4包gamm4可用。


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


              xt=NULL,id=NULL,sp=NULL,full=FALSE)



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

参数:...
a list of variables that are the covariates that this smooth is a function of.
顺利,这是一个功能的协变量的变量列表。


参数:k
the dimension(s) of the bases used to represent the smooth term. If not supplied then set to 5^d. If supplied as a single number then this  basis dimension is used for each basis. If supplied as an array then the elements are the dimensions of the component (marginal) bases of the tensor product. See choose.k for further information.
尺寸(S)的代表顺利长期使用的基地。如果不提供,则设置为5^d。如果提供作为一个单独的数字,然后以此为基础的维度用于每个基础。如果作为一个数组提供元素组件的尺寸(边际)张产品基地。看到choose.k为进一步的信息。


参数:bs
array (or single character string) specifying the type for each  marginal basis. "cr" for cubic regression spline; "cs" for cubic regression spline with shrinkage; "cc" for periodic/cyclic  cubic regression spline; "tp" for thin plate regression spline; "ts" for t.p.r.s. with extra shrinkage. See smooth.terms for details  and full list. User defined bases can  also be used here (see smooth.construct for an example). If only one  basis code is given then this is used for all bases.
指定边际的基础上为每个类型的数组(或单个字符串)。 "cr"三次回归样条;"cs"三次回归样条与收缩; "cc"定期/循环三次回归样条;"tp"薄板回归样条;"ts" TPRS额外的收缩。看到smooth.terms细节和完整列表。用户定义的基地,也可以在这里使用(见smooth.construct一个例子)。如果只有一个基础代码,那么这是用于所有基地。


参数:m
The order of the spline and its penalty (for smooth classes that use this) for each term.  If a single number is given  then it is used for all terms. A vector can be used to  supply a different m for each margin. For marginals that take vector m  (e.g. p.spline and Duchon.spline), then a list can be supplied, with a vector element for each margin. NA autoinitializes.  m is ignored by some bases (e.g. "cr").
样条,其罚款的顺序(每学期顺利使用此类)。如果给出一个号码,然后用于所有条款。一个向量可以用来提供不同的保证金为每个m。为勉强,向量m(如p.spline和Duchon.spline),然后列表可以提供保证金为每个向量元素。 NAautoinitializes。 m忽略一些基地(例如"cr")。


参数:d
array of marginal basis dimensions. For example if you want a smooth for 3 covariates  made up of a tensor product of a 2 dimensional t.p.r.s. basis and a 1-dimensional basis, then  set d=c(2,1). Incompatibilities between built in basis types and dimension will be resolved by resetting the basis type.
边际的基础上尺寸的阵列。例如,如果你想顺利为3协变量张量积的2维TPRS基础和一维的基础上,然后设置d=c(2,1)。将解决复位的基础类型,基础类型和尺寸的建立之间的不兼容性。


参数:by
a numeric or factor variable of the same dimension as each covariate.  In the numeric vector case the elements multiply the smooth evaluated at the corresponding  covariate values (a "varying coefficient model" results).  In the factor case causes a replicate of the smooth to be produced for each factor level. See gam.models for further details. May also be a matrix  if covariates are matrices: in this case implements linear functional of a smooth  (see gam.models and linear.functional.terms for details).
一个相同尺寸为每个协变量的数值或因素。在数字向量的情况下,元素乘以相应的协变量的值(一个变系数模型的结果)评估顺利。在因素的情况下会导致复制的每个因子水平的平稳。看到gam.models作进一步的细节。也可能是一个矩阵,如果协变量是矩阵:在这种情况下,实现线性平滑功能(见gam.models和linear.functional.terms详情)。


参数:xt
Either a single object, providing any extra information to be passed to each marginal basis constructor, or a list of such objects, one for each marginal basis.  
无论是一个单一的对象,要传递给每一个边际的基础上构造,这样的对象,为每个边际的基础上提供任何额外的信息。


参数:id
A label or integer identifying this term in order to link its smoothing parameters to others of the same type. If two or more smooth terms have the same  id then they will have the same smoothing paramsters, and, by default, the same bases (first occurance defines basis type, but data from all terms  used in basis construction).
整数识别标签或以其他相同类型的连接平滑参数这个词。如果两个或两个以上的平稳术语具有相同的id然后,他们将有相同平滑paramsters,并在默认情况下,同一基地(第一occurance定义的基础类型,但在基础建设中使用的所有条款中的数据)。


参数:sp
any supplied smoothing parameters for this term. Must be an array of the same length as the number of penalties for this smooth. Positive or zero elements are taken as fixed  smoothing parameters. Negative elements signal auto-initialization. Over-rides values supplied in  sp argument to gam. Ignored by gamm.
任何提供本学期的平滑参数。必须在这平稳的处罚相同长度的数组。正数或零的元素都采取固定平滑参数。消极因素信号自动初始化。提供过游戏机值spgam参数。 gamm忽略。


参数:full
If TRUE then there is a separate penalty for each combination of null space column  and range space. This gives strict invariance. If FALSE each combination of null space and  range space generates one penalty, but the coulmns of each null space basis are treated as one group.  The latter is more parsimonious, but does mean that invariance is only  achieved by an arbitrary rescaling of null space basis vectors.
如果TRUE然后有一个空的空间列和空间范围的每个组合单独的罚款。这提供了严格的不变性。如果FALSE空的空间和范围空间的每个组合产生一个点球,但作为一组处理每个空的空间基础coulmns。后者则是更简洁,但并不意味着不变性只实现零空间基向量的任意缩放功能。


Details

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

Smooths of several covariates can be constructed from tensor products of the bases used to represent smooths of one (or sometimes more) of the covariates. To do this "marginal" bases are produced with associated model matrices and penalty matrices. These are reparameterized so that the  penalty is zero everywhere, except for some elements on the leading diagonal, which all have the same non-zero value.  This reparameterization results in an unpenalized and a penalized subset of parameters, for each marginal basis (see  e.g. appendix of Wood, 2004, for details).
平滑的几个变项,可以用来代表张基地产品构造平滑的变项之一(或有时)。做这个“边缘”的基地生产相关的模型矩阵和罚款矩阵。这些被重新参数化,使刑罚到处是零,除了一些领导对角线的元素,它们都具有相同的非零值。此重新参数化结果在unpenalized和处罚的参数子集,每个边际的基础上(见,2004年木材细节,如附录)。

The re-parameterized marginal bases are then combined to produce a basis for a single function of all the covariates  (dimension given by the product of the dimensions of the marginal bases). In this set up there are multiple  penalty matrices — all zero, but for a mixture of a constant and zeros on the leading diagonal. No two penalties have  a non-zero entry in the same place.
然后,重新参数化的边际基地相结合,以生产为单一功能的所有协变量(维度由边际基地的尺寸的产品)的基础。在此设置有多个处罚矩阵 - 所有零,但对于一个常数和零上领先的对角线的混合物。没有两个点球有一个非零项在同一个地方。

Essentially the basis for the tensor product can be thought of as being constructed from a set of products of the penalized (range) or unpenalized (null) space bases of the marginal smooths  (see Gu, 2002, section 2.4).  To construct one of the set, choose either the  null space or the range space from each marginal, and from these bases construct a product basis. The result is subject to a ridge  penalty (unless it happens to be a product entirely of marginal null spaces). The whole basis for the smooth is constructed from  all the different product bases that can be constructed in this way. The separately penalized components of the smooth basis each have an interpretation in terms of the ANOVA - decomposition of the term.  See pen.edf for some further information.
本质上的张量积的基础上,可以被认为是作为正在构建一套从产品的处罚(范围)或边缘平滑(见顾,2002年,第2.4节)(空)unpenalized空间基地。兴建集之一,选择“空的空间,从每个边缘或范围空间,并从这些基地建立一个产品的基础上。结果是受到脊罚款(除非发生完全是一个产品的边际空空间)。整个基础的顺利建成,从各种不同的产品,可以以这种方式建造的基地。每个组件的平稳的基础上,分别处罚条款解释的方差 - 长期分解。看到pen.edf一些进一步的信息。

Note that there are two ways to construct the product. When full=FALSE then the null space bases are treated as a whole in each product, but when full=TRUE each null space column is treated as a separate null space. The latter results in more penalties, but is the strict  analog of the SS-ANOVA approach.
请注意,有两种方式来构建产品。当full=FALSE空空间基地视为一个整体在每一个产品,但full=TRUE每个空的空间列处理作为一个单独的零空间。在更多的处罚,后者的结果,但严格的SS-方差方法模拟。

Tensor product smooths are especially useful for representing functions of covariates measured in different units,  although they are typically not quite as nicely behaved as t.p.r.s. smooths for well scaled covariates.
张量积平滑代表在不同的单位测量的协变量的功能是特别有用的,虽然他们通常不作为相当很好地表现为TPRS平滑的以及缩放的协变量。

Note also that GAMs constructed from lower rank tensor product smooths are nested within GAMs constructed from higher rank tensor product smooths if the same marginal bases are used in both cases (the marginal smooths themselves are just special cases of tensor product smooths.)
也请注意,嵌套内排名较高的张量积构造GAMS GAMS从较低级的张量积构造平滑,平滑,如果相同的边际基地在这两种情况下使用(边缘平滑本身只是特殊情况下平滑张量积。)

Note that tensor product smooths should not be centred (have identifiability constraints imposed)  if any marginals would not need centering. The constructor for tensor product smooths  ensures that this happens.
注意不应集中辨识约束施加任何勉强不会需要为中心的张量积平滑。张量积构造平滑,确保这种情况的发生。

The function does not evaluate the variable arguments.
该功能不评估的可变参数。


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

A class t2.smooth.spec object defining a tensor product smooth to be turned into a basis and penalties by the smooth.construct.tensor.smooth.spec function.
A类t2.smooth.spec对象定义张量积顺利打开smooth.construct.tensor.smooth.spec函数将依据和处罚。

The returned object contains the following items:
返回的对象包含下列项目:


参数:margin
A list of smooth.spec objects of the type returned by s,  defining the basis from which the tensor product smooth is constructed.
返回smooth.specs类型的对象名单,定义张量积顺利被构建的基础。


参数:term
An array of text strings giving the names of the covariates that  the term is a function of.
文本字符串数组协变量的名称,这个词是一个功能。


参数:by
is the name of any by variable as text ("NA" for none).
是任何by("NA"无)作为文本的变量的名称。


参数:fx
logical array with element for each penalty of the term (tensor product smooths have multiple penalties). TRUE if the penalty is to  be ignored, FALSE, otherwise.  
每个术语的刑罚与元素的逻辑阵列(张产品平滑有多个处罚)。 TRUE如果是不容忽视的罚款,FALSE,否则。


参数:label
A suitable text label for this smooth term.
这光滑的长期的一个合适的文本标签。


参数:dim
The dimension of the smoother - i.e. the number of covariates that it is a function of.
平滑的维度 - 即协变量的数量,它是一个功能。


参数:mp
TRUE is multiple penalties are to be used (default).
TRUE是多重的刑罚是要使用(默认)。


参数:np
TRUE to re-parameterize 1-D marginal smooths in terms of function values (defualt).
TRUE重新参数化的1-D边缘平滑函数值(defualt)。


参数:id
the id argument supplied to te.
id参数提供te的。


参数:sp
the sp argument supplied to te.
sp参数提供te的。


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


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



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


generalized additive models. J. Amer. Statist. Ass. 99:673-686.

*not* implemented by t2 terms, are discussed in:




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

te s,gam,gamm,
tes,gam,gamm


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



# following shows how tensor product deals nicely with [以下显示如何处理张量积很好地与]
# badly scaled covariates (range of x 5% of range of z )[严重缩放协变量(×5%z范围内的范围)]
test1<-function(x,z,sx=0.3,sz=0.4)  
{ x<-x*20
  (pi**sx*sz)*(1.2*exp(-(x-0.2)^2/sx^2-(z-0.3)^2/sz^2)+
  0.8*exp(-(x-0.7)^2/sx^2-(z-0.8)^2/sz^2))
}
n<-500
old.par<-par(mfrow=c(2,2))
x<-runif(n)/20;z<-runif(n);
xs<-seq(0,1,length=30)/20;zs<-seq(0,1,length=30)
pr<-data.frame(x=rep(xs,30),z=rep(zs,rep(30,30)))
truth<-matrix(test1(pr$x,pr$z),30,30)
f <- test1(x,z)
y <- f + rnorm(n)*0.2
b1<-gam(y~s(x,z))
persp(xs,zs,truth);title("truth")
vis.gam(b1);title("t.p.r.s")
b2<-gam(y~t2(x,z))
vis.gam(b2);title("tensor product")
b3<-gam(y~t2(x,z,bs=c("tp","tp")))
vis.gam(b3);title("tensor product")
par(old.par)

test2<-function(u,v,w,sv=0.3,sw=0.4)  
{ ((pi**sv*sw)*(1.2*exp(-(v-0.2)^2/sv^2-(w-0.3)^2/sw^2)+
  0.8*exp(-(v-0.7)^2/sv^2-(w-0.8)^2/sw^2)))*(u-0.5)^2*20
}
n <- 500
v <- runif(n);w<-runif(n);u<-runif(n)
f <- test2(u,v,w)
y <- f + rnorm(n)*0.2

## tensor product of 2D Duchon spline and 1D cr spline[#2D Duchon样条和1D CR样条张量积]
m <- list(c(1,.5),0)
b <- gam(y~t2(v,w,u,k=c(30,5),d=c(2,1),bs=c("ds","cr"),m=m))

## look at the edf per penalty. "rr" denotes interaction term [#看看EDF每罚款。 “RR”表示交互作用项]
## (range space range space). "rn" is interaction of null space[#(范围空间范围空间)。 “RN”是空的空间相互作用]
## for u with range space for v,w...[#为üV,W的空间范围...]
pen.edf(b)

## plot results...[#图的结果......]
op <- par(mfrow=c(2,2))
vis.gam(b,cond=list(u=0),color="heat",zlim=c(-0.2,3.5))
vis.gam(b,cond=list(u=.33),color="heat",zlim=c(-0.2,3.5))
vis.gam(b,cond=list(u=.67),color="heat",zlim=c(-0.2,3.5))
vis.gam(b,cond=list(u=1),color="heat",zlim=c(-0.2,3.5))
par(op)

b <- gam(y~t2(v,w,u,k=c(30,5),d=c(2,1),bs=c("tp","cr"),full=TRUE),
         method="ML")
## more penalties now. numbers in labels like "r1" indicate which [#更多的惩罚现在。像“R1”标签的数字表明这]
## basis function of a null space is involved in the term. [#一个空的空间基础功能的长期参与。]
pen.edf(b)


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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-24 15:28 , Processed in 0.027495 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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