【问题标题】:Population-level prediction from bam {mgcv}来自 bam {mgcv} 的人口水平预测
【发布时间】:2018-07-25 13:15:45
【问题描述】:

使用bam,我做了一个如下形式的逻辑混合模型:

PresAbs ~ s(Var 1) + s(Var 2) + ... + s(Var n) + s(RandomVar, bs = "re")

RandomVar 是一个因素,我对每个级别的预测不感兴趣。如何获得与predict.lme相当的人口水平预测?

【问题讨论】:

标签: r prediction mixed-models mgcv


【解决方案1】:

一种方法是从预测中排除随机效应样条。

使用来自?gam.models的示例

library("mgcv")
dat <- 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
## 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

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

我们想排除术语s(fac),因为它写在来自

的输出中
summary(m1)

对于观察到的数据,人口效应是

predict(m1, exclude = 's(fac)')

但您可以提供 newdata 来生成其他协变量组合的预测。

【讨论】:

    猜你喜欢
    • 2016-04-03
    • 2022-11-04
    • 1970-01-01
    • 1970-01-01
    • 2015-03-20
    • 1970-01-01
    • 1970-01-01
    • 2020-07-02
    • 2021-07-19
    相关资源
    最近更新 更多