R :: mgcv中张量相互作用的方差分量

问题描述 投票:3回答:1

为什么mgcv::gam.vcomp显示了与mgcv::ti相互作用的两个方差分量?¨

我似乎无法在任何地方找到解释或行间解释。或许是因为交互中每个组成部分的差异?

require(mgcv)
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
b3 <- gam(y~ ti(x) + ti(z) + ti(x,z))
b3s <- gam(y~ ti(x) + ti(z) + s(x,z)) # describing the itneraction with s(). 

我知道我们在这里混合苹果和橘子。

gam.vcomp(b3)
     ti(x)      ti(z)   ti(x,z)1   ti(x,z)2 
0.06609731 0.01476070 0.08834218 0.05700322 

gam.vcomp(b3s)
    ti(x)     ti(z)    s(x,z) 
0.1623056 2.4870344 7.7484987
r interaction gam mgcv
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.