Zeitreihenanalyse - Aufgabe 2

From StatWiki
Jump to: navigation, search

Exercise 1

Show that 
\begin{pmatrix}
p & r \\
s & q 
\end{pmatrix}^{-1} = 
\frac{1}{pq - rs} 
\begin{pmatrix}
q & -r \\
-s & p 
\end{pmatrix} 
\,

 A \cdot A^{-1} = E \,


\begin{align}
E 
& = 
\begin{pmatrix}
p & r \\
s & q 
\end{pmatrix}

\begin{pmatrix}
p & r \\
s & q 
\end{pmatrix}^{-1}
\\
& = 
\begin{pmatrix}
p & r \\
s & q 
\end{pmatrix}

\frac{1}{pq - rs} 
\begin{pmatrix}
q & -r \\
-s & p 
\end{pmatrix} 

\\
&= 
\frac{1}{pq - rs} 
\begin{pmatrix}
pq - rs & -rp + rp \\
qs-qs & -rs + pq
\end{pmatrix} 

\\
&= 
\begin{pmatrix}
\frac{pq - rs}{pq - rs} & 0 \\
0 & \frac{pq - rs}{pq - rs}
\end{pmatrix} 
\\
&= E

\end{align}
 \,


Exercise 2

Use the fact that X^T X\, is a 2×2 matrix to show that

\hat \beta = \begin{pmatrix} \hat a \\ \hat b \end{pmatrix} = (X^T X)^{-1} X^T y \,
\hat \beta = \begin{pmatrix} \hat a \\ \hat b \end{pmatrix} = \begin{pmatrix} \bar y - \hat b \bar t \\ 
\frac{\frac 1 n \sum_{t=1}^n y_t t - \bar y \bar t}{\frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2}  \end{pmatrix}
X = \begin{pmatrix} 
1 & 1 \\ 
1 & 2 \\
\vdots & \vdots \\
1 & n
\end{pmatrix}


X^T X = 
\begin{pmatrix} 
n & \sum_{t=1}^n t \\
\sum_{t=1}^n t & \sum_{t=1}^n t^2
\end{pmatrix} =
n
\begin{pmatrix} 
1 & \bar t \\
\bar t & \frac 1 n \sum_{t=1}^n t^2
\end{pmatrix}
 

(X^T X)^{-1} = 
\frac 1 n \frac{1}{\frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2}
\begin{pmatrix} 
\frac 1 n \sum_{t=1}^n t^2 & -\bar t \\
-\bar t & 1
\end{pmatrix}


X^T y = \begin{pmatrix} \sum_{t=1}^n y_t \\ \sum_{t=1}^n y_t t \end{pmatrix} = n \begin{pmatrix} \bar y  \\ \frac 1 n \sum_{t=1}^n y_t t \end{pmatrix}

 \begin{align}
(X^T X)^{-1} X^T y
& = \frac 1 n \frac{1}{\frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2}
\begin{pmatrix} 
\frac 1 n \sum_{t=1}^n t^2 & -\bar t \\
-\bar t & 1
\end{pmatrix}
n \begin{pmatrix} \bar y  \\ \frac 1 n \sum_{t=1}^n y_t t \end{pmatrix} \\

& = \begin{pmatrix}
\frac{\bar y \frac 1 n \sum_{t=1}^n t^2 - \bar t \frac 1 n \sum_{t=1}^n y_t t}
{\frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2} \\
\frac{\frac 1 n \sum_{t=1}^n y_t t - \bar y \bar t}
{\frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2}
\end{pmatrix} \\

& =

\begin{pmatrix}
\frac{\bar y \frac 1 n \sum_{t=1}^n t^2}
{\frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2}
-
\hat b \bar t 
- \bar t \frac{\bar y \bar t}
{\frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2} \\

\frac{\frac 1 n \sum_{t=1}^n y_t t - \bar y \bar t}
{\frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2}
\end{pmatrix} \\

& =

\begin{pmatrix}
\frac{\bar y \frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2 \bar y}
{\frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2}
-
\hat b \bar t \\

\frac{\frac 1 n \sum_{t=1}^n y_t t - \bar y \bar t}
{\frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2}
\end{pmatrix} \\

& =

\begin{pmatrix}
\frac{\bar y \left(\frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2 \right) }
{\frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2}
-
\hat b \bar t \\

\frac{\frac 1 n \sum_{t=1}^n y_t t - \bar y \bar t}
{\frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2}
\end{pmatrix} \\

& =

\begin{pmatrix}
\bar y - \hat b \bar t \\
\frac{\frac 1 n \sum_{t=1}^n y_t t - \bar y \bar t}
{\frac 1 n \sum_{t=1}^n t^2 - \bar{t}^2}
\end{pmatrix}

\end{align}

Exercise 3

> pdf(rpdf)
> gdpa=readdataSK("GDPA.csv", "csv")
> gdpa=data.frame(year=as.numeric(substr(gdpa$DATE,1,4)), gdp=gdpa$VALUE)
> gdpa=subset(gdpa, year>=1946)
>
> plot(gdp~year, data=gdpa)
> pdf(rpdf)
> gdpa=readdataSK("GDPA.csv", "csv")
> gdpa=data.frame(year=as.numeric(substr(gdpa$DATE,1,4)), gdp=gdpa$VALUE)
> gdpa=subset(gdpa, year>=1946)
>
> plot(log(gdp)~year, data=gdpa)
> pdf(rpdf)
> gdpa=readdataSK("GDPA.csv", "csv")
> gdpa=data.frame(year=as.numeric(substr(gdpa$DATE,1,4)), gdp=gdpa$VALUE)
> gdpa=subset(gdpa, year>=1946)
>
> plot(log(gdp)~year, data=gdpa)
>
> lines(gdpa$year, fitted(lm(log(gdp)~year+I(year>1972),data=gdpa)))