0
点赞
收藏
分享

微信扫一扫

an example of time series regression analysis

徐一村 2022-04-13 阅读 74
r语言

This passage will introduce an example of time series regression analysis.

文章目录

the series

The data shown below are extracted series from a study by Shumway et al.(1988) of the possible effects of temperature and pollution on weekly mortality in Los Angeles County.

library("astsa")
par(mfrow=c(3,1))
tsplot(cmort, main="Cardiovascular Mortality", ylab="")
tsplot(tempr, main="Temperature", ylab="")
tsplot(part, main="Particulates", ylab="")

在这里插入图片描述

There are strong seasonal components in all of the series, corresponding to winter-summer variations and the downward trend of the cardiovascular morality over the 10-year period.

scatterplot matrix

I will display a scatterplot matrix by R to explore the relation between morality and the pollutant particulates and a possible relation to temperature.

ts.plot(cmort,tempr,part,col=1:3)
legend("topright",legend=c("Mortality","Temperature","Pollution"),lty=1,col=1:3)
pairs(cbind(Mortality=cmort, Temperature=tempr, Particulates=part))

在这里插入图片描述
A scatterplot matrix shown below indicates a possible linear relation.
在这里插入图片描述
The lineplot shown above indicates that higher temperatures as well as lower temperatures are associated with increases in cardiovascular mortality.

model

Based on the scatterplot matrix, we entertain a model where M t M_t Mt denotes mortality, T t T_t Tt denotes temperature, P t P_t Pt denotes the particulate levels, T . T. T. denotes the mean of temperatures to avoid collinearity problems.

M t = β 0 + β 1 t + β 2 ( T t − T . ) + β 3 ( T t − T . ) 2 + β 4 P t + w t M_t = \beta_0 + \beta_1t + \beta_2(T_t-T.) + \beta_3(T_t-T.)^2+\beta_4P_t+w_t Mt=β0+β1t+β2(TtT.)+β3(TtT.)2+β4Pt+wt

Now, I will fit the regression model using the code below.

temp = tempr-mean(tempr)
temp2 = temp^2
trend = time(cmort)
fit = lm(cmort~ trend + temp + temp2 + part, na.action=NULL)
summary(aov(lm(cmort~ cbind(trend, temp, temp2, part))))

Output:
在这里插入图片描述
These results will be summarized in an ANOVA table as given below.
在这里插入图片描述

AIC、AICc、BIC

num = length(cmort)
AIC(fit)/num - log(2*pi)
BIC(fit)/num - log(2*pi)
AICc = log(sum(resid(fit)^2)/num + (num+5)/(num-5-2))
AICc

Output:

[1] 4.721732
[1] 4.771699
[1] 3.723158

Now, we have computed the corresponding values of AIC, AICc and BIC.

举报

相关推荐

Time Series

0 条评论