Sea Ice Summary

load("C:/Users/duranf/Downloads/climate_Time_Series_Extravaganza.Rdata")
summary(ice.ts)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   3.566   8.871  12.210  11.580  14.400  16.350
tsp(ice.ts)
## [1] 1978.750 2016.167   12.000

Preliminary Plots

plot(ice.ts)

boxplot(ice.ts~cycle(ice.ts),xlab="Month",ylab="Millions of sq km")#see the seasons

my.xlim <- range(ice.ts)
h<-hist(ice.ts, breaks=12, col="chartreuse3", xlab="Sea Ice (millions of sq km)",
        main="",xlim=my.xlim)
xfit<-seq(min(ice.ts),max(ice.ts),length=15) 
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="bisque1", lwd=2)
boxplot(ice.ts, horizontal=TRUE,  outline=TRUE,  axes=FALSE,
        ylim=my.xlim, col = "lightblue4", add = TRUE, boxwex=3)

The first plot above is all the sea ice data over time. We can see that there is seasonality to the data, but a trend is not apparent. To see the season more clearly I made a boxplot of the sea ice by month (I think). We can see that sea ice increases from October to March and decreases April through September. Next I made a histogram of the data. We can see that the data are not evenly distributed (not verified by tests).

Linear model

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

Moving averages and trend line

I chose to use 2 and 15 years as my smoothing intervals because I wanted to see the stark difference in smoothing over short and longer intervals.

ma3 <- filter(x=ice.ts, filter=rep(x=1/3,times=3), sides=2)
ma15 <- filter(x=ice.ts, filter=rep(x=1/15,times=15), sides=2)
plot(ice.ts,col="azure3")
lines(ma3,col="sandybrown",lwd=2)
lines(ma15,col="turquoise2",lwd=2)
abline(ice.lm, col="navy",lwd=2, lty="dashed")

Decomposition

ice.d <- decompose(ice.ts)
plot(ice.d)

Look at that downward trend in sea ice!

New data

From the Time Series Data Library, I chose the Personal savings as % of disposable income 1955-1979 data set.

setwd("E:/")
read.csv("save.csv",header=T)
##                                                  Quarter persave
## 1                                                 1955Q1     4.9
## 2                                                 1955Q2     5.2
## 3                                                 1955Q3     5.7
## 4                                                 1955Q4     5.7
## 5                                                 1956Q1     6.2
## 6                                                 1956Q2     6.7
## 7                                                 1956Q3     6.9
## 8                                                 1956Q4     7.1
## 9                                                 1957Q1     6.6
## 10                                                1957Q2     7.0
## 11                                                1957Q3     6.9
## 12                                                1957Q4     6.4
## 13                                                1958Q1     6.6
## 14                                                1958Q2     6.4
## 15                                                1958Q3     7.0
## 16                                                1958Q4     7.3
## 17                                                1959Q1     6.0
## 18                                                1959Q2     6.3
## 19                                                1959Q3     4.8
## 20                                                1959Q4     5.3
## 21                                                1960Q1     5.4
## 22                                                1960Q2     4.7
## 23                                                1960Q3     4.9
## 24                                                1960Q4     4.4
## 25                                                1961Q1     5.1
## 26                                                1961Q2     5.3
## 27                                                1961Q3     6.0
## 28                                                1961Q4     5.9
## 29                                                1962Q1     5.9
## 30                                                1962Q2     5.6
## 31                                                1962Q3     5.3
## 32                                                1962Q4     4.5
## 33                                                1963Q1     4.7
## 34                                                1963Q2     4.6
## 35                                                1963Q3     4.3
## 36                                                1963Q4     5.0
## 37                                                1964Q1     5.2
## 38                                                1964Q2     6.2
## 39                                                1964Q3     5.8
## 40                                                1964Q4     6.7
## 41                                                1965Q1     5.7
## 42                                                1965Q2     6.1
## 43                                                1965Q3     7.2
## 44                                                1965Q4     6.5
## 45                                                1966Q1     6.1
## 46                                                1966Q2     6.3
## 47                                                1966Q3     6.4
## 48                                                1966Q4     7.0
## 49                                                1967Q1     7.6
## 50                                                1967Q2     7.2
## 51                                                1967Q3     7.5
## 52                                                1967Q4     7.0
## 53                                                1968Q1     7.6
## 54                                                1968Q2     7.2
## 55                                                1968Q3     7.5
## 56                                                1968Q4     7.8
## 57                                                1969Q1     7.2
## 58                                                1969Q2     7.5
## 59                                                1969Q3     5.6
## 60                                                1969Q4     5.7
## 61                                                1970Q1     4.9
## 62                                                1970Q2     5.1
## 63                                                1970Q3     6.2
## 64                                                1970Q4     6.0
## 65                                                1971Q1     6.1
## 66                                                1971Q2     7.5
## 67                                                1971Q3     7.8
## 68                                                1971Q4     8.0
## 69                                                1972Q1     8.0
## 70                                                1972Q2     8.1
## 71                                                1972Q3     7.6
## 72                                                1972Q4     7.1
## 73                                                1973Q1     6.6
## 74                                                1973Q2     5.6
## 75                                                1973Q3     5.9
## 76                                                1973Q4     6.6
## 77                                                1974Q1     6.8
## 78                                                1974Q2     7.8
## 79                                                1974Q3     7.9
## 80                                                1974Q4     8.7
## 81                                                1975Q1     7.7
## 82                                                1975Q2     7.3
## 83                                                1975Q3     6.7
## 84                                                1975Q4     7.5
## 85                                                1976Q1     6.4
## 86                                                1976Q2     9.7
## 87                                                1976Q3     7.5
## 88                                                1976Q4     7.1
## 89                                                1977Q1     6.4
## 90                                                1977Q2     6.0
## 91                                                1977Q3     5.7
## 92                                                1977Q4     5.0
## 93                                                1978Q1     4.2
## 94                                                1978Q2     5.1
## 95                                                1978Q3     5.4
## 96                                                1978Q4     5.1
## 97                                                1979Q1     5.3
## 98                                                1979Q2     5.0
## 99                                                1979Q3     4.8
## 100                                               1979Q4     4.7
## 101                                               1980Q1     5.0
## 102                                               1980Q2     5.4
## 103                                               1980Q3     4.3
## 104                                               1980Q4     3.5
## 105                                                           NA
## 106 Personal savings as % of disposable income 1955-1979      NA
S<-read.csv("save.csv",header=T)
SAVE<-S$persave
save<- ts(SAVE,start=c(1955,4),end=c(1979,4),frequency=4)

plot(save,ylab="Personal savings as a % of disposable income")

my.xlim <- range(save)
h<-hist(save, breaks=7, col="chartreuse3", xlab="% Savings",
        main="",xlim=my.xlim)
xfit<-seq(min(save),max(save),length=5) 
yfit<-dnorm(xfit,mean=mean(save),sd=sd(save)) 
yfit <- yfit*diff(h$mids[1:2])*length(save) 
lines(xfit, yfit, col="bisque1", lwd=2)
boxplot(save, horizontal=TRUE,  outline=TRUE,  axes=FALSE,
        ylim=my.xlim, col = "lightblue4", add = TRUE, boxwex=3)

Linear model

savetime <- time(save)
save.lm <- lm(save ~ savetime)
summary(save.lm)
## 
## Call:
## lm(formula = save ~ savetime)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.5709 -0.7931  0.0011  0.8641  2.9999 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)  
## (Intercept) -73.29710   30.37382  -2.413   0.0177 *
## savetime      0.04046    0.01544   2.621   0.0102 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.064 on 95 degrees of freedom
## Multiple R-squared:  0.06746,    Adjusted R-squared:  0.05764 
## F-statistic: 6.872 on 1 and 95 DF,  p-value: 0.0102

There seems to be a downward trend.

Moving averages and trend line

ma3 <- filter(x=save, filter=rep(x=1/3,times=3), sides=2)
ma12 <- filter(x=save, filter=rep(x=1/9,times=9), sides=2)
plot(save,col="azure3")
lines(ma3,col="sandybrown",lwd=2)
lines(ma12,col="turquoise2",lwd=2)
abline(save.lm, col="navy",lwd=2, lty="dashed")

These data are much less pretty than the ice data. Lets see what happens when I decompose…

Decomposition

save.d<-decompose(save)
plot(save.d)

I do not see an obvious trend. What I see is a very strong seasonal pattern. I may be doing this incorrectly, but when I try to pull out the season in a box plot, I do not see an evident pattern (see below).

boxplot(save~cycle(save),xlab="Quarter",ylab="Personal savings")

Trouble shooting

I tried to import the data using the “rdatamarket” library, and read a bit about how the data are imported if you use the dmseries function. It was my understanding that it brings it in as a zoo timeseries. I was able to do most of the above functions except for making a boxplot and using the decompose function. I tried to troubleshoot for a bit, but decide to import my data the way Matt did (Thanks Matt!!) and continued my analysis.How did you guys import your other data?