當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。