dff <- generateData()
# Use package MCMCglmm to get Bayesian posteriors
# NOT RUN ##
#svlist <- makePostSurvivalObjs(dataf = dff, explanatoryVariables = "size",
#meanB = rep(0, 3), varB = rep(1e+10), nitt = 5000)
#grlist <- makePostGrowthObjs(dataf = dff, explanatoryVariables = "size",nitt = 5000)
#fvlist <- makePostFecObjs(dataf = dff, explanatoryVariables = "size",nitt = 5000)
# Use only first 10 of each list, for speed:
#Tlist <- makeListPmatrix(growObjList = grlist[1:10], survObjList = svlist[1:10],
#nBigMatrix = 20, minSize = -5, maxSize = 20, cov = FALSE, envMat = NULL)
#Flist <- makeListFmatrix(fecObjList = fvlist[1:10], nBigMatrix = 20, minSize = -5,
#maxSize = 20, cov = FALSE, envMat = NULL)
#res <- getIPMoutput(PmatrixList = Tlist, targetSize = 10, FmatrixList = Flist)
#names(res)
# Plot out with different colours for different rows:
#par(mfrow=c(2,2),bty="l",pty="s")
#plot(Tlist[[1]]@meshpoints,res$LE[1, ],xlab="Continuous (e.g. size) stage",
#ylab="Life expectancy", type="l",
# ylim=range(res$LE,na.rm=TRUE))
#for (j in 1:nrow(res$LE)) points(Tlist[[1]]@meshpoints,res$LE[j,],col=j, type="l")
#plot(Tlist[[1]]@meshpoints,res$pTime[1, ], xlab = "Continuous (e.g. size) stage",
#ylab = "Passage time", type = "l", ylim = range(res$pTime, na.rm=TRUE))
#for (j in 1:nrow(res$pTime)) points(Tlist[[1]]@meshpoints, res$pTime[j, ], col = j,
#type = "l")
#plot(Tlist[[1]]@meshpoints, Re(res$stableStage[1, ]), xlab = "Continuous (e.g. size) stage",
# ylab = "Stable stage distribution", type = "l",
# ylim = range(Re(res$stableStage), na.rm=TRUE))
#for (j in 1:nrow(res$stableStage)) points(Tlist[[1]]@meshpoints,
# Re(res$stableStage[j, ]),col = j, type = "l")
#hist(res$lambda, xlab = expression(lambda), ylab = "", main = "", col = "grey")
Run the code above in your browser using DataLab