Skip to content
Snippets Groups Projects
OLS.R 943 B
Newer Older
Martin Renoult's avatar
Martin Renoult committed
## R code for OLS
## Author: Martin Renoult
## correspondence: martin.renoult@misu.su.se

## Created: 27 April 2020

## PMIP2 ensemble
y <- c(4,4.4,2.7,3.4,2.3,3.3,1.8)
x <- c(-2.74899797,-2.82983243,-2.11649457,-3.15521371,-2.35793821,-2.77644642,-1.33816631)

## PMIP2 + 3 ensemble
y <- c(4,4.4,2.7,3.4,2.3,3.3,1.8,
       3.2,4.13,4.67,3.45,3.25,2.6,3.37)

x <- c(-2.74899797,-2.82983243,-2.11649457,-3.15521371,-2.35793821,-2.77644642,-1.33816631,
       -2.5957031, -3.3755188, -2.5169983, -2.5567322, -1.6669922, -2.81839, -3.1465664)

## PMIP3 ensemble
y <- c(3.2,4.13,4.67,3.45,3.25,2.6,3.37)

x <- c(-2.5957031, -3.3755188, -2.5169983, -2.5567322, -1.6669922, -2.81839, -3.1465664)

## Temperature reconstruction
temp <- rnorm(20000,mean=-2.2,sd=0.4)

## OLS
fit <- lm(y~x)
fit$coefficients

## Prediction intervals and median
obj <- predict(fit, newdata=data.frame(x=temp), interval="prediction",level=0.95)
stat_sum <- colMeans(obj)