# Read file with data filenames setwd("bayesmodel") load(paste("bayes_recon_",numpc,".R",sep="")) yhat <- list(yhat1, yhat2, yhat3) yhatbar <- lapply(yhat, rowMeans) all_idxD <- c(in_idxD, out_idxD) mm <- min(unlist(lapply(yhat,min))) MM <- max(unlist(lapply(yhat,max))) sizes <- c( mean(apply(yhat[[1]], 1, quantile, prob=.975)-apply(yhat[[1]], 1, quantile, prob=.025)), mean(apply(yhat[[2]], 1, quantile, prob=.975)-apply(yhat[[2]], 1, quantile, prob=.025)), mean(apply(yhat[[3]], 1, quantile, prob=.975)-apply(yhat[[3]], 1, quantile, prob=.025)) ) sizerank <- rank(sizes) vv <- mean(c( max(as.numeric(out_idxI)), min(as.numeric(in_idxI)) )) # PLOT: pdf(pdffile1, width=8, height=5) par(oma=rep(0,4), mar=c(4,4,.7,.1)) plot(as.numeric(all_idxD), yhatbar[[1]], type="n", col=sizerank[1]+1, ylim=c(-1.5, 1.5), xlab="Year", ylab="Temperature Anomaly (C)",main=paste("Impact of proper proxy selection/No Tilj/OLS PC",numpc,sep=""),cex.main=0.8) for(j in 1:dim(yhat[[3]])[2]){ lines(as.numeric(all_idxD), yhat[[3]][,j], col="grey") } for(j in 1:dim(yhat[[1]])[2]){ lines(as.numeric(all_idxD), yhat[[1]][,j], col=5) } for(j in 1:dim(yhat[[2]])[2]){ lines(as.numeric(all_idxD), yhat[[2]][,j], col=colors()[47]) } # Add mean of all reconstructions lines(as.numeric(all_idxD), yhatbar[[1]], type="l", col=2, ylim=c(mm, MM), xlab="", ylab="") tmplo <- loess(yhatbar[[1]]~as.numeric(all_idxD), span=.05) tmpy <- predict(tmplo, as.numeric(all_idxD), se=TRUE) lines(as.numeric(all_idxD), tmpy$fit, col=2, lwd=2) # Add CRU lines(instrument[,1], instrument[,2], col=1) tmplo <- loess(instrument[,2] ~instrument[,1], span=.33) tmpy <- predict(tmplo, instrument[,1], se=TRUE) lines(instrument[,1], tmpy$fit, col=1, lwd=2) abline(v=vv) #legend(1300,1.5, legend=c(" "), col=c("red"), lwd=2) dev.off() setwd("../")