Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 在因子中添加两个随机效果:GAM_R - Fatal编程技术网

R 在因子中添加两个随机效果:GAM

R 在因子中添加两个随机效果:GAM,r,R,根据这些数据: UQdata MudUQ Estuary Site 7.00 10.9 NoriPau A 6.00 13.9 NoriPau A 5.00 10.3 NoriPau B 4.00 7.9 Porirua A 4.00 8.3 Porirua A 4.00 8.7 Porirua A 4.00 10.9 NoriPau B 3.00 9.8

根据这些数据:

UQdata  MudUQ   Estuary   Site
7.00    10.9    NoriPau   A
6.00    13.9    NoriPau   A
5.00    10.3    NoriPau   B
4.00    7.9     Porirua   A
4.00    8.3     Porirua   A
4.00    8.7     Porirua   A
4.00    10.9    NoriPau   B
3.00    9.8     Porirua   B
3.00    9.8     Porirua   B
3.00    11.5    Porirua   B
我正在使用mgcv软件包拟合以下GAM模型:

aa2.estuary <- gam(UQdata~s(MudUQ, bs="ps", k=5) + s(Estuary, bs="re"), 
                   family=Gamma(link=log),data=Antho)
这里的任何帮助都将不胜感激


mnel,我试过你的建议字符串:

> aa1.estuary<-gam(UQdata~s(MudUQ,bs="ps", k=5) + s(Estuary, bs="re") + s(Site, Estuary, bs = 're'),family=binomial, gamma=1,data=Antho)
Error in while (mean(ldxx/(ldxx + ldss)) < 0.4) { : 
  missing value where TRUE/FALSE needed

>aa1.河口通过返回原始数据并与每个河口相关的
站点重命名
(见下文):

包括
站点
作为另一个随机效应:

aa2.estuary <- gam(UQdata ~ s(MudUQ,bs="ps", k=5) + s(Estuary, bs="re") + s(Site, bs="re"),family=Gamma(link=log),data=Antho)

aa2.equarth你能发布一个可复制的示例(即一些数据)
中的
bs='re'
示例吗?gam.vcomp
并不表明你的
s(equarth~Site+equarth,bs='re')
是正确的(调用
s
时没有提到公式接口)。也许
s(河口,bs='re')+s(站点,河口,bs='re')
就是你想要的want@mnel我想这取决于
站点:河口-1
是否被视为
站点
嵌套在
河口
中<代码>?smooth.construct.re.smooth.spec
提供了更多详细信息。如果这不被认为是嵌套的,那么切换到gamm4包并使用它的
gamm()
,它使用
glmer()
来适应模型可能会更容易。我已经在上述问题中添加了新信息您的上一个示例没有使用您的示例数据。(我希望这只是您的数据的一个子集…)我看不到有文档记载,
mgcv::s
函数采用公式参数。这肯定是我第一次看到这样做。
UQdata  MudUQ   Estuary   Site
7.00    10.9    NoriPau   Nori1
6.00    13.9    NoriPau   Nori1
5.00    10.3    NoriPau   Nori2
4.00    7.9     Porirua   Pori1
4.00    8.3     Porirua   Pori1
4.00    8.7     Porirua   Pori1
4.00    10.9    NoriPau   Nori2
3.00    9.8     Porirua   Pori2
3.00    9.8     Porirua   Pori2
3.00    11.5    Porirua   Pori2
aa2.estuary <- gam(UQdata ~ s(MudUQ,bs="ps", k=5) + s(Estuary, bs="re") + s(Site, bs="re"),family=Gamma(link=log),data=Antho)