You are on page 1of 17

Assigment 2 Thursday September 28 16:56:28 2017 Page 1

___ ____ ____ ____ ____(R)


/__ / ____/ / ____/
___/ / /___/ / /___/
Statistics/Data Analysis

User: Assignment 2

___ ____ ____ ____ ____ (R)


/__ / ____/ / ____/
___/ / /___/ / /___/ 14.1 Copyright 1985-2015 StataCorp LP
Statistics/Data Analysis StataCorp
4905 Lakeway Drive
College Station, Texas 77845 USA
800-STATA-PC http://www.stata.com
979-696-4600 stata@stata.com
979-696-4601 (fax)

50-student Stata lab perpetual license:


Serial number: 301406216314
Licensed to: User
Nova SBE

Notes:
1. Unicode is supported; see help unicode_advice .

1 . log using "C:\Users\21964\Desktop\LOGF.smcl"

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

Variable Obs Mean Std. Dev. Min Max

date 70 17849.76 1858.439 14700 21000


xom 70 68.44114 20.56509 31.9 101.2
sp500 70 1408.247 403.8126 797.87 2423.41
usgdp 70 14474.98 2641.86 10031 19246.7
usunemploy~t 70 6.17 1.759887 3.9 9.9

uscpi 70 210.4879 22.8056 171 243.79


ustbill10y 70 3.498236 1.236061 1.4697 6.031
eurusdfx 70 1.22214 .1769119 .8473 1.5809
oilprice 70 62.772 28.25614 19.84 140
year 70 2008.257 5.092437 2000 2017

quarter 70 2.471429 1.125739 1 4


Assigment 2 Thursday September 28 16:56:28 2017 Page 2

22 . * or
23 .
24 . mean usunemployment // The mean of usunemplyment is 6,17

Mean estimation Number of obs = 70

Mean Std. Err. [95% Conf. Interval]

usunemployment 6.17 .2103468 5.75037 6.58963

25 .
26 . * b)
27 .
28 . summarize // The maximum value of eurusdfx is 1,5809 and the minimum value of
> that variable is 0,8473

Variable Obs Mean Std. Dev. Min Max

date 70 17849.76 1858.439 14700 21000


xom 70 68.44114 20.56509 31.9 101.2
sp500 70 1408.247 403.8126 797.87 2423.41
usgdp 70 14474.98 2641.86 10031 19246.7
usunemploy~t 70 6.17 1.759887 3.9 9.9

uscpi 70 210.4879 22.8056 171 243.79


ustbill10y 70 3.498236 1.236061 1.4697 6.031
eurusdfx 70 1.22214 .1769119 .8473 1.5809
oilprice 70 62.772 28.25614 19.84 140
year 70 2008.257 5.092437 2000 2017

quarter 70 2.471429 1.125739 1 4

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.

1. date xom sp500 usgdp usunem~t uscpi


3/31/2000 38.9912 1498.58 10031 4 171

ustb~10y eurusdfx oilprice year quarter


6.004 .9574 26.9 2000 1

2. date xom sp500 usgdp usunem~t uscpi


6/30/2000 39.2412 1454.6 10278.3 3.9 172.2

ustb~10y eurusdfx oilprice year quarter


6.031 .9553 32.5 2000 2

3. date xom sp500 usgdp usunem~t uscpi


9/29/2000 44.5427 1436.51 10357.4 4 173.6

ustb~10y eurusdfx oilprice year quarter


5.802 .8831 30.84 2000 3

4. date xom sp500 usgdp usunem~t uscpi


12/29/2000 43.459 1320.28 10472.3 3.9 174.6

ustb~10y eurusdfx oilprice year quarter


5.112 .9395 26.8 2000 4
Assigment 2 Thursday September 28 16:56:28 2017 Page 3

5. date xom sp500 usgdp usunem~t uscpi


3/30/2001 40.4909 1160.33 10508.1 4.2 176.1

ustb~10y eurusdfx oilprice year quarter


4.917 .8798 26.29 2001 1

6. date xom sp500 usgdp usunem~t uscpi


6/29/2001 43.675 1224.42 10638.4 4.4 177.7

ustb~10y eurusdfx oilprice year quarter


5.412 .8473 26.25 2001 2

7. date xom sp500 usgdp usunem~t uscpi


9/28/2001 39.4 1040.94 10639.5 4.8 178.1

ustb~10y eurusdfx oilprice year quarter


4.588 .9105 23.43 2001 3

8. date xom sp500 usgdp usunem~t uscpi


12/31/2001 39.3 1148.08 10701.3 5.5 177.4

ustb~10y eurusdfx oilprice year quarter


5.051 .8903 19.84 2001 4

9. date xom sp500 usgdp usunem~t uscpi


3/28/2002 43.83 1147.39 10834.4 5.7 178.5

ustb~10y eurusdfx oilprice year quarter


5.396 .8712 26.31 2002 1

10. date xom sp500 usgdp usunem~t uscpi


6/28/2002 40.92 989.81 10934.8 5.8 179.6

ustb~10y eurusdfx oilprice year quarter


4.7965 .9895 26.86 2002 2

11. date xom sp500 usgdp usunem~t uscpi


9/30/2002 31.9 815.28 11037.1 5.7 180.8

ustb~10y eurusdfx oilprice year quarter


3.5942 .9879 30.45 2002 3

12. date xom sp500 usgdp usunem~t uscpi


12/31/2002 34.94 879.82 11103.8 5.8 181.8

ustb~10y eurusdfx oilprice year quarter


3.816 1.0504 31.2 2002 4

13. date xom sp500 usgdp usunem~t uscpi


3/31/2003 34.95 848.18 11230.1 5.9 183.9

ustb~10y eurusdfx oilprice year quarter


3.796 1.0902 31.04 2003 1
Assigment 2 Thursday September 28 16:56:28 2017 Page 4

14. date xom sp500 usgdp usunem~t uscpi


6/30/2003 35.91 974.5 11370.7 6.2 183.1

ustb~10y eurusdfx oilprice year quarter


3.5133 1.1483 30.19 2003 2

15. date xom sp500 usgdp usunem~t uscpi


9/30/2003 36.6 995.97 11625.1 6.1 185.1

ustb~10y eurusdfx oilprice year quarter


3.9376 1.1667 29.2 2003 3

16. date xom sp500 usgdp usunem~t uscpi


12/31/2003 41 1111.92 11816.8 5.8 185.5

ustb~10y eurusdfx oilprice year quarter


4.2455 1.2564 32.52 2003 4

17. date xom sp500 usgdp usunem~t uscpi


3/31/2004 41.59 1126.21 11988.4 5.7 187.1

ustb~10y eurusdfx oilprice year quarter


3.8348 1.2295 35.76 2004 1

18. date xom sp500 usgdp usunem~t uscpi


6/30/2004 44.41 1140.84 12181.4 5.6 188.9

ustb~10y eurusdfx oilprice year quarter


4.5806 1.2169 37.05 2004 2

19. date xom sp500 usgdp usunem~t uscpi


9/30/2004 48.33 1114.58 12367.7 5.4 189.8

ustb~10y eurusdfx oilprice year quarter


4.1194 1.2428 49.64 2004 3

20. date xom sp500 usgdp usunem~t uscpi


12/31/2004 51.26 1211.92 12562.2 5.4 191.7

ustb~10y eurusdfx oilprice year quarter


4.2182 1.3556 43.45 2004 4

21. date xom sp500 usgdp usunem~t uscpi


3/31/2005 59.6 1180.59 12813.7 5.3 193.1

ustb~10y eurusdfx oilprice year quarter


4.4815 1.2968 55.4 2005 1

22. date xom sp500 usgdp usunem~t uscpi


6/30/2005 57.47 1191.33 12974.1 5.1 193.7

ustb~10y eurusdfx oilprice year quarter


3.913 1.2094 56.5 2005 2
Assigment 2 Thursday September 28 16:56:28 2017 Page 5

23. date xom sp500 usgdp usunem~t uscpi


9/30/2005 63.54 1228.81 13205.4 5 198.8

ustb~10y eurusdfx oilprice year quarter


4.324 1.203 66.24 2005 3

24. date xom sp500 usgdp usunem~t uscpi


12/30/2005 56.17 1248.29 13381.6 5 198.1

ustb~10y eurusdfx oilprice year quarter


4.3911 1.1833 61.04 2005 4

25. date xom sp500 usgdp usunem~t uscpi


3/31/2006 60.86 1294.83 13648.9 4.7 199.7

ustb~10y eurusdfx oilprice year quarter


4.8472 1.2139 66.63 2006 1

26. date xom sp500 usgdp usunem~t uscpi


6/30/2006 61.35 1270.2 13799.8 4.7 201.8

ustb~10y eurusdfx oilprice year quarter


5.1364 1.2785 73.93 2006 2

27. date xom sp500 usgdp usunem~t uscpi


9/29/2006 67.1 1335.85 13908.5 4.6 202.8

ustb~10y eurusdfx oilprice year quarter


4.6276 1.2686 62.91 2006 3

28. date xom sp500 usgdp usunem~t uscpi


12/29/2006 76.63 1418.3 14066.4 4.5 203.1

ustb~10y eurusdfx oilprice year quarter


4.7022 1.3189 61.05 2006 4

29. date xom sp500 usgdp usunem~t uscpi


3/30/2007 75.45 1420.86 14233.2 4.5 205.288

ustb~10y eurusdfx oilprice year quarter


4.6443 1.3371 65.87 2007 1

30. date xom sp500 usgdp usunem~t uscpi


6/29/2007 83.88 1503.35 14422.3 4.5 207.234

ustb~10y eurusdfx oilprice year quarter


5.0244 1.3538 70.68 2007 2

31. date xom sp500 usgdp usunem~t uscpi


9/28/2007 92.56 1526.75 14569.7 4.7 208.547

ustb~10y eurusdfx oilprice year quarter


4.5865 1.4235 81.66 2007 3
Assigment 2 Thursday September 28 16:56:28 2017 Page 6

32. date xom sp500 usgdp usunem~t uscpi


12/31/2007 93.69 1468.36 14685.3 4.8 211.445

ustb~10y eurusdfx oilprice year quarter


4.0232 1.4583 95.98 2007 4

33. date xom sp500 usgdp usunem~t uscpi


3/31/2008 84.58 1322.7 14668.4 5 213.448

ustb~10y eurusdfx oilprice year quarter


3.4096 1.5809 101.58 2008 1

34. date xom sp500 usgdp usunem~t uscpi


6/30/2008 88.13 1280 14813 5.3 217.463

ustb~10y eurusdfx oilprice year quarter


3.969 1.5736 140 2008 2

35. date xom sp500 usgdp usunem~t uscpi


9/30/2008 77.66 1166.36 14843 6 218.877

ustb~10y eurusdfx oilprice year quarter


3.8234 1.4066 100.64 2008 3

36. date xom sp500 usgdp usunem~t uscpi


12/31/2008 79.83 903.25 14549.9 6.9 211.398

ustb~10y eurusdfx oilprice year quarter


2.2123 1.3953 44.6 2008 4

37. date xom sp500 usgdp usunem~t uscpi


3/31/2009 68.1 797.87 14383.9 8.3 212.495

ustb~10y eurusdfx oilprice year quarter


2.6629 1.3229 49.66 2009 1

38. date xom sp500 usgdp usunem~t uscpi


6/30/2009 69.91 919.32 14340.4 9.3 214.79

ustb~10y eurusdfx oilprice year quarter


3.5326 1.405 69.89 2009 2

39. date xom sp500 usgdp usunem~t uscpi


9/30/2009 68.61 1057.08 14384.1 9.6 215.861

ustb~10y eurusdfx oilprice year quarter


3.3053 1.4643 70.61 2009 3

40. date xom sp500 usgdp usunem~t uscpi


12/31/2009 68.19 1115.1 14566.5 9.9 217.347

ustb~10y eurusdfx oilprice year quarter


3.8368 1.4331 79.36 2009 4
Assigment 2 Thursday September 28 16:56:28 2017 Page 7

41. date xom sp500 usgdp usunem~t uscpi


3/31/2010 66.98 1169.43 14681.1 9.8 217.353

ustb~10y eurusdfx oilprice year quarter


3.8257 1.3533 83.76 2010 1

42. date xom sp500 usgdp usunem~t uscpi


6/30/2010 57.07 1030.71 14888.6 9.7 217.199

ustb~10y eurusdfx oilprice year quarter


2.9311 1.2257 75.63 2010 2

43. date xom sp500 usgdp usunem~t uscpi


9/30/2010 61.79 1141.2 15057.7 9.5 218.275

ustb~10y eurusdfx oilprice year quarter


2.5098 1.362 79.97 2010 3

44. date xom sp500 usgdp usunem~t uscpi


12/31/2010 73.12 1257.64 15230.2 9.5 220.472

ustb~10y eurusdfx oilprice year quarter


3.2935 1.3366 91.38 2010 4

45. date xom sp500 usgdp usunem~t uscpi


3/31/2011 84.13 1325.83 15238.4 9 223.046

ustb~10y eurusdfx oilprice year quarter


3.4703 1.419 106.72 2011 1

46. date xom sp500 usgdp usunem~t uscpi


6/30/2011 81.38 1320.64 15460.9 9.1 224.806

ustb~10y eurusdfx oilprice year quarter


3.16 1.451 95.42 2011 2

47. date xom sp500 usgdp usunem~t uscpi


9/30/2011 72.63 1131.42 15587.1 9 226.597

ustb~10y eurusdfx oilprice year quarter


1.9154 1.3449 79.2 2011 3

48. date xom sp500 usgdp usunem~t uscpi


12/30/2011 84.76 1257.6 15785.3 8.7 227.223

ustb~10y eurusdfx oilprice year quarter


1.8762 1.296 98.83 2011 4

49. date xom sp500 usgdp usunem~t uscpi


3/30/2012 86.73 1408.47 15973.9 8.3 228.807

ustb~10y eurusdfx oilprice year quarter


2.2088 1.3332 103.02 2012 1
Assigment 2 Thursday September 28 16:56:28 2017 Page 8

50. date xom sp500 usgdp usunem~t uscpi


6/29/2012 85.57 1362.16 16121.9 8.2 228.524

ustb~10y eurusdfx oilprice year quarter


1.6449 1.2651 84.96 2012 2

51. date xom sp500 usgdp usunem~t uscpi


9/28/2012 91.45 1440.67 16227.9 8 231.015

ustb~10y eurusdfx oilprice year quarter


1.6335 1.2876 92.19 2012 3

52. date xom sp500 usgdp usunem~t uscpi


12/31/2012 86.55 1426.19 16297.3 7.8 231.221

ustb~10y eurusdfx oilprice year quarter


1.7574 1.3197 91.82 2012 4

53. date xom sp500 usgdp usunem~t uscpi


3/28/2013 90.11 1569.19 16475.4 7.7 232.299

ustb~10y eurusdfx oilprice year quarter


1.8486 1.2819 97.23 2013 1

54. date xom sp500 usgdp usunem~t uscpi


6/28/2013 90.35 1606.28 16541.4 7.5 232.374

ustb~10y eurusdfx oilprice year quarter


2.4857 1.3005 96.56 2013 2

55. date xom sp500 usgdp usunem~t uscpi


9/30/2013 86.04 1681.55 16749.3 7.3 233.632

ustb~10y eurusdfx oilprice year quarter


2.61 1.3531 102.33 2013 3

56. date xom sp500 usgdp usunem~t uscpi


12/31/2013 101.2 1848.36 16999.9 7 234.723

ustb~10y eurusdfx oilprice year quarter


3.0282 1.3789 98.42 2013 4

57. date xom sp500 usgdp usunem~t uscpi


3/31/2014 97.68 1872.34 17031.3 6.6 235.978

ustb~10y eurusdfx oilprice year quarter


2.718 1.3772 101.58 2014 1

58. date xom sp500 usgdp usunem~t uscpi


6/30/2014 100.68 1960.23 17320.9 6.2 237.029

ustb~10y eurusdfx oilprice year quarter


2.5304 1.369 105.37 2014 2
Assigment 2 Thursday September 28 16:56:28 2017 Page 9

59. date xom sp500 usgdp usunem~t uscpi


9/30/2014 94.05 1972.29 17622.3 6.1 237.486

ustb~10y eurusdfx oilprice year quarter


2.4888 1.2629 91.16 2014 3

60. date xom sp500 usgdp usunem~t uscpi


12/31/2014 92.45 2058.9 17735.9 5.7 236.29

ustb~10y eurusdfx oilprice year quarter


2.1712 1.21 53.27 2014 4

61. date xom sp500 usgdp usunem~t uscpi


3/31/2015 85 2067.89 17874.7 5.6 235.989

ustb~10y eurusdfx oilprice year quarter


1.9231 1.0728 47.6 2015 1

62. date xom sp500 usgdp usunem~t uscpi


6/30/2015 83.2 2063.11 18093.2 5.4 237.419

ustb~10y eurusdfx oilprice year quarter


2.3531 1.1153 59.47 2015 2

63. date xom sp500 usgdp usunem~t uscpi


9/30/2015 74.35 1920.03 18227.7 5.1 237.467

ustb~10y eurusdfx oilprice year quarter


2.0368 1.1182 45.09 2015 3

64. date xom sp500 usgdp usunem~t uscpi


12/31/2015 77.95 2043.94 18287.2 5 237.846

ustb~10y eurusdfx oilprice year quarter


2.2694 1.0866 37.04 2015 4

65. date xom sp500 usgdp usunem~t uscpi


3/31/2016 83.59 2059.74 18325.2 5 238.078

ustb~10y eurusdfx oilprice year quarter


1.7687 1.1381 38.34 2016 1

66. date xom sp500 usgdp usunem~t uscpi


6/30/2016 93.74 2098.86 18538 4.9 239.842

ustb~10y eurusdfx oilprice year quarter


1.4697 1.1073 48.33 2016 2

67. date xom sp500 usgdp usunem~t uscpi


9/30/2016 87.28 2168.27 18729.1 4.9 241.006

ustb~10y eurusdfx oilprice year quarter


1.5944 1.1228 48.24 2016 3
Assigment 2 Thursday September 28 16:56:28 2017 Page 10

68. date xom sp500 usgdp usunem~t uscpi


12/30/2016 90.26 2238.83 18905.5 4.7 242.821

ustb~10y eurusdfx oilprice year quarter


2.4443 1.0547 53.72 2016 4

69. date xom sp500 usgdp usunem~t uscpi


3/31/2017 82.01 2362.72 19057.7 4.7 243.752

ustb~10y eurusdfx oilprice year quarter


2.3874 1.0697 50.6 2017 1

70. date xom sp500 usgdp usunem~t uscpi


6/30/2017 80.73 2423.41 19246.7 4.4 243.79

ustb~10y eurusdfx oilprice year quarter


2.3037 1.1413 46.04 2017 2

33 .
34 . * ----------------------------------------------------------------------------
> --------------------------------------------
35 .
36 . * Exercise 2
37 .
38 . * a)
39 .
40 . gen logxom = log(xom)

41 . gen logsp500 = log(sp500)

42 . gen logusgdp = log(usgdp)

43 . gen loguscpi = log(uscpi)

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

56 . rename date2 date

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 logsp500 logusgdp loguscpi usunem~t ustb~10y eurusdfx

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

Source SS df MS Number of obs = 70


F(7, 62) = 110.39
Model 7.20853697 7 1.029791 Prob > F = 0.0000
Residual .578365483 62 .009328476 R-squared = 0.9257
Adj R-squared = 0.9173
Total 7.78690246 69 .112853659 Root MSE = .09658
Assigment 2 Thursday September 28 16:56:28 2017 Page 12

logxom Coef. Std. Err. t P>|t| [95% Conf. Interval]

logsp500 .1028391 .1153511 0.89 0.376 -.1277444 .3334226


logusgdp -.705858 .9412046 -0.75 0.456 -2.587299 1.175583
usunemploym~t -.0355467 .0158905 -2.24 0.029 -.0673113 -.0037821
loguscpi 3.815626 1.816277 2.10 0.040 .1849409 7.446312
ustbill10y .0463221 .0245868 1.88 0.064 -.0028262 .0954703
eurusdfx .3325805 .155344 2.14 0.036 .0220523 .6431087
oilprice .0022052 .0011368 1.94 0.057 -.0000673 .0044776
_cons -10.69337 1.892267 -5.65 0.000 -14.47596 -6.910784

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

113 . * Ha: Beta(eurusdfx) 25 (two-sided)


114 .
115 . test eurusdfx=25

( 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

Source SS df MS Number of obs = 70


F(7, 62) = 110.39
Model 7.20853697 7 1.029791 Prob > F = 0.0000
Residual .578365483 62 .009328476 R-squared = 0.9257
Adj R-squared = 0.9173
Total 7.78690246 69 .112853659 Root MSE = .09658

logxom Coef. Std. Err. t P>|t| [95% Conf. Interval]

logsp500 .1028391 .1153511 0.89 0.376 -.1277444 .3334226


logusgdp -.705858 .9412046 -0.75 0.456 -2.587299 1.175583
loguscpi 3.815626 1.816277 2.10 0.040 .1849409 7.446312
usunemploym~t -.0355467 .0158905 -2.24 0.029 -.0673113 -.0037821
ustbill10y .0463221 .0245868 1.88 0.064 -.0028262 .0954703
eurusdfx .3325805 .155344 2.14 0.036 .0220523 .6431087
oilprice .0022052 .0011368 1.94 0.057 -.0000673 .0044776
_cons -10.69337 1.892267 -5.65 0.000 -14.47596 -6.910784
Assigment 2 Thursday September 28 16:56:28 2017 Page 15

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

White's test for Ho: homoskedasticity


against Ha: unrestricted heteroskedasticity

chi2( 35) = 56.13


Prob > chi2 = 0.0132

Cameron & Trivedi's decomposition of IM-test

Source chi2 df p

Heteroskedasticity 56.13 35 0.0132


Skewness 15.45 7 0.0306
Kurtosis 0.00 1 0.9543

Total 71.58 43 0.0040

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)

Breusch-Godfrey LM test for autocorrelation

lags( p) chi2 df Prob > chi2

1 21.753 1 0.0000
2 23.449 2 0.0000
3 23.451 3 0.0000
4 23.495 4 0.0001

H0: no serial correlation

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)

193 . scatter e loguscpi, yline(0)

194 . scatter e usunemployment, yline(0)

195 . scatter e ustbill10y, yline(0)

196 . scatter e eurusdfx, yline(0)

197 . scatter e oilprice, 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

Linear regression Number of obs = 69


F(8, 60) = 239.92
Prob > F = 0.0000
R-squared = 0.9595
Root MSE = .07129

Robust
logxom Coef. Std. Err. t P>|t| [95% Conf. Interval]

logsp500 .2395408 .094489 2.54 0.014 .0505346 .4285469


logusgdp .5283849 .7640403 0.69 0.492 -.9999232 2.056693
loguscpi -.5968454 1.464436 -0.41 0.685 -3.526154 2.332464
usunemploym~t .0097865 .0130529 0.75 0.456 -.0163233 .0358962
ustbill10y .0150775 .0189327 0.80 0.429 -.0227934 .0529484
eurusdfx .2309423 .1423633 1.62 0.110 -.0538267 .5157113
oilprice .0011935 .000969 1.23 0.223 -.0007448 .0031319
logxomt1 .6289752 .0784066 8.02 0.000 .4721387 .7858117
_cons -2.505378 1.571261 -1.59 0.116 -5.648368 .6376117

213 .
Assigment 2 Thursday September 28 16:56:28 2017 Page 17

214 . * After correcting for heteroskedasticity and autocorrelation, we were able to


> make inference and concluded that variable logsp500 is statistically signific
> ant and variables usunemployment, loguscpi and eurusdfx are no longer statisti
> cally significant(considering a critical value of 1,96).
215 .
216 . * d)
217 .
218 . // If there is a problem of heretoskedasticity we will have inefficient estima
> tors and, tehreofre, we cannot make inference.
219 . // If there is a problem with autocorrelation, and considering this is a dynam
> ic model, we would have inconsistent estimators.
220 .
221 .
222 .
223 .
end of do-file

224 .

You might also like