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

R语言 mgcv包 gam.models()函数中文帮助文档(中英文对照)

  [复制链接]
发表于 2012-9-23 10:24:58 | 显示全部楼层 |阅读模式
gam.models(mgcv)
gam.models()所属R语言包:mgcv

                                        Specifying generalized additive models
                                         指定广义加性模型

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

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

This page is intended to provide some more information on how to specify GAMs. A GAM is a GLM in which the linear predictor depends,  in part, on a sum of smooth functions of predictors and (possibly) linear  functionals of smooth functions of (possibly dummy) predictors.
本页面的目的是提供一些更多的信息如何指定GAMS。一个GAM是一个GLM中的线性预测,在某种程度上,取决于上一笔的预测和平滑的功能(可能)线性泛函的光滑函数(可能是假的)的预测。

Specifically let y_i denote an independent random variable  with mean mu_i and an exponential family distribution, or failing  that a known mean variance relationship suitable for use of quasi-likelihood methods.  Then the the linear predictor of a GAM has a structure something like
特别是让y_i表示一个独立的随机变量,平均mu_i指数族分布,或没有一个已知的平均方差的关系,适合用于拟似然方法。然后,一个GAM的线性预测,具有这样的结构类似

where g is a known smooth monotonic "link" function, X_i b  is the parametric part of the linear predictor, the x_j are predictor variables, the f_j are smooth functions and L_i is some linear functional of  f_3. There may of course be multiple linear functional terms, or none.
g是一个已知的光滑单调的链接功能,X_i b的是参数的线性预测,x_j预测变量,f_j是光滑函数。和L_i是一些线性泛函的f_3的。当然是有可能的多元线性功能上来讲,还是没有。

The key idea here is that the dependence of the response on the predictors can be represented as a parametric sub-model plus the sum of some (functionals of) smooth functions of one or more of the predictor variables. Thus the model is quite flexible relative to strictly parametric linear or generalized linear models, but still has much more structure than the completely general model that says that the response is just some smooth function of all the covariates.
这里的关键思想是,可以被表示为一个参数的子模型加上一些(泛函)的光滑函数的一个或多个的预测变量的总和上的响应的预测因子的依赖性。因此,相对于严格的参数线性或广义线性模型,该模型是相当灵活的,但仍然有更多的结构比一般的模型,说的反应仅仅是一些平滑功能,所有的协变量。

Note one important point. In order for the model to be identifiable the smooth functions usually have to be constrained to have zero mean (usually taken over the set of covariate values). The constraint is needed if the term involving the  smooth includes a constant function in its span. gam always applies such constraints  unless there is a by variable present, in which case an assessment is made of whether  the constraint is needed or not (see below).
请注意很重要的一点。为了为模型识别的光滑函数通常被约束到具有零均值(通常接管协变量值的组)。如果这个词涉及的顺利包括一个恒定的功能在其跨度的约束是必要的。 gam总是适用于这样的约束,除非有一个by变量目前,在这种情况下,作出评估,约束是否需要或不(见下文)。

The following sections discuss specifying model structures for gam.  Specification of the distribution and link function is done using the family  argument to gam and works in the same way as for glm.  This page therefore concentrates on the model formula for gam.
以下各节讨论指定模型结构gam的。使用family gam和作品以同样的方式为glm参数的分配和链接功能规格。因此本页面集中模型公式为gam。


与简约流畅条款的型号----------Models with simple smooth terms----------

Consider the example model.
考虑示例模型。

where the response variables y_i has expectation mu_i and g is a link function.
响应变量y_i有期望mu_i和g是一个链接的功能。

The gam formula for this would be <br> y ~ x1 + x2 + s(x3) + s(x4,x5). <br> This would use the default basis for the smooths (a thin plate regression spline basis for each), with automatic selection of the effective degrees of freedom for both smooths. The dimension of the smoothing basis is given a default value as well (the dimension of the basis sets an upper limit on the maximum possible degrees of freedom for the basis - the limit is typically one less than basis dimension). Full details of how to control smooths are given in s and te, and further discussion of basis dimension choice can be found in choose.k.  For the moment suppose that we would like to change the basis of the first smooth to a cubic regression spline basis with a dimension of 20, while fixing the second term at 25 degrees of freedom. The appropriate formula would be:<br> y ~ x1 + x2 + s(x3,bs="cr",k=20) + s(x4,x5,k=26,fx=TRUE).
gam公式这将是<BR>的y ~ x1 + x2 + s(x3) + s(x4,x5)。 <br>这将使用默认的基础上的平滑(薄板为每个回归样条基),与自动选择的有效自由度为平滑。的平滑基础的尺寸给定的一个默认值,以及(的尺寸的基础上设置一个上限的最大可能的自由度为依据 - 限制通常是一个小于基准尺寸)。如何控制平滑的全部细节s和te,并进一步讨论的基础尺寸的选择,可以发现在choose.k。对于目前假设我们想改变的基础上的第一个光滑的三次回归样条基,尺寸为20的第二个任期,而固定在25度的自由。相应的计算公式是:<BR>y ~ x1 + x2 + s(x3,bs="cr",k=20) + s(x4,x5,k=26,fx=TRUE)。

The above assumes that x_4 and x_5 are naturally on  similar scales (e.g. they might be co-ordinates), so that isotropic smoothing  is appropriate. If this assumption is false then tensor product smoothing might be  better (see te). <br> y ~ x1 + x2 + s(x3) + te(x4,x5)<br> would generate a tensor product smooth of x_4 and x_5.  By default this smooth would have basis dimension 25 and use cubic regression spline marginals.  Varying the defaults is easy. For example<br> y ~ x1 + x2 + s(x3) + te(x4,x5,bs=c("cr","ps"),k=c(6,7))<br> specifies that the tensor product should use a rank 6 cubic regression spline marginal and a rank 7 P-spline marginal to create a smooth with basis dimension 42.
上述假设x_4和x_5自然类似的尺度(例如,它们可能是坐标),因此,各向同性的平滑是适当的。如果这个假设是错误的,那么张量积平滑可能会更好(见te“)。参考:y ~ x1 + x2 + s(x3) + te(x4,x5):<BR>会产生一个张量积顺利x_4和x_5。默认情况下,此平滑有依据尺寸25和使用三次回归样条边缘人。不同的默认值是很容易的。例如<BR>:y ~ x1 + x2 + s(x3) + te(x4,x5,bs=c("cr","ps"),k=c(6,7)):<BR>规定,张产品应使用一个等级6的三次回归样条边缘和一个7级P-样条曲线边缘创建一个平滑的基础上尺寸42。


嵌套条款----------Nested terms----------

Another common modelling task is to decide if a model like:
另一种常见的建模任务是,以决定是否这样一个模型:

is really necessary or whether:
确有必要,或者是否:

would do just as well. One possibility is to examine the results of fitting:<br> y ~ s(x) + s(z) + s(x,z).<br> gam automatically generates side conditions to make this model identifiable. You can also estimate "overlapping" models like:<br> y ~ s(x,z) + s(z,v).  
会做的一样好。一种可能性是,检查结果拟合:<BR>y ~ s(x) + s(z) + s(x,z)。<BR> gam自动生成侧条件,使这种模式的识别。您还可以估算重叠的模型,如:<BR> y ~ s(x,z) + s(z,v)。

Note that optimum interpretability of such models is obtained by ensuring that  lower order terms are strictly nested withing higher order ones. This is most easily achieved by employing tensor product smooths for multidimensional terms, and ensuring that lower order terms are using the same (marginal) bases as higher order ones. For example:<br> y ~ s(x,bs="cr",k=5) + s(z,bs="cr",k=5) + te(x,z)<br> would ensure strict nesting of the main effects within the interaction (given the te default  bs and k arguments), since the main effects employ the same bases used as marginals for the te term.
需要注意的是,这样的模型,得到最佳的解释性确保低阶项是严格嵌套高阶的内。这是最容易实现的采用张量积平滑为多维的条款,确保低阶项使用的是相同的(边际)高阶的碱基。对于例如:<br>的y ~ s(x,bs="cr",k=5) + s(z,bs="cr",k=5) + te(x,z)参考将确保严格嵌套的主要影响范围内的相互作用(给定te默认的bs和k参数),因为作为边缘人的te术语主要影响采用相同的基础。


的变量----------&lsquo;by&rsquo; variables----------

by variables are the means for constructing "varying-coefficient models" (geographic regression models) and  for letting smooths "interact" with factors or parametric terms. They are also the key to specifying general linear  functionals of smooths.
by变量是建设“变系数模型”(GEO回归模型),让平滑互动的因素或参数方面的手段。他们还指定一般的平滑线性泛函的关键。

The s and te terms used to specify smooths accept an argument by,  which is a numeric or factor variable of the same dimension as the covariates of the smooth.  If a by variable is numeric, then its ith element multiples the  ith row of the model matrix corresponding to the smooth term concerned.
s和te条款用于指定平滑接受的参数by,这是一个数字或因子变量的尺寸相同协变量的顺利。如果一个by变量是数值型的,那么它的ith元的倍数ith的模型矩阵的行对应的顺利术语关注。

Factor smooth interactions (see also factor.smooth.interaction). If a by variable is a factor then it  generates an indicator vector for each level  of the factor, unless it is an ordered factor. In the non-ordered case, the model matrix for the smooth term is then replicated for each factor level, and each copy has its rows multiplied by the corresponding rows of its indicator variable. The smoothness penalties are also duplicated for each factor level.  In short a different smooth is generated for each factor level (the id argument to s and te can be used to force all  such smooths to have the same smoothing parameter). ordered by variables are handled in the same  way, except that no smooth is generated for the first level of the ordered factor (see b3 example below).  This is useful for setting up  identifiable models when the same smooth occurs more than once in a model, with different factor by variables.
因子光滑的相互作用(factor.smooth.interaction)。如果一个by变量是一个:factor然后它会产生一个指标向量为每个级别的因素,除非它是一个ordered因素。在非有序的情况下,模型矩阵的顺利任期然后复制每个因子水平,每个副本都有其乘以其指示变量的相应行的行。所有的平滑处罚也重复为每个因子水平。总之,不同的光滑生成的每个因子水平(id参数s和te可以用来强制所有平滑有相同的平滑参数)。 orderedby变量都以相同的方式处理,不同之处在于没有平坦的生成的有序因子(见b3以下示例)的第一级。建立识别模型时,同样流畅不止一次出现在模型中,不同的因素by变量,这是非常有用的。

As an example, consider the model
作为一个例子,考虑模型

where f is a smooth function, and z_i is a numeric variable. The appropriate formula is:<br> y ~ s(x,by=z)<br> - the by argument ensures that the smooth function gets multiplied by covariate z. Note that when using factor by variables, centering constraints are applied to the smooths, which usually means that the by variable should be included as a parametric term, as well.
f是一个光滑函数,z_i是一个数值型变量。相应的计算公式是:<BR>y ~ s(x,by=z)的<BR>  - by参数,确保顺利被乘以协z。请注意,当使用的变量因素,围绕制约因素的平滑,这通常意味着的变量作为参数来看,以及。

The example code below also illustrates the use of factor by variables.
下面的示例代码演示了如何使用的因素by变量。

by variables may be supplied as numeric matrices as part of specifying general linear functional terms.
by变量可以提供作为一般线性泛函条款指定的数字矩阵。

If a by variable is present and numeric (rather than a factor) then the corresponding smooth is only subjected  to an identifiability constraint if (i) the by variable is a constant vector, or, (ii) for a matrix  by variable, L, if L%*%rep(1,ncol(L)) is constant or (iii) if a user defined smooth constructor  supplies an identifiability constraint explicitly, and that constraint has an attibute "always.apply".
如果by变量是本和数字(而不是一个因素),然后只经受相应的光滑的一个可识别约束,如果(i)该by变量是一个常数的向量,或(ii)矩阵by变量,L如果L%*%rep(1,ncol(L))是不变或(iii)如果一个用户定义的光滑的构造函数中提供明确的可识别性约束,,约束的attibute的"always.apply" 。


链接平滑具有id----------Linking smooths with &lsquo;id&rsquo;----------

It is sometimes desirable to insist that different smooth terms have the same degree of smoothness.  This can be done by using the id argument to s or te terms. Smooths  which share an id will have the same smoothing parameter. Really this only makes sense if the  smooths use the same basis functions, and the default behaviour is to force this to happen: all smooths  sharing an id have the same basis functions as the first smooth occurring with that id. Note  that if you want exactly the same function for each smooth, then this is best achieved by making use of the  summation convention covered under "linear functional terms".
有时希望坚持,不同的光滑的术语具有相同的平滑度。这可以通过使用ids或te条款的参数。平滑共享id将有相同的平滑参数。实际上这仅是有道理如果在平滑使用相同的基础功能,默认的行为是强制要做到这一点:所有平滑共享id具有相同的基函数的第一个平滑的发生与那id 。请注意,如果你想要完全一样的功能,每个光滑,那么这是最好的实现使用求和约定范围内“线性泛函条款”。

As an example suppose that E(y_i)=mu_i and
作为一个例子假设E(y_i)=mu_i

but that f1 and f3 should have the same smoothing parameters (and x_2 and x_3 are on different scales). Then  the gam formula<br> y ~ s(x1,id=1) + te(x_2,x3) + s(x4,id=1)<br> would achieve the desired result. id can be numbers or character strings. Giving an id to a  term with a factor by variable causes the smooths at each level of the factor to have the same smoothing  parameter.
但f1和f3应该有相同的平滑参数(x_2和x_3是在不同的尺度)。然后gam公式参考y ~ s(x1,id=1) + te(x_2,x3) + s(x4,id=1)参考会达到预期的效果。 id可以是数字或字符串。给予id术语的因素by变量的原因,在每个级别的因素有相同的平滑参数的平滑。

Smooth term ids are not supported by gamm.
光滑的术语id的是不支持的gamm。


线性泛函条款----------Linear functional terms----------

General linear functional terms have a long history in the spline literature including in the penalized  GLM context (see e.g. Wahba 1990). Such terms encompass varying coefficient models/ geographic  regression, functional GLMs (i.e. GLMs with functional predictors), GLASS models, etc, and allow  smoothing with respect to aggregated covariate values, for example.
一般线性功能上来讲有很长的历史,在花文学,包括在受到处罚的的GLM情况下(例如沃赫拜1990)。这些条款包括变系数模型/的GEO回归,功能GLMS(即与功能预测因子的GLMS),玻璃模型,等等,并允许平滑聚集的协变量值,例如。

Such terms are implemented in mgcv using a simple "summation convention" for smooth terms: If the covariates of a  smooth are supplied as matrices, then summation of the evaluated smooth over the columns of the matrices is implied. Each  covariate matrix and any by variable matrix must be of the same dimension. Consider, for example the term<br> s(X,Z,by=L)<br> where X, Z and L are n by p matrices. Let f denote the thin plate regression  spline specified. The resulting contibution to the ith  element of the linear predictor is
这样的术语来实现在mgcv使用一个简单的“求和约定的顺利条款:如果协变量的顺利供给作为矩阵,然后求和超过矩阵的列的评价平滑隐含。每个协变量矩阵和任何by的变量矩阵必须是相同的维度。考虑,例如的的术语<BR>s(X,Z,by=L)<BR>X,Z和L是n by p矩阵。让我们f表示薄板的回归样条。由此产生的contibutionith元素的线性预测

If no L is supplied then all its elements are taken as 1. In R code terms, let F denote the n by p  matrix obtained by evaluating the smooth at the values in X and Z. Then the contribution of the term to the  linear predictor is rowSums(L*F) (note that it's element by element multiplication here!).
如果没有L提供,则它的所有元素都为1。在R代码的条款,让F表示n by p矩阵中的值X和Z顺利通过评估获得的。术语的线性预测的贡献是rowSums(L*F)(请注意,它的元素的元素相乘在这里!)。

The summation convention applies to te terms as well as s terms. More details and examples  are provided in  linear.functional.terms.
的求和约定适用于te条件,以及s条款。在linear.functional.terms提供更多的细节和例子。


随机效应----------Random effects----------

Random effects can be added to gam models using s(...,bs="re") terms (see  smooth.construct.re.smooth.spec),  or the paraPen argument to gam covered below. See gam.vcomp, random.effects and  smooth.construct.re.smooth.spec for further details. An alternative is to use the approach of gamm.
随机效应可以被添加到gam使用s(...,bs="re")条款(见smooth.construct.re.smooth.spec),或paraPen参数gam下面介绍的模型。 gam.vcomp,random.effects和smooth.construct.re.smooth.spec进一步的细节。另一种方法是使用方法gamm。


惩罚参数条款----------Penalizing the parametric terms----------

In case the ability to add smooth classes, smooth identities, by variables and the summation convention are  still not sufficient to implement exactly the penalized GLM that you require, gam also allows you to penalize the  parametric terms in the model formula. This is mostly useful in  allowing one or more matrix terms to be included in the formula, along with a  sequence of quadratic penalty matrices for each.
在情况下,添加平滑的类,流畅的身份,by变量和求和约定仍不足以完全执行处罚的GLM您需要的能力,gam也可以让你惩罚的参数计算,模型公式。这是非常有用的,允许一个或多个矩阵条件要包含在该式中,随着二次罚矩阵,对于每个序列。

Suppose that you have set up a model matrix X, and want to penalize the corresponding coefficients, b with two penalties b'S1 b and b'S2 b.  Then something like the  following would be appropriate:<br> gam(y ~ X - 1,paraPen=list(X=list(S1,S2)))<br> The paraPen argument should be a list with elements having  names corresponding to the terms being penalized.  Each element of paraPen is itself a list, with optional elements L, rank and sp: all other elements  must be penalty matrices. If present, rank is a vector giving the rank of each penalty matrix  (if absent this is determined numerically). L is a matrix that maps underlying log smoothing parameters to the  log smoothing parameters that actually multiply the individual quadratic penalties: taken as the identity if not supplied. sp is a vector of (underlying) smoothing parameter values: positive values are taken as fixed, negative to signal that  the smoothing parameter should be estimated. Taken as all negative if not supplied.
假设你建立了一个模型矩阵X,要惩罚相应的系数,b与人两个点球b'S1 b和b'S2 b。然后像下面的东西是适当的:<BR>gam(y ~ X - 1,paraPen=list(X=list(S1,S2)))参考paraPen参数应该是有相应的条款被处罚的名称列表中的元素。 paraPen的每个元素本身也是一个列表,可选的元素L,rank和sp:所有其他元素必须惩罚矩阵。如果存在,rank是一个向量,每个罚球矩阵的秩(如果不存在的话,这是确定的数值)。 L是一个矩阵,它图相关log平滑参数的log平滑参数乘以个人的二次处罚:如果未提供的身份。 sp是一个向量(底层)的平滑参数值:正值固定的,消极的信号,平滑参数应估计。如果未提供的所有负。

An obvious application of paraPen is to incorporate random effects, and an example of this is provided below. In this case the supplied penalty matrices will be (generalized) inverse covariance matrices for the random effects &mdash; i.e. precision  matrices. The final estimate of the covariance matrix corresponding to one of these penalties is given by the (generalized)  inverse of the penalty matrix multiplied by the estimated scale parameter and divided by the estimated  smoothing parameter for the penalty. For example, if you use an identity matrix to penalize some coefficients that are to be viewed as i.i.d.  Gaussian random effects, then their estimated variance will be the estimated scale parameter divided by the estimate of the  smoothing parameter, for this penalty. See the "rail" example below.
paraPen一个明显的应用是将随机的效果,下面提供了一个这样的例子。在这种情况下,提供的处罚矩阵(广义)的随机效应 - 即精度矩阵的逆协方差矩阵。最终这些刑罚之一相对应的协方差矩阵的估计由下式给出(广义)逆的惩罚矩阵乘以估计尺度参数除以估计的平滑参数的罚款。例如,如果你使用一个单位矩阵,以惩罚被视为独立同分布的一些系数是高斯随机效应,那么他们的估计方差估计尺度参数除以平滑参数的估计,这个点球。请参阅“铁路下面的例子。

P-values for penalized parametric terms should be treated with caution. If you must have them, then use the option freq=TRUE in  anova.gam and summary.gam, which will tend to give reasonable results for random effects implemented this way,  but not for terms with a rank defficient penalty (or penalties with a wide eigen-spectrum).
P-值惩罚参数术语应谨慎对待。如果你必须有他们,然后使用选项“freq=TRUEanova.gam和summary.gam,往往会以这种方式实现的随机效应得到合理的结果,但不与等级defficient刑罚具有广泛的频谱特征(或处罚)。


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


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



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


and Hall/CRC Press.

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


set.seed(10)
## simulate date from y = f(x2)*x1 + error[#模拟日期从y = F(X2)* X1 +错误]
dat <- gamSim(3,n=400)

b<-gam(y ~ s(x2,by=x1),data=dat)
plot(b,pages=1)
summary(b)

## Factor `by' variable example (with a spurious covariate x0)[#因子的变量的例子(使用一个虚假的协X0)]
## simulate data...[#模拟数据...]

dat <- gamSim(4)

## fit model...[#拟合模型...]
b <- gam(y ~ fac+s(x2,by=fac)+s(x0),data=dat)
plot(b,pages=1)
summary(b)

## note that the preceding fit is the same as....[#注意前面的契合是一样的。......]
b1<-gam(y ~ s(x2,by=as.numeric(fac==1))+s(x2,by=as.numeric(fac==2))+
            s(x2,by=as.numeric(fac==3))+s(x0)-1,data=dat)
## ... the `-1' is because the intercept is confounded with the [#... -1,是因为混淆与拦截]
## *uncentred* smooths here.[*不集中*平滑这里。]
plot(b1,pages=1)
summary(b1)

## repeat forcing all s(x2) terms to have the same smoothing param[#重复迫使所有(X2)的条款有相同的平滑参数]
## (not a very good idea for these data!)[#(对这些数据并不是一个很好的主意!)]
b2 <- gam(y ~ fac+s(x2,by=fac,id=1)+s(x0),data=dat)
plot(b2,pages=1)
summary(b2)

## now repeat with a single reference level smooth, and [#现在重复与一个单一的参考水平光滑,]
## two `difference' smooths...[#2差平滑...]
dat$fac <- ordered(dat$fac)
b3 <- gam(y ~ fac+s(x2)+s(x2,by=fac)+s(x0),data=dat,method="REML")
plot(b3,pages=1)
summary(b3)


rm(dat)

## An example of a simple random effects term implemented via [#一个例子,实现通过一个简单的随机效应项]
## penalization of the parametric part of the model...[#处罚的参数化模型的一部分,...]

dat &lt;- gamSim(1,n=400,scale=2) ## simulate 4 term additive truth[#模拟的添加剂真理]
## Now add some random effects to the simulation. Response is [#现在,添加一些随机效果的模拟。响应是]
## grouped into one of 20 groups by `fac' and each groups has a[FAC“#分为20组,每个组有一个]
## random effect added....[#随机效应增加....]
fac <- as.factor(sample(1:20,400,replace=TRUE))
dat$X <- model.matrix(~fac-1)
b <- rnorm(20)*.5
dat$y <- dat$y + dat$X%*%b

## now fit appropriate random effect model...[#现在配合适当的随机效应模型...]
PP <- list(X=list(rank=20,diag(20)))
rm <- gam(y~ X+s(x0)+s(x1)+s(x2)+s(x3),data=dat,paraPen=PP)
plot(rm,pages=1)
## Get estimated random effects standard deviation...[#获取随机效应估计标准差...]
sig.b <- sqrt(rm$sig2/rm$sp[1]);sig.b

## a much simpler approach uses "re" terms...[#一个更简单的方法是使用“重”的条款...]

rm1 <- gam(y ~ s(fac,bs="re")+s(x0)+s(x1)+s(x2)+s(x3),data=dat,method="ML")
gam.vcomp(rm1)

## Simple comparison with lme, using Rail data. [#简单的比较与伦敦金属交易所,用铁的数据。]
## See ?random.effects for a simpler method[#看到了吗?random.effects一个简单的方法]
require(nlme)
b0 <- lme(travel~1,data=Rail,~1|Rail,method="ML")
Z <- model.matrix(~Rail-1,data=Rail,
     contrasts.arg=list(Rail="contr.treatment"))
b <- gam(travel~Z,data=Rail,paraPen=list(Z=list(diag(6))),method="ML")

b0
(b$reml.scale/b$sp)^.5 ## `gam' ML estimate of Rail sd[#GAM的ML估计铁SD]
b$reml.scale^.5         ## `gam' ML estimate of residual sd[#GAM的ML估计剩余的SD]

b0 <- lme(travel~1,data=Rail,~1|Rail,method="REML")
Z <- model.matrix(~Rail-1,data=Rail,
     contrasts.arg=list(Rail="contr.treatment"))
b <- gam(travel~Z,data=Rail,paraPen=list(Z=list(diag(6))),method="REML")

b0
(b$reml.scale/b$sp)^.5 ## `gam' REML estimate of Rail sd[#GAM的REML估计铁SD]
b$reml.scale^.5         ## `gam' REML estimate of residual sd[#GAM的REML估计剩余的SD]


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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-23 23:13 , Processed in 0.030988 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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