forked from mca91/EconometricsWithR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex10_2.html
106 lines (81 loc) · 3.04 KB
/
ex10_2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'/>
<script async='async' src='https://cdn.datacamp.com/dcl-react-dev.js.gz'></script>
<style>
.DCexercise .datacamp-exercise {
border: 2px solid #3D678D;
border-radius: 10px 10px 10px 10px !important;
}
*[class*="lm_"], .ace_gutter, textarea[class*="ace_"], .ace_scroller {
background-color: #F0EFF0 !important;
}
div[class*="Editor-module__editor"], div[class*="dcl__Footer"] {
background-color: #3D678D !important;
}
*[class*="lm_"] {
border-radius: 10px 10px 0px 0px !important;
}
div[class*="dcl__Footer"] {
border-radius: 0px 0px 10px 10px !important;
}
.lm_content {
border-radius: 0px !important;
}
.lm_splitter {
background-color: #3D678D !important;
width: 3px !important;
}
.lm_drag_handle {
background: transparent !important;
}
div[class*="dcl__index-module"] {
outline-color: transparent !important;
border-radius: 10px !important;
}
button[class*="secondary-light"] {
background-color: #FF0000;
}
</style>
</head>
<body>
<div data-datacamp-exercise data-lang="r">
<code data-type="pre-exercise-code">
library(AER)
library(plm)
data(Guns)
model <- plm(log(violent) ~ law, data = Guns, index = c("state", "year"), model = "pooling")
</code>
<code data-type="sample-code">
# estimate a model with state fixed effects using plm()
model_se <-
# print a summary using robust standard errors
# test whether the state fixed effects are jointly significant from zero
</code>
<code data-type="solution">
# estimate a model with state fixed effects using plm()
model_se <- plm(log(violent) ~ law, data = Guns, index = c("state", "year"), model = "within")
# print a summary using robust standard errors
coeftest(model_se, vcov. = vcovHC, type = "HC1")
# test whether the state fixed effects are jointly significant from zero
pFtest(model_se, model)
</code>
<code data-type="sct">
ex() %>% check_function("plm") %>% {
check_arg(., "formula") %>% check_equal()
check_arg(., "data") %>% check_equal()
check_arg(., "index") %>% check_equal()
check_arg(., "model") %>% check_equal()
}
test_function("coeftest", args="x")
test_student_typed("vcov. = vcovHC")
ex() %>% check_function("pFtest") %>% {
check_arg(., "x") %>% check_equal()
check_arg(., "z") %>% check_equal()
}
success_msg("Correct! Incorporating state fixed effects control for state specific unobservable omitted variables which do not vary over time (e.g. the residents attitude towards guns). Note that Including fixed effects changes both the sign and the magnitude of the estimated coefficient. The F-test reveals that the state fixed effects are jointly significantly different from zero. There is the possibility of an omitted variable bias, e.g., due to omitted variables that change over time.")
</code>
</div>
</body>
</html>