代写-HW3
时间:2021-11-05
HW3 Solutions
Problem 1
For the Johnson & Johnson data, say yt, shown in Figure 1.1, let xt = log(yt). In this problem, we are going
to fit a special type of structural model, xt = Tt + St +Nt where Tt is a trend component, St is a seasonal
component, and Nt is noise. In our case, time t is in quarters (1960.00, 1960.25, . . . ) so one unit of time
is a year.
part a
Fit the regression model
xt = βt︸︷︷︸
trend
+α1Q1(t) + α2Q2(t) + α3Q3(t) + α4Q4(t)︸ ︷︷ ︸
seasonal
+ wt︸︷︷︸
noise
where Qi(t) = 1 if time t corresponds to quarter i = 1, 2, 3, 4, and zero otherwise. The Qi(t)‘s are called
indicator variables. We will assume for now that wt is a Gaussian white noise sequence.
library(astsa)
## Warning: package ’astsa’ was built under R version 3.5.3
trend = time(jj)
Q = factor(cycle(jj) ) # make (Q)uarter factors
reg1 = lm(log(jj)~0 + trend + Q, na.action=NULL) # no intercept
summary(reg1)
##
## Call:
## lm(formula = log(jj) ~ 0 + trend + Q, na.action = NULL)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.29318 -0.09062 -0.01180 0.08460 0.27644
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## trend 1.672e-01 2.259e-03 74.00 <2e-16 ***
## Q1 -3.283e+02 4.451e+00 -73.76 <2e-16 ***
## Q2 -3.282e+02 4.451e+00 -73.75 <2e-16 ***
## Q3 -3.282e+02 4.452e+00 -73.72 <2e-16 ***
## Q4 -3.284e+02 4.452e+00 -73.77 <2e-16 ***
## ---
## Signif. codes: 0 ’***’ 0.001 ’**’ 0.01 ’*’ 0.05 ’.’ 0.1 ’ ’ 1
##
## Residual standard error: 0.1254 on 79 degrees of freedom
## Multiple R-squared: 0.9935, Adjusted R-squared: 0.9931
## F-statistic: 2407 on 5 and 79 DF, p-value: < 2.2e-16
1
part b
The estimated average annual increase in the logged earnings per share is βˆ, which can be extracted from
the sumamry table above, i.e., βˆ = 0.167172
part c
If the model is correct, average logged earnings rate change from the third quarter to the fourth quarter is
0.25βˆ + αˆ4 − αˆ3 = −0.226965. Therefore, the everage log earnings rate decreases from the third quarter to
the fourth quarter.
part d
It leads to the probelm of multicolliearity. In practice, if we include the intercept in R code as fowllowing:
reg2 = lm(log(jj)~ trend + Q, na.action=NULL) # including intercept
summary(reg2)
##
## Call:
## lm(formula = log(jj) ~ trend + Q, na.action = NULL)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.29318 -0.09062 -0.01180 0.08460 0.27644
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.283e+02 4.451e+00 -73.761 < 2e-16 ***
## trend 1.672e-01 2.259e-03 73.999 < 2e-16 ***
## Q2 2.812e-02 3.870e-02 0.727 0.4695
## Q3 9.823e-02 3.871e-02 2.538 0.0131 *
## Q4 -1.705e-01 3.873e-02 -4.403 3.31e-05 ***
## ---
## Signif. codes: 0 ’***’ 0.001 ’**’ 0.01 ’*’ 0.05 ’.’ 0.1 ’ ’ 1
##
## Residual standard error: 0.1254 on 79 degrees of freedom
## Multiple R-squared: 0.9859, Adjusted R-squared: 0.9852
## F-statistic: 1379 on 4 and 79 DF, p-value: < 2.2e-16
Having an intercept here takes away the first quarter effect, and the intercept apperas in all quarters, this
does not make sense since we want to study the effect of each quarter seperately.
part e
Graph the data, xt, and superimpose the fitted values, say xˆt, on the graph. Examine the residuals, xt− xˆt,
and state your conclusions. Does it appear that the model fits the data well (do the residuals look white)?
par(mfrow=c(1,2))
plot(log(jj), main="plot of data and fitted value") # data
lines(fitted(reg1), col="red") # fitted
plot(log(jj)-fitted(reg1), main="plot of residuals")
2
plot of data and fitted value
Time
lo
g(j
j)
1960 1970 1980
0
1
2
plot of residuals
Time
lo
g(j
j) −
fit
ted
(re
g1
)
1960 1970 1980

0.
3

0.
1
0.
0
0.
1
0.
2
acf(log(jj)-fitted(reg1))
3
0 1 2 3 4

0.
2
0.
2
0.
4
0.
6
0.
8
1.
0
Lag
AC
F
Series log(jj) − fitted(reg1)
Residuals do not look like a sample from a white noise process. We need to fit an appropriate model to the
residuals to explain the dependencies among them.
Problem 2
varve_more = cbind(x = astsa::varve,
logx = log(astsa::varve),
difflogx = diff(log(astsa::varve)))
plot(varve_more)
4
0
50
10
0
15
0
x
2
3
4
5
lo
gx

1
0
1
0 100 200 300 400 500 600
di
ffl
og
x
Time
varve_more
part a
The variance in the second half of the varve series is obviously larger than that in the first half. Dividing the
data in half gives γˆ(0) = 133 for the first part and γˆ(0) = 594 for the second part. Note that, the variance
is about 4.5 times as large in the second half. The transformed series yt = ln(xt) has γˆ(0) = .27 .45 for the
two halves, respectively and the variance of the second half is only about 1.7 times as large. Histograms,
computed for the two series indicate that the transformation improves the normal approximation.
par(mfrow=c(1,2))
hist(varve)
hist(log(varve))
5
Histogram of varve
varve
Fr
eq
ue
nc
y
0 50 100 150
0
50
10
0
15
0
20
0
25
0
Histogram of log(varve)
log(varve)
Fr
eq
ue
nc
y
1 2 3 4 5
0
50
10
0
15
0
20
0
Yt = logXt has bell-shape histogram and a better straight line fit of Q-Q plot in normal distribution.
part (b)
The data between 300 and 450 show a positive trend that is similar to the global temperature data.
part (c)
acf(log(astsa::varve))
6
0 5 10 15 20 25
0.
0
0.
2
0.
4
0.
6
0.
8
1.
0
Lag
AC
F
Series log(astsa::varve)
The ACF of the yt is positive for a large number of lags and decreases in a linear fashion.
part (d)
The plot of Ut and its ACF seem to indicate stationarity. There is not apparent trend or heteroscedasticity
in the data and The ACF has one significant value at lag 1.
par(mfrow=c(2,1))
tsplot(diff(log(astsa::varve)), ylab = "U_t")
acf(diff(log(astsa::varve)))
7
Time
U_
t
0 100 200 300 400 500 600

1
0
1
0 5 10 15 20 25

0.
4
0.
2
0.
6
1.
0
Lag
AC
F
Series diff(log(astsa::varve))
Problem 3
Let (xt : t ∈ Z) be such that xt = b0 + b1t+ wt, where (wt : t ∈ Z) ∼WN(0, σ2). Then
vt = (xt−1 + xt + xt+1)/3
= 13[b0 + b1(t− 1) + wt−1 + b0 + b1t+ wt + b0 + b1(t+ 1) + wt+1]
= b0 + b1t+
1
3[wt−1 + wt + wt+1]
Therefore, E[vt] = b0 + b1t+ E[ 13 [wt−1 + wt + wt+1]] = b0 + b1t.
Problem 4
part (a)
Since E[Xt] = b0 + b1t+ b2t2, it is not a stationary process.
8
part (b)
∇Xt = (b0 + b1t+ b2t2 + Yt)− (b0 + b1(t− 1) + b2(t− 1)2 + Yt−1)
= b1 + b2t2 − b2(t− 1)2 + Yt − Yt−1
= b1 + b2t2 − b2(t2 − 2t+ 1) + Yt − Yt−1
= b1 + b2(2t− 1) + Yt − Yt−1
E[∇Xt] = b1 + b2(2t− 1), thus ∇Xt is not stationary.
part (c)
∇2Xt = b1 + b2(2t− 1)− b1 − (b2(2(t− 1)− 1)) +∇2Yt
= b2(2t− 1)− (b2(2t− 3)) +∇2Yt
= 2b2 +∇2Yt
E[∇Xt] = 2b2 and
Cov(Xt+h, Xt) =

6γY (0), h = 0
−4γY (0), |h| = 1
γY (0), |h| = 2
0, otherwise
Thus ∇2Xt is stationary and the minimum value k is 2.
Problem 5
part (a)
∇3Xt = (1−B)3Xt = (1− 3B + 3B2 −B3)Xt = Xt − 3Xt−1 + 3Xt−2 −Xt−3.
part (b)
Note that
(1 + .5B)
(1− .5B) = (1+.5B)(1+.5B+.5
2B2+.53B3+. . . ) = 1+(.5+.5)B+(.52+.52)B2+(.53+.53)B3+· · · = 1+2
∞∑
k=1
.5kBk.
Therefore,
(1 + .5B)
(1− .5B)Xt = Xt + (2)
∞∑
k=1
.5kXt−k.
9







































































































































































































































































































学霸联盟


essay、essay代写