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

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

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

                                        Define tensor product smooths in GAM formulae
                                         定义张量的产品平滑自由亚齐运动公式

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

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

Function used in definition of tensor product smooth terms within gam model formulae. The function does not evaluate a smooth - it exists purely to help set up a model using tensor product  based smooths. Designed to construct tensor products from any marginal smooths with a basis-penalty representation (with the restriction that each  marginal smooth must have only one penalty).
张量积gam模型公式内顺利条款的定义,使用的功能。该函数不评估顺利 - 它的存在纯粹是为了帮助建立一个模型,采用基于平滑的张量积。从设计到建造任何边际张产品的平滑与罚款的基础上代表(限制每个边缘光滑,必须有一个点球)。


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


              mp=TRUE,np=TRUE,xt=NULL,id=NULL,sp=NULL)



参数----------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详情)。


参数:fx
indicates whether the term is a fixed d.f. regression spline (TRUE) or a penalized regression spline (FALSE).
指示是否一词是一个固定的D.F.回归样条(TRUE)或处罚的回归样条(FALSE)。


参数:mp
TRUE to use multiple penalties for the smooth. FALSE to use only  a single penalty: single penalties are not recommended - they tend to allow only rather  wiggly models.
TRUE使用的顺利多个处罚。 FALSE只使用一个单一的罚款:不建议单处罚 - 他们往往允许只,而蠕动模型。


参数:np
TRUE to use the "normal parameterization" for a tensor product smooth. This represents any 1-d marginal smooths via parameters that are function values at "knots", spread evenly through the data. The parameterization makes the penalties easily interpretable, however it can reduce numerical stability in some cases.
TRUE使用张量的产品顺利的正常参数“。这代表任何1-D边缘平滑,通过在“节”函数值的参数,通过数据均匀传播。参数化使得刑罚容易解释,但它可以减少在某些情况下的数值稳定性。


参数: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忽略。


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, and these are then combined in the manner described in tensor.prod.model.matrix and tensor.prod.penalties, to produce  a single model matrix for the smooth, but multiple penalties (one for each marginal basis). The basis dimension  of the whole smooth is the product of the basis dimensions of the marginal smooths.
平滑的几个变项,可以用来代表张基地产品构造平滑的变项之一(或有时)。为了做这个“边缘”基地生产相关的模型矩阵和罚款矩阵,和这些然后tensor.prod.model.matrix和tensor.prod.penalties,产生一个平稳的单一模式矩阵,描述的方式相结合的但多个(每个边际的基础之一)处罚。整个平稳的基础层面是边缘平滑的基础上尺寸的产品。

An option for operating with a single penalty (The Kronecker product of the marginal penalties) is provided, but  it is rarely of practical use: the penalty is typically so rank deficient that even the smoothest resulting model  will have rather high estimated degrees of freedom.
提供一个单一的罚款(Kronecker积的边际处罚)经营的一个选项,但它很少是实际使用的处罚通常秩亏,甚至由此产生的流畅的模型,将有相当高的估计的自由度。

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从较低级的张量积构造平滑,平滑,如果相同的边际基地在这两种情况下使用(边缘平滑本身只是特殊情况下平滑张量积。)

The "normal parameterization" (np=TRUE) re-parameterizes the marginal smooths of a tensor product smooth so that the parameters are function values at a set of points spread evenly through the range of values of the covariate of the smooth. This means that the penalty of the tensor product associated with any particular covariate direction can be interpreted as the penalty of the appropriate marginal smooth applied in that direction and averaged over the smooth. Currently this is only done for marginals of a single variable. This parameterization can reduce numerical stability  when used with marginal smooths other than "cc", "cr" and "cs": if this causes problems, set np=FALSE.
“正常参数(np=TRUE)重新参数化的边际平滑张量的产品,所以顺利的参数是函数值在一组点均匀扩散范围值的协的顺利通过。这意味着协与任何特定的方向张量积的罚款,可以解释为适用于这个方向适当的边际顺利的罚款,并在平滑的平均。目前这仅仅是一个单变量的边缘人。边缘平滑以外使用时,此参数可以减少数值稳定性"cc","cr"和"cs":如果这个问题的原因,设置np=FALSE。

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 tensor.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类tensor.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>



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

generalized additive mixed models. Biometrics 62(4):1025-1036


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

s,gam,gamm,
s,gam,gamm


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



# following shows how tensor pruduct deals nicely with [张项目Service items如何很好地处理与后显示]
# 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~te(x,z))
vis.gam(b2);title("tensor product")
b3<-gam(y~te(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 &lt;- list(c(1,.5),rep(0,0)) ## example of list form of m[#m的列表形式例如]
b <- gam(y~te(v,w,u,k=c(30,5),d=c(2,1),bs=c("ds","cr"),m=m))
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)


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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-23 09:25 , Processed in 0.035879 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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