CTFSworkshop(data=TRUE) args(modelfit.Bayes) fit=modelfit.Bayes(start=c(-2,2,.5),xcol='logdbh',ycol='logagb',steps=100,showstep=10,burnin=50) fit=modelfit.Bayes(start=c(-2,2,.5),xcol='logdbh',ycol='logagb',data=treemass,steps=100,showstep=10,burnin=50) fit=modelfit.Bayes(start=c(-2,2,.5),xcol='logdbh',ycol='logagb',data=treemass,model=linear.model,steps=100,showstep=10,burnin=50) str(treemass.split) names(treemass.split) options(width=70) is.list(treemass.split) head(treemass) head(treemass.split[[1]]) names(treemass.split) options(width=60) names(treemass.split) table(treemass$Locality) treemass.split$BraRond subset(treemass,Locality=='BraRond') treemass.split$BraRond CTFSworkshop() args(growthModelHier) args(metrop1step) args(CI) growthModelHier(start=c(0,0,1),data=treemass.split,xcol='logdbh',gcol='logagb') CTFSworkshop() growthModelHier(start=c(0,0,1),data=treemass.split,xcol='logdbh',gcol='logagb') growthModelHier(start=c(0,0,1),data=treemass.split,xcol='logdbh',gcol='logagb',steps=1000,burnin=500,showstep=100) fit=growthModelHier(start=c(0,0,1),data=treemass.split,xcol='logdbh',gcol='logagb',steps=1000,burnin=500,showstep=100) debug(growthModelHier) fit=growthModelHier(start=c(0,0,1),data=treemass.split,xcol='logdbh',gcol='logagb',steps=1000,burnin=500,showstep=100) Q debug(growthModelHier) fit=growthModelHier(start=c(0,0,1),data=treemass.split,xcol='logdbh',gcol='logagb',steps=1000,burnin=500,showstep=100) Q source('~/meetings_workshops/Rmodeling/cenpat/growthModelHier.r') source('~/meetings_workshops/Rmodeling/cenpat/growthModelHierBayes.r') source('~/meetings_workshops/Rmodeling/cenpat/growthModel.HierBayes.r') source('~/meetings_workshops/Rmodeling/Cenpat/growthModel.HierBayes.r') CTFSworkshop() fit=growthModelHier(start=c(0,0,1),data=treemass.split,xcol='logdbh',gcol='logagb',steps=1000,burnin=500,showstep=100) n dim(param) head(param[1,,]) n x plot(x,y) allspp[j] n metropInter oneparam head(param[1,,]) oneparam head(param[1,,]) head(param[1,,]) Q fit=growthModelHier(start=c(0,0,1),data=treemass.split,xcol='logdbh',gcol='logagb',steps=1000,burnin=500,showstep=100,debug=TRUE) n c m n head(param[1,,]) head(param[2,,]) head(param[3,,]) param[,i,1] n hyperMuInter hyperSDInter c c n c i head(param[3,,]) head(param[2,,]) param[,i,1] param[,i,2] Q CTFSworkshop() fit=growthModelHier(start=c(0,0,1),data=treemass.split,xcol='logdbh',gcol='logagb',steps=1000,burnin=500,showstep=100) Q CTFSworkshop() fit=growthModelHier(start=c(0,0,1),data=treemass.split,xcol='logdbh',gcol='logagb',steps=1000,burnin=500,showstep=100) fit=growthModelHier(start=c(0,0,1),data=treemass.split,xcol='logdbh',gcol='logagb',steps=2000,burnin=1000,showstep=100) names(fit) dim(fit$full) dim(fullhyper) dim(fit$fullhyper) fit$best dim(fit$fullhyper) plot(fit$fullhyper[,1]) plot(fit$fullhyper[,2]) plot(fit$fullhyper[,3]) plot(fit$fullhyper[,4]) plot(fit$full[1,,1]) plot(fit$full[2,,1]) plot(fit$fullhyper[,4]) plot(fit$full[2,,1]) fit=growthModelHier(start=c(0,0,1),data=treemass.split,xcol='logdbh',gcol='logagb',steps=4000,burnin=1000,showstep=3000) fit$besthyper fit$CIhyper plot(fit$fullhyper[,4]) plot(fit$fullhyper[,1]) fit=growthModelHier(start=c(-2,2,1),data=treemass.split,xcol='logdbh',gcol='logagb',steps=4000,burnin=1000,showstep=3000) plot(fit$fullhyper[,1]) plot(fit$fullhyper[,2]) plot(fit$full[2,,1]) plot(fit$full[2,,2]) plot(fit$full[2,,1]) fit$best lm(logagb~logdbh,data=treemass.split$BraRond)$coef abline(fit$best[1,1:2]) plot(logagb~logdbh,data=treemass) plot(logagb~logdbh,data=treemass[[1]]) plot(logagb~logdbh,data=treemass.split[[1]]) for(i in 2:28) points(logagb~logdbh,data=treemass.split[[i]],col=i) names(treemass.split) head(fit$best) str(fit$best) abline(fit$best[1,1:2]) abline(as.matrix(fit$best[1,1:2])) fit$best=as.matrix(fit$best) cf=as.matrix(fit$best) cf abline(cf[3,1:2]) cf=as.matrix(fit$best[,1:2]) abline(cf[3,]) abline(cf[5,]) plot(logagb~logdbh,data=treemass) plot(logagb~logdbh,data=treemass,cex=.2) for(i in 1:28) abline(cf[i,]) for(i in 1:28) abline(cf[i,],col=i) fit$besthyper for(i in 1:28) { plot(logagb~logdbh,data=treemass[[i]]); abline(cf[i,]) } for(i in 1:28) { plot(logagb~logdbh,data=treemass[[i]]); abline(cf[i,]) } cf[1,] for(i in 1:28) { plot(logagb~logdbh,data=treemass.split[[i]]); abline(cf[i,]) } for(i in 1:28) { plot(logagb~logdbh,data=treemass.split[[i]]); abline(cf[i,]) } for(i in 1:28) { plot(logagb~logdbh,data=treemass.split[[i]]); abline(cf[i,]) } par(ask=TRUE) for(i in 1:28) { plot(logagb~logdbh,data=treemass.split[[i]]); abline(cf[i,]) } par(ask=FALSE) par(mfcol=c(4,3)) for(i in 1:12) { plot(logagb~logdbh,data=treemass.split[[i]]); abline(cf[i,]) } for(i in 1:12) { plot(logagb~logdbh,data=treemass.split[[i]]); abline(cf[i,]) } par(mfcol=c(4,3)) for(i in 1:12) { plot(logagb~logdbh,data=treemass.split[[i]]); abline(cf[i,]) } graphics.off() par(mfcol=c(4,3)) for(i in 1:12) { plot(logagb~logdbh,data=treemass.split[[i]]); abline(cf[i,]) } par(mfcol=c(7,4)) for(i in 1:28) { plot(logagb~logdbh,data=treemass.split[[i]]); abline(cf[i,]) } graphics.off() par(mfcol=c(7,4)) for(i in 1:28) { plot(logagb~logdbh,data=treemass.split[[i]]); abline(cf[i,]) } fit$bes fit$best mod=lmer(logagb~1+logdbh+(1+logdbh|Locality),data=treemass) head(coef(mod)$Local) head(fit$best) head(coef(mod)$Local,8) head(fit$best,8) plot(logagb~logdbh,data=treemass.split$BraRond) graphics.off() plot(logagb~logdbh,data=treemass.split$BraRond) plot(logagb~logdbh,data=treemass,cex=.2) points(logagb~logdbh,data=treemass.split$BraRond,col='red',pch=16) abline(cf['BraRond',],col='red',lwd=2) cf=as.matrix(fit$best[,1:2]) cf['BraRond',] abline(lm(logagb~logdbh,data=treemass.split$BraRond,col='green',lwd=2)) abline(lm(logagb~logdbh,data=treemass.split$BraRond),col='green',lwd=2) site='BraRond' site plot(logagb~logdbh,data=treemass,cex=.2) abline(cf[site,],col='red',lwd=2) points(logagb~logdbh,data=treemass.split[[site]],col='red',pch=16) abline(lm(logagb~logdbh,data=treemass.split[[site]]),col='green',lwd=2) site='Australia' head(fit$best) plot(logagb~logdbh,data=treemass,cex=.2) points(logagb~logdbh,data=treemass.split[[site]],col='red',pch=16) abline(lm(logagb~logdbh,data=treemass.split[[site]]),col='green',lwd=2) abline(cf[site,],col='red',lwd=2) fit$best site='IndiaKarna' plot(logagb~logdbh,data=treemass,cex=.2) points(logagb~logdbh,data=treemass.split[[site]],col='red',pch=16) abline(cf[site,],col='red',lwd=2) abline(lm(logagb~logdbh,data=treemass.split[[site]]),col='green',lwd=2) lm(logagb~logdbh,data=treemass.split[[site]])$coef fit$besthyper display(mod) names(fit) savehistory('~/meetings_workshops/Rmodeling/Cenpat/history13Oct.txt')