##load data
data(mesa.data.model)
data(mesa.data.res)
##examining which components we have
names(mesa.data.res)
##examining the results for the different components
#################
## For par.est ##
#################
names(mesa.data.res$par.est)
##Optimisation status message
mesa.data.res$par.est$message
##extract the estimated parameters
x <- mesa.data.res$par.est$res.best$par.all
##and approximate uncertainties from the hessian
x.sd <- sqrt(diag(-solve(mesa.data.res$par.est$res.best$hessian.all)))
##plot the estimated parameters
par(mfrow=c(1,1),mar=c(13.5,2.5,.5,.5))
plot(x,ylab="",xlab="",xaxt="n")
abline(h=0, col="grey")
axis(1,1:length(x),names(x),las=2)
########################
## For EX and EX.obs ##
########################
names(mesa.data.res$EX)
names(mesa.data.res$EX.obs)
####################
## For par.est.cv ##
####################
names(mesa.data.res$par.est.cv)
##boxplot of the different estimates from the CV
par(mfrow=c(1,1), mar=c(7,2.5,2,.5), las=2)
boxplot(t(mesa.data.res$par.est.cv$par))
points(mesa.data.res$par.est$res.best$par, pch=4, col=2)
##################
## For pred.cv ##
##################
names(mesa.data.res$pred.cv)
##Plot observations with CV-predictions and prediction intervals
par(mfcol=c(4,1),mar=c(2.5,2.5,2,.5))
plotCV(mesa.data.res$pred.cv, 1, mesa.data.model)
plotCV(mesa.data.res$pred.cv, 10, mesa.data.model)
plotCV(mesa.data.res$pred.cv, 17, mesa.data.model)
plotCV(mesa.data.res$pred.cv, 22, mesa.data.model)
#########################################
## For par.est.ST and par.est.ST.mean0 ##
#########################################
names(mesa.data.res$par.est.ST)
names(mesa.data.res$par.est.ST.mean0)
##Optimisation status message
mesa.data.res$par.est.ST$message
mesa.data.res$par.est.ST.mean0$message
##extract the estimated parameters
x.ST <- mesa.data.res$par.est.ST$res.best$par.all
x.ST0 <- mesa.data.res$par.est.ST.mean0$res.best$par.all
##plot the estimated parameters
par(mfrow=c(1,1),mar=c(13.5,2.5,.5,.5))
plot(c(1:5,7:19), x.ST, ylab="",xlab="",xaxt="n")
points(1:19, x.ST0, pch=3, col=2)
points(c(2:5,7:19), x, pch=4, col=3)
abline(h=0, col="grey")
axis(1,1:length(x.ST0),names(x.ST0),las=2)
legend("bottomleft", col = c(1,2,3), pch = 1:3,
legend=c("par.est.ST","par.est.ST.mean0","par.est.ST"))
##################
## For MCMC.res ##
##################
names(mesa.data.res$MCMC.res)
##The MCMC-estimated parameters
summary(mesa.data.res$MCMC.res$par)
##MCMC tracks for four of the parameters
par(mfrow=c(4,1),mar=c(2,2,2.5,.5))
for(i in c(4,9,13,15)){
plot(mesa.data.res$MCMC.res$par[,i], ylab="", xlab="", type="l",
main=colnames(mesa.data.res$MCMC.res$par)[i])
}
##And estimated densities for the log-covariance parameters.
##The red line is the approximate normal distribution given by
##the maximum-likelihood estimates, e.g. ML-estimate and standard
##deviation from the observed information matrix.
par(mfrow=c(3,3),mar=c(4,4,2.5,.5))
for(i in 9:17){
xd <- sort(unique(mesa.data.res$MCMC.res$par[,i]))
yd <- dnorm(xd, mean=x[i],sd=x.sd[i])
dens <- density(mesa.data.res$MCMC.res$par[,i])
plot(dens, ylim=c(0,max(c(dens$y,yd))), main =
colnames(mesa.data.res$MCMC.res$par)[i])
lines(xd,yd,col=2)
}
Run the code above in your browser using DataLab