B
R Code for Figure 9-2

n <- 600;

baseline <- n - 0:99;

phi <- 0.9;


HSIndex <- function(x)

{

(mean(x[baseline]) - mean(x)) / sqrt(var(x));

}


SimulatePC1 <- function(p = 50)

{

a <- matrix(NA, n, p);

for (j in 1:p) {

b <- arima.sim(model = list(ar = phi), n);

a[ , j] <- b - mean(b[baseline]);

}

invisible(svd(a)$u[,1]);

}


a <- matrix(NA, n, 5);

for (j in 1:ncol(a)) {

a[ , j] <- SimulatePC1();

}


b <- apply(a, 2, HSIndex);

c <- t(sign(b) * t(a));

matplot(c, type = “l”, xlab = “”, ylab = “”, lty = 2);



The National Academies | 500 Fifth St. N.W. | Washington, D.C. 20001
Copyright © National Academy of Sciences. All rights reserved.
Terms of Use and Privacy Statement



Below are the first 10 and last 10 pages of uncorrected machine-read text (when available) of this chapter, followed by the top 30 algorithmically extracted key phrases from the chapter as a whole.
Intended to provide our own search engines and external engines with highly rich, chapter-representative searchable text on the opening pages of each chapter. Because it is UNCORRECTED material, please consider the following text as a useful but insufficient proxy for the authoritative book pages.

Do not use for reproduction, copying, pasting, or reading; exclusively for search engines.

OCR for page 140
Surface Temperature Reconstructions for the last 2,000 Years B R Code for Figure 9-2 n <- 600; baseline <- n - 0:99; phi <- 0.9; HSIndex <- function(x) { (mean(x[baseline]) - mean(x)) / sqrt(var(x)); } SimulatePC1 <- function(p = 50) { a <- matrix(NA, n, p); for (j in 1:p) { b <- arima.sim(model = list(ar = phi), n); a[ , j] <- b - mean(b[baseline]); } invisible(svd(a)$u[,1]); } a <- matrix(NA, n, 5); for (j in 1:ncol(a)) { a[ , j] <- SimulatePC1(); } b <- apply(a, 2, HSIndex); c <- t(sign(b) * t(a)); matplot(c, type = “l”, xlab = “”, ylab = “”, lty = 2);

OCR for page 140
Surface Temperature Reconstructions for the last 2,000 Years PopulationCov <- function(n) { a <- matrix(NA, n, n); a[] <- phi^abs(row(a) - col(a)); for (i in 1:n) a[i, ] <- a[i, ] - mean(a[i, baseline]); for (j in 1:n) a[ , j] <- a[ , j] - mean(a[baseline, j]); invisible(a); } e <- eigen(PopulationCov(n)); lines(e$vectors[,1], col = 2, lwd = 2);