library(AER)
library(plm)
data(Guns)
model <- plm(log(violent) ~ law, data = Guns, index = c("state", "year"), model = "pooling")
model_fe <- plm(log(violent) ~ law, data = Guns, index = c("state", "year"), model = "within")
# estimate a model with state and time fixed effects using plm()
model_sete <-
# print a summary using robust standard errors
# test whether state and time fixed effects are jointly significant from zero
# estimate a model with state and time fixed effects using plm()
model_sete <- plm(log(violent) ~ law, data = Guns, index = c("state", "year"), model = "within", effect = "twoways")
# print a summary using robust standard errors
coeftest(model_sete, vcov. = vcovHC, type = "HC1")
# test whether state and time fixed effects are jointly significant from zero
pFtest(model_sete, model)
ex() %>% check_function("plm") %>% {
check_arg(., "formula") %>% check_equal()
check_arg(., "data") %>% check_equal()
check_arg(., "index") %>% check_equal()
check_arg(., "model") %>% check_equal()
check_arg(., "effect") %>% 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! Including state and time effects results in a very small coefficient estimate which is not significantly different from zero at any common level. The F-test reveals that state and time fixed effects are jointly significantly different from zero.")