从这个数据:
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)
问题:我想添加Estuary
和作为两个随机效果(即),但是当我尝试这个时Site
,它会抛出这个错误:Estuary
s(Estuary ~ Site + Estuary, bs="re")
aa2.estuary <- gam(UQdata ~ s(MudUQ,bs="ps", k=5) +
s(Estuary~Estuary+Site, bs="re"),
family=Gamma(link=log),data=Antho)
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
In addition: Warning message:
In s(Estuary ~ Estuary + Site, bs = "re") :
number of items to replace is not a multiple of replacement length
这里的任何帮助将不胜感激。
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
有任何想法吗?