Professional Documents
Culture Documents
User: Assignment 2
Notes:
1. Unicode is supported; see help unicode_advice .
name: <unnamed>
log: C:\Users\21964\Desktop\LOGF.smcl
log type: smcl
opened on: 28 Sep 2017, 16:55:30
2 . doedit~
3 . do "C:\Users\21964\AppData\Local\Temp\STD00000000.tmp"
4 . * Assignment 2
5 .
6 . *Ins Patrcio, 22225
7 . *Joo Berberan, 30296
8 . *Jos Paula, 23805
9 . *Matilde Aires Mateus, 21964
10 . *Pedro Pinto Coelho, 20220
11 .
12 .
13 . clear all
14 .
15 . import excel "C:\Users\21964\Desktop\exxonmobil.xlsx", sheet("Worksheet") fir
> strow
16 .
17 . * Exercise 1
18 .
19 . * a)
20 .
21 . summarize // The mean of usunemployment is 6,17
22 . * or
23 .
24 . mean usunemployment // The mean of usunemplyment is 6,17
25 .
26 . * b)
27 .
28 . summarize // The maximum value of eurusdfx is 1,5809 and the minimum value of
> that variable is 0,8473
29 .
30 . * c)
31 .
32 . list // The 25th observation for the following variables is: xom=60,86; sp500=
> 1294,83; ustbill10y=4,8472; oilprice=73,93.
33 .
34 . * ----------------------------------------------------------------------------
> --------------------------------------------
35 .
36 . * Exercise 2
37 .
38 . * a)
39 .
40 . gen logxom = log(xom)
44 .
45 . * Making log transformations on the variables is a possible way of manipulatin
> g the data in order to make it more normally distributed (mitigates skewness o
> f variables).
46 .
47 . * b)
48 .
49 . tsset date // declare data to be time series
time variable: date, 3/31/2000 to 6/30/2017, but with gaps
delta: 1 day
50 .
51 . gen date2=yq(year,quarter) // quarterly data
52 .
53 . format date2 %tq
54 .
55 . drop date
Assigment 2 Thursday September 28 16:56:28 2017 Page 11
57 .
58 . line logusgdp date // plotting logusgdp overtime // Annex 1
59 .
60 . * ----------------------------------------------------------------------------
> --------------------------------------------
61 .
62 . * Exercise 3
63 .
64 . * a)
65 .
66 . correlate logxom logsp500 logusgdp loguscpi usunemployment ustbill10y eurusdfx
> oilprice
(obs=70)
logxom 1.0000
logsp500 0.6429 1.0000
logusgdp 0.9007 0.7104 1.0000
loguscpi 0.9079 0.6568 0.9899 1.0000
usunemploy~t 0.2613 -0.2999 0.2703 0.3767 1.0000
ustbill10y -0.6495 -0.4200 -0.8277 -0.8511 -0.4528 1.0000
eurusdfx 0.6162 -0.0397 0.4579 0.4969 0.5119 -0.3151 1.0000
oilprice 0.7486 0.2018 0.5614 0.6266 0.5074 -0.3882 0.8103
oilprice
oilprice 1.0000
67 .
68 . * This matrix provides the correlations between each two variables. Looking at
> variables loguscpi and logusgdp, we can observe that they have a strong posit
> ive correlation (0,9899), thus, movements of logusgdp will usually be followed
> by movements of loguscpi in the same direction.
69 . * Although we cannot state that these variables drive each other, historically
> , we can observe that periods characterized by a higher GDP usually make the c
> ost of living, measured by CPI, higher.
70 . * Considering the variables logxom and ustbill10y, one can see that there is
> a negative correlation (-o,6495), meaning that these variables will usually mo
> ve in opposite directions.
71 . * In theory, this is a reasonable behaviour, given that as treasury bills' yie
> lds icnrease, we will usually observe a departure from investment in stocks to
> wards investment in bonds, which will decrease the price of stocks overall.
72 . * b)
73 .
74 . scatter logxom logsp500 // Annex 2
75 .
76 . * Scatter plots are useful data visualization tools for illustrating a trend.
77 . * Besides showing the extent of correlation, a scatter plot shows the sense of
> the correlation: If logxom (or y-axis) increases as logsp500(or x-axis) incre
> ases, the correlation is positive, as seen in the matrix above (0,6429).
78 .
79 . * c)
80 .
81 . reg logxom logsp500 logusgdp usunemployment loguscpi ustbill10y eurusdfx oilpr
> ice
82 .
83 . * Looking at the p-values, we can conclude that only usunemployment, loguscpi
> and eurusdfx are statistically significant variables.
84 .
85 . * usunemployment: if usunemployment increases by 1 unit, logxom decreases by 3
> ,55467%, on average, ceteris paribus.
86 .
87 . * loguscpi: if loguscpi increases by 1%, logxom increases by 3,815626%, on ave
> rage, ceteris paribus.
88 .
89 . * eurusdfx: if eurusdfx increases by 1 unit, logxom increases by 33,25805%, on
> average, ceteris paribus.
90 .
91 . * ----------------------------------------------------------------------------
> --------------------------------------------
92 .
93 . * Exercise 4
94 .
95 . * a)
96 .
97 . test logusgdp // The F-statistic is 0,56.
( 1) logusgdp = 0
F( 1, 62) = 0.56
Prob > F = 0.4561
98 .
99 . * b)
100 .
101 . * We know that F stat=(t stat)^2 , hence tstat= sqroot (0,56)
102 .
103 . display 0.56^0.5
.74833148
104 .
105 . * tstat=0,74833148
106 . * Using a 5% level of significance, we fail to reject the null once 0,748<1,96
> (critical value of a standar normal distribution), which means the variable i
> s not statistically significant.
107 .
108 . * ----------------------------------------------------------------------------
> --------------------------------------------
109 .
110 . * Exercise 5
111 .
112 . * H0: Beta(eurusdfx)=25
Assigment 2 Thursday September 28 16:56:28 2017 Page 13
( 1) eurusdfx = 25
F( 1, 62) = 25214.97
Prob > F = 0.0000
116 .
117 . * Once the p-value is 0,0000 we reject the null that the coefficient on eurusd
> fx is not equal to 25.
118 .
119 . * b)
120 .
121 . * H0: Beta(cons)=0
122 . * Ha: Beta(cons) 0 (two-sided)
123 .
124 . test _cons
( 1) _cons = 0
F( 1, 62) = 31.93
Prob > F = 0.0000
125 .
126 . * Once the p-value is 0,0000 we reject the null and conclude that the constant
> term is statistically significant.
127 .
128 . * c)
129 .
130 . * H0: Beta(usunemployment)=-2*Beta(loguscpi)=-7,631252
131 . * Ha: Beta(usunemployment) -2*Beta(loguscpi) -7,631252
132 .
133 . test usunemployment=-7.631252
( 1) usunemployment = -7.631252
F( 1, 62) = 2.3e+05
Prob > F = 0.0000
134 .
135 . * Once the p-value is 0,0000 we reject the null and conclude that the coeffici
> ent on usunemploymeny is not equal to -2 times the coefficient on loguscpi.
136 .
137 . * d)
138 .
139 . * H0: Beta(usunemployment)=-1
140 . * Ha: Beta(usunemployment) -1
141 .
142 . test usunemployment=-1
( 1) usunemployment = -1
F( 1, 62) = 3683.74
Prob > F = 0.0000
143 .
144 . * Once the p-value is 0,0000 we reject the null and conclude that the coeffici
> ent on usunemploymeny is not equal to -1.
Assigment 2 Thursday September 28 16:56:28 2017 Page 14
145 .
146 . * H0: Beta(loguscpi)=4
147 . * Ha: Beta(loguscpi) 4
148 .
149 . test loguscpi=4
( 1) loguscpi = 4
F( 1, 62) = 0.01
Prob > F = 0.9195
150 .
151 . * Once the p-value is 0,9195 we fail to reject the null and conclude that the
> coefficient on usunemploymeny is not different than 4.
152 .
153 . * e)
154 .
155 . test logsp500 logusgdp usunemployment loguscpi ustbill10y eurusdfx oilprice
( 1) logsp500 = 0
( 2) logusgdp = 0
( 3) usunemployment = 0
( 4) loguscpi = 0
( 5) ustbill10y = 0
( 6) eurusdfx = 0
( 7) oilprice = 0
F( 7, 62) = 110.39
Prob > F = 0.0000
156 .
157 . * Once the p-value is 0,0000 we reject the null and conclude that the model is
> overall statistically significant.
158 .
159 . * ----------------------------------------------------------------------------
> --------------------------------------------
160 .
161 . * Exercise 6
162 .
163 . * a)
164 .
165 . reg logxom logsp500 logusgdp loguscpi usunemployment ustbill10y eurusdfx oilpr
> ice
166 .
167 . // In order to test for Heteroskedasticity, we will perform a White test:
168 .
169 . * H0: Homoskedasticity
170 . * Ha: No homoskedasticity
171 .
172 . estat imtest, white
Source chi2 df p
173 .
174 . * LM=56,13
175 . * Once the approximate critical value of a Chi-square distribution with 35 deg
> rees of freedom is equal to 24,825, we reject the null and conclude that there
> is evidence that the residuals are heteroscedastic.
176 .
177 . // In order to test for Autocorrelation, we will perform a Breusch-Godfrey:
178 .
179 . * H0: No autocorrelation
180 . * Ha: Autocorrelation
181 .
182 . * Since we have quarterly data, we will include 4 lags.
183 .
184 . estat bgodfrey, lags(1 2 3 4)
1 21.753 1 0.0000
2 23.449 2 0.0000
3 23.451 3 0.0000
4 23.495 4 0.0001
185 .
186 . * Once the p-values are lower than the level of significance, we reject the nu
> ll and conclude that there is a problem of autocorrelation.
187 .
188 . * b)
189 .
190 . predict e if e(sample), resid
Assigment 2 Thursday September 28 16:56:28 2017 Page 16
191 .
192 . scatter e logsp500, yline(0)
198 .
199 .
200 . * We plotted the residuals against the independent variables // Annex 3
201 . * Looking at the plot with residuals on the vertical axis and usunemployment o
> n horizontal axis (Annex 3.3), we can observe that the points are at widely va
> rying distances from the line (this line represents the assumption that the ex
> pected mean of the residuals is zero), therefore, the non-existence of a clear
> pattern leads us to believe that there is heteroskedasticity.
202 .
203 .
204 . * c)
205 .
206 . // In order to mitigate the problem of heteroskedasticity we could use robust
> standard errors.
207 .
208 . // In order to mitigate the problem of autocorrelation, we could include lags
> of the dependent variable.
209 .
210 . gen logxomt1=L.logxom // generating one lag of logxom (logxom(t-1))
(1 missing value generated)
211 .
212 . reg logxom logsp500 logusgdp loguscpi usunemployment ustbill10y eurusdfx oilp
> rice logxomt1, robust
Robust
logxom Coef. Std. Err. t P>|t| [95% Conf. Interval]
213 .
Assigment 2 Thursday September 28 16:56:28 2017 Page 17
224 .