Time series analysis of the annual global temperature data
The annual global temperature data is here. The SAS code below fits a piecewise linear
regression and then inspects the residuals for temporal correlation.
- Create a basis function to model the change in slope in 1970;
data temp;
set temp;
year_1970=0;
if year > 1970 then year_1970 = year - 1970;
run;
- Fit the piecewise linear regression and plot residuals
proc reg data = temp;
model temp = year year_1970;
output out=temp_out p=p r=r;
run;
proc gplot data = temp_out;
title "Raw data v fitted values";
plot temp*year p*year\overlay;
run;
proc gplot data = temp_out;
title "Residuals";
plot r*year;
run;
- plot the sample autocorrelation function of the residuals;
proc arima data=temp_out;
identify var=r outcov=acf noprint;
run;
PROC GPLOT data=acf uniform;
title "ACF";
plot corr*lag;
run;
- Fit time series models to the residuals
proc arima data=temp_out;
title "AR(1) fit";
identify var=r noprint;
estimate p=1 q=0;
run;
proc arima data=temp_out;
title "ARMA(1,1) fit";
identify var=r noprint;
estimate p=1 q=1;
run;