0

我有一个像这个示例数据这样的数据集,其中包括三个站点。我想沿着“timeInt”模拟“cumSR”的趋势。我使用以下模型(“cumSR~b/(cc+(timeInt)^(-z))”)为每个站点执行此操作。现在我想使用相同的模型来为这三个站点只获得一条曲线。我认为我需要使用非线性混合模型,对吗?我已经尝试过“nlme”包中的“nlme”函数和“lme4”函数中的“nlmer”函数,但还没有弄清楚。有人可以帮忙吗?非常感谢。

    dat = data.frame(cumSR=c(17, 25, 34, 43, 46, 49, 51, 52, 55, 57, 59, 60, 18, 26, 34, 38, 41, 43, 45, 49, 51, 54, 
                     57, 58, 59, 23, 29, 33, 37, 38, 40, 44, 46, 47),
             timeInt=c(2.5, 7.5, 12.5, 17.5, 22.5, 27.5, 32.5, 42.5, 47.5, 52.5, 62.5, 67.5, 2.5, 7.5, 12.5, 17.5, 
                       22.5, 27.5, 32.5, 37.5, 42.5, 47.5, 52.5, 57.5, 62.5, 2.5, 7.5, 12.5, 17.5, 22.5, 37.5, 42.5, 47.5, 57.5),
             site=c("A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B","B", 
                    "B", "B", "B", "B", "B", "B", "C","C","C","C","C","C","C","C","C"))


    par(mfcol=c(1,3))
    dat1 <- dat[which(dat$site=="A"),]
    SAR.nls.logist <- nls(cumSR~b/(cc+(timeInt)^(-z)), data=dat1,start = list(b=10,cc=.1,z=.5))
    plot(dat1$timeInt,dat1$cumSR, type="b",col=1)
    curve(coef(SAR.nls.logist)[1]/(coef(SAR.nls.logist)[2]+(x)^(-coef(SAR.nls.logist)[3])), col = "pink", type="l",add = TRUE,lwd=2)

    dat1 <- dat[which(dat$site=="B"),]
    SAR.nls.logist <- nls(cumSR~b/(cc+(timeInt)^(-z)), data=dat1,start = list(b=10,cc=.1,z=.5))
    plot(dat1$timeInt,dat1$cumSR, type="b",col=1)
    curve(coef(SAR.nls.logist)[1]/(coef(SAR.nls.logist)[2]+(x)^(-coef(SAR.nls.logist)[3])), col = "pink", type="l",add = TRUE,lwd=2)

    dat1 <- dat[which(dat$site=="C"),]
    SAR.nls.logist <- nls(cumSR~b/(cc+(timeInt)^(-z)), data=dat1,start = list(b=10,cc=.1,z=.5))
    plot(dat1$timeInt,dat1$cumSR, type="b",col=1)
    curve(coef(SAR.nls.logist)[1]/(coef(SAR.nls.logist)[2]+(x)^(-coef(SAR.nls.logist)[3])), col = "pink", type="l",add = TRUE,lwd=2)
4

0 回答 0