0

有没有办法在局部回归建模中提取全局拟合项的系数?

也许我确实误解了全局拟合项在函数 loess 中的作用,但我想要的是以下内容:

# baseline:
x <- sin(seq(0.2,0.6,length.out=100)*pi)

# noise:
x_noise <- rnorm(length(x),0,0.1)

# known structure:
x_1 <- sin(seq(5,20,length.out=100))

# signal:
y <- x + x_1*0.25 + x_noise

# fit loess model:
x_seq <- seq_along(x)
mod <- loess(y ~ x_seq + x_1,parametric="x_1")

拟合完成得很完美,但是,如何提取全局拟合项的估计值x_1(即上面示例中接近 0.25 的某个值)?

4

1 回答 1

0

Finally, I found a solution to my problem using the function gam from the package gam:

require(gam)
mod2 <- gam(y ~ lo(x_seq,span=0.75,degree=2) + x_1)

However, the fits from the two models are not exactly the same (which might be due to different control settings?)...

于 2016-07-01T08:33:34.883 回答