library(repmis)
## Warning: package 'repmis' was built under R version 3.2.4
githubURL <- "https://github.com/AndyBunn/TeachingData/raw/master/climate_Time_Series_Extravaganza.Rdata"
source_data(githubURL)
## Downloading data from: https://github.com/AndyBunn/TeachingData/raw/master/climate_Time_Series_Extravaganza.Rdata
## SHA-1 hash of the downloaded data file is:
## 48125039f27ef2efe9ea38ac221d894f640c2fa5
## [1] "loti.zoo" "co2.zoo" "ice.zoo" "ohc.zoo" "sl.zoo" "loti.ts"
## [7] "co2.ts" "ice.ts" "ohc.ts" "sl.ts"
plot(ice.ts)
summary(ice.ts)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 3.566 8.871 12.210 11.580 14.400 16.350
class(ice.ts)
## [1] "ts"
Just looking at the plot, I can see a somewhat negative trend in the data over time.
library(moments)
## Warning: package 'moments' was built under R version 3.2.3
kt <-kurtosis(ice.ts)
sk <- skewness(ice.ts)
my.xlim <- range(ice.ts)
h<-hist(ice.ts, breaks=10, col="lightblue", xlab="ice extent (sq km)",main="",xlim=my.xlim)
xfit<-seq(min(ice.ts),max(ice.ts),length=100)
yfit<-dnorm(xfit,mean=mean(ice.ts),sd=sd(ice.ts))
yfit <- yfit*diff(h$mids[1:2])*length(ice.ts)
lines(xfit, yfit, col="darkblue", lwd=2)
boxplot(ice.ts, horizontal=TRUE, outline=TRUE, axes=FALSE, ylim=my.xlim, col = "lightgreen", add = TRUE,boxwex=3)
text(x = 4, y=60, labels = paste("Kurtosis=",round(kt,2)),pos = 4)
text(x = 4, y=55, labels = paste("Skewness=",round(sk,2)),pos = 4)
The plot shows normal distribution with a very little skewness to the right.
icetime <- time(ice.ts)
ice.lm <- lm(ice.ts ~ icetime)
summary(ice.lm)
##
## Call:
## lm(formula = ice.ts ~ icetime)
##
## Residuals:
## Min 1Q Median 3Q Max
## -7.1893 -2.6979 0.6955 2.8952 4.4143
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 119.52096 27.23324 4.389 1.42e-05 ***
## icetime -0.05404 0.01363 -3.964 8.58e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.131 on 448 degrees of freedom
## Multiple R-squared: 0.03388, Adjusted R-squared: 0.03173
## F-statistic: 15.71 on 1 and 448 DF, p-value: 8.585e-05
The results show that there was an annual decrease in sea ice of 0.05, or 5%.
I used a moving average filtering method in order to smooth the data.
ma10 <- filter(x=ice.ts, filter=rep(x=1/10,times=10), sides=2)
ma5 <- filter(x=ice.ts, filter=rep(x=1/5,times=5), sides=2)
plot(ice.ts,col="grey")
lines(ma10,col="red",lwd=2)
lines(ma5,col="blue",lwd=2)
abline(ice.lm, col="black",lwd=2, lty="dashed")
##Decomposing by season In order to remove the seasonal component of the data, I decomposed the data
ice.ts<- decompose(ice.ts)
plot(ice.ts)