xtscc
R 에서 Stata 명령이 제공하는 결과 를 패키지와 함께 복제하려고 plm
하지만 복제 목적으로 Stata에서도 plm 패키지의 데이터 세트를 사용하는 것과 동일한 표준 오류를 보는 데 문제가 있습니다.
# code to obtain dataset
library(lmtest)
library(car)
library(tidyverse)
data("Produc", package="plm")
write.dta(Produc,"test.dta")
내 목표는 Driscoll 및 Kraay 표준 오류로 양방향 고정 효과 패널 모델 추정을 실행하는 것입니다. Stata의 루틴은 다음과 같습니다.
use "test.dta", clear \\ to import data
** i declare the panel
xtset state year
* create the dummies for the time fixed effects
quietly tab year, gen(yeardum)
* run a two way fixed effect regression model with Driscoll and Kraay standard errors
xi: xtscc gsp pcap emp unemp yeardum*,fe
* results are the following
Coef. Std. Err. t P>|t| [95% Conf. Interval]
pcap | -.1769881 .265713 -0.67 0.515 -.7402745 .3862983
emp | 40.61522 2.238392 18.14 0.000 35.87004 45.3604
unemp | 23.59849 85.10647 0.28 0.785 -156.8192 204.0161
RI에서는 다음 루틴을 사용합니다.
# I declare the panel
Produc <- pdata.frame(Produc, index = c("state","year"), drop.index = FALSE)
# run a two way fixed effect model
femodel <- plm(gsp~pcap+emp+unemp, data=Produc,effect = "twoway",
index = c("iso3c","year"), model="within")
# compute Driscoll and Kraay standard errors using vcovSCC
coeftest(femodel, vcovSCC(femodel))
pcap -0.17699 0.25476 -0.6947 0.4874
emp 40.61522 2.14610 18.9252 <2e-16 ***
unemp 23.59849 81.59730 0.2892 0.7725
포인트 추정치는 Stata와 동일하지만 표준 오차는 다릅니다.
표준 오류에 대해 "잘못된"작은 샘플 조정을 사용하고 있는지 확인하기 위해 사용 가능한 모든 조정으로 coeftest를 실행했지만 어떤 것도 xtscc
.
library(purrr)
results <- map(c("HC0", "sss", "HC1", "HC2", "HC3", "HC4"),~coeftest(femodel, vcovSCC(femodel,type = .x)))
walk(results,print)
# none of the estimated standard errors is the same as xtscc
R에서 Stata의 결과를 복제 할 수있는 방법을 아는 사람이 있습니까?
plm
(2.3, https://r-forge.r-project.org/R/?group_id=406 참조 ) 의 개발 버전은 함수의 Stata 에서처럼 처리 된 인터셉트를 사용하여 내부 모델의 전체 모델을 반환 할 수 있습니다 within_intercept(., return.model = TRUE)
. 이를 통해 Stata의 사용자 제공 명령 결과를 정확하게 복제 할 수 있습니다 xtscc
.
xtscc
작동 하는 방법 은 양방향 FE 모델을 단방향 FE 모델 + 시간 차원에 대한 더미로 추정하는 것입니다. 따라서 다음과 plm
같이 복제 해 보겠습니다 .
data("Produc", package="plm")
Produc <- pdata.frame(Produc, index = c("state","year"), drop.index = FALSE)
femodel <- plm(gsp ~ pcap + emp + unemp + factor(year), data = Produc, model="within")
femodelint <- within_intercept(femodel, return.model = TRUE)
lmtest::coeftest(femodelint, vcov. = function(x) vcovSCC(x, type = "sss"))
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) -6547.68816 3427.47163 -1.9104 0.0564466 .
# pcap -0.17699 0.26571 -0.6661 0.5055481
# emp 40.61522 2.23839 18.1448 < 0.00000000000000022 ***
# unemp 23.59849 85.10647 0.2773 0.7816356
# [...]
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다