# Tietokoneharjoitus 2

Data sisaltaa 2 muuttujaa:

RealGDP: Quarterly values of Real GDP for the United States in Billions of Chained (2000) Dollars Seasonally Adjusted, Annual Rate.

TBillRate: Quarterly values of the rate on 3-month Treasury Bills. Quaterterly averages of daily rates in percentage points at an annual rate.

## Datan lukeminen R:aan

```file<-"http://cc.oulu.fi/~jklemela/econometrics/USMacro_Quarterly.csv"
```

## Datan lukeminen SAS:iin

```FILENAME myurl URL 'http://cc.oulu.fi/~jklemela/econometrics/USMacro_Quarterly.txt';

DATA USmacro;
INFILE myurl firstobs=2;
INPUT time \$ gdpq tbill;
RUN;

```

## Tehtävä 5

Olkoon Y(t) = log(RealGDP(t)) - log(RealGDP(t-1)) ja X(t) = TbillRate(t) - TbillRate(t-1)

Sovitetaan malli Y(t) = beta1 +beta2*X(t-1) + epsilon ja suoritetaan OLS-regressio. Luettele kertoimien pienimman neliosumman estimaatit. Suorita t-testit ja F-testi.

```file<-"http://cc.oulu.fi/~jklemela/econometrics/USMacro_Quarterly.csv"

gdp<-data[,2]
r<-data[,3]
n<-length(r)

y0<-log(gdp[2:n])-log(gdp[1:(n-1)])
plot(y0,type="l")

x0<-r[2:n]-r[1:(n-1)]
plot(x0,type="l")

T<-length(x0)

y<-y0[2:T]
x<-x0[1:(T-1)]

plot(x,y)

reg.model<-lm(y ~ x)

summary(reg.model)

plot(reg.model)

```

```Call:
lm(formula = y ~ x)

Residuals:
Min        1Q    Median        3Q       Max
-0.035938 -0.005788  0.000078  0.005344  0.031697

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.0084572  0.0006541  12.929   <2e-16 ***
x           0.0017816  0.0009083   1.961    0.051 .
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.00992 on 228 degrees of freedom
Multiple R-squared: 0.01659,	Adjusted R-squared: 0.01228
F-statistic: 3.847 on 1 and 228 DF,  p-value: 0.05104

```
Ilman vakiotermia:
```reg.model<-lm(y ~ 0+x)

summary(reg.model)

plot(reg.model)

Call:
lm(formula = y ~ 0 + x)

Residuals:
Min        1Q    Median        3Q       Max
-0.027477  0.002648  0.008503  0.013781  0.040151

Coefficients:
Estimate Std. Error t value Pr(>|t|)
x 0.001860   0.001193   1.559     0.12

Residual standard error: 0.01303 on 229 degrees of freedom
Multiple R-squared: 0.0105,	Adjusted R-squared: 0.006184
F-statistic: 2.431 on 1 and 229 DF,  p-value: 0.1203

```

Kokeillaan SAS:ia.

```
FILENAME myurl URL 'http://cc.oulu.fi/~jklemela/econometrics/USMacro_Quarterly.txt';
DATA USmacro;
INFILE myurl firstobs=2;
INPUT time \$ gdpq tbill;
loggdpq = log(gdpq);
y = loggdpq - lag1(loggdpq);
x0 = tbill - lag1(tbill);
x = lag1(x0);
RUN;

proc reg data = USmacro;
model y = x;
run;

proc reg data = USmacro;
model y = x / noint;
run;

```