当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


R pen.edf 提取与游戏拟合中每个惩罚相关的有效自由度


R语言 pen.edf 位于 mgcv 包(package)。

说明

找到每个惩罚所惩罚的系数并将其有效自由度相加。对于 t2 术语非常有用,但对于惩罚重叠参数集的术语(例如 te 术语)很难解释。

用法

pen.edf(x)

参数

x

继承自gam的对象

细节

对于包含 t2 项的模型很有用,因为它会根据平滑的不同分量将项的 EDF 分成多个部分。这对于确定模型中实际需要哪些交互项非常有用。

EDF 向量,以标签命名,标识每个 EDF 与哪个惩罚相关。

例子

 
  require(mgcv)
  set.seed(20) 
  dat <- gamSim(1,n=400,scale=2) ## simulate data
  ## following `t2' smooth basically separates smooth 
  ## of x0,x1 into main effects + interaction.... 
  
  b <- gam(y~t2(x0,x1,bs="tp",m=1,k=7)+s(x2)+s(x3),
           data=dat,method="ML")
  pen.edf(b)
  
  ## label "rr" indicates interaction edf (range space times range space)
  ## label "nr" (null space for x0 times range space for x1) is main
  ##            effect for x1.
  ## label "rn" is main effect for x0
  ## clearly interaction is negligible
  
  ## second example with higher order marginals. 
  
  b <- gam(y~t2(x0,x1,bs="tp",m=2,k=7,full=TRUE)
             +s(x2)+s(x3),data=dat,method="ML")
  pen.edf(b)
  
  ## In this case the EDF is negligible for all terms in the t2 smooth
  ## apart from the `main effects' (r2 and 2r). To understand the labels
  ## consider the following 2 examples....
  ## "r1" relates to the interaction of the range space of the first 
  ##      marginal smooth and the first basis function of the null 
  ##      space of the second marginal smooth
  ## "2r" relates to the interaction of the second basis function of 
  ##      the null space of the first marginal smooth with the range 
  ##      space of the second marginal smooth. 

作者

Simon N. Wood simon.wood@r-project.org

也可以看看

t2

相关用法


注:本文由纯净天空筛选整理自R-devel大神的英文原创作品 Extract the effective degrees of freedom associated with each penalty in a gam fit。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。