R - fixed effect of panel data analysis and robust standard errors
up vote
0
down vote
favorite
I am working with the panel data through plm
package in R. And now I am considering a fixed effect model of group (cities), time, and two ways of group and time, respectively. Because I detected heteroskedasticity through the Breusch-Pagan test, I compute robust standard errors.
I read a help ?vcovHC
, but I could not understand fully how to utilize coeftest
.
My current code is:
library(plm)
library(lmtest)
library(sandwich)
fem_city <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "individual")
fem_year <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "time")
fem_both <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "twoways")
coeftest(fem_city, vcovHC(fem_city, type = 'HC3', cluster = 'group')
coeftest(fem_year, vcovHC(fem_city, type = 'HC3', cluster = 'time')
In order to compute the robust standard errors, are codes of coeftest
appropriate? I am wondering that how to set the cluster
option for effect = 'individual
and effect = 'time'
each.
For example, I set coeftest
codes:
cluster = 'group'
in plm
of fem_city for effect = 'individual'
in coeftest
cluster = 'time'
in plm
of fem_year for effect = 'time'
in coeftest
Is this way appropriate?
And, how to compute the robust standard error for twoways of both city
and year
?
Thank you very much!
r plm standard-error robust
add a comment |
up vote
0
down vote
favorite
I am working with the panel data through plm
package in R. And now I am considering a fixed effect model of group (cities), time, and two ways of group and time, respectively. Because I detected heteroskedasticity through the Breusch-Pagan test, I compute robust standard errors.
I read a help ?vcovHC
, but I could not understand fully how to utilize coeftest
.
My current code is:
library(plm)
library(lmtest)
library(sandwich)
fem_city <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "individual")
fem_year <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "time")
fem_both <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "twoways")
coeftest(fem_city, vcovHC(fem_city, type = 'HC3', cluster = 'group')
coeftest(fem_year, vcovHC(fem_city, type = 'HC3', cluster = 'time')
In order to compute the robust standard errors, are codes of coeftest
appropriate? I am wondering that how to set the cluster
option for effect = 'individual
and effect = 'time'
each.
For example, I set coeftest
codes:
cluster = 'group'
in plm
of fem_city for effect = 'individual'
in coeftest
cluster = 'time'
in plm
of fem_year for effect = 'time'
in coeftest
Is this way appropriate?
And, how to compute the robust standard error for twoways of both city
and year
?
Thank you very much!
r plm standard-error robust
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am working with the panel data through plm
package in R. And now I am considering a fixed effect model of group (cities), time, and two ways of group and time, respectively. Because I detected heteroskedasticity through the Breusch-Pagan test, I compute robust standard errors.
I read a help ?vcovHC
, but I could not understand fully how to utilize coeftest
.
My current code is:
library(plm)
library(lmtest)
library(sandwich)
fem_city <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "individual")
fem_year <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "time")
fem_both <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "twoways")
coeftest(fem_city, vcovHC(fem_city, type = 'HC3', cluster = 'group')
coeftest(fem_year, vcovHC(fem_city, type = 'HC3', cluster = 'time')
In order to compute the robust standard errors, are codes of coeftest
appropriate? I am wondering that how to set the cluster
option for effect = 'individual
and effect = 'time'
each.
For example, I set coeftest
codes:
cluster = 'group'
in plm
of fem_city for effect = 'individual'
in coeftest
cluster = 'time'
in plm
of fem_year for effect = 'time'
in coeftest
Is this way appropriate?
And, how to compute the robust standard error for twoways of both city
and year
?
Thank you very much!
r plm standard-error robust
I am working with the panel data through plm
package in R. And now I am considering a fixed effect model of group (cities), time, and two ways of group and time, respectively. Because I detected heteroskedasticity through the Breusch-Pagan test, I compute robust standard errors.
I read a help ?vcovHC
, but I could not understand fully how to utilize coeftest
.
My current code is:
library(plm)
library(lmtest)
library(sandwich)
fem_city <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "individual")
fem_year <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "time")
fem_both <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "twoways")
coeftest(fem_city, vcovHC(fem_city, type = 'HC3', cluster = 'group')
coeftest(fem_year, vcovHC(fem_city, type = 'HC3', cluster = 'time')
In order to compute the robust standard errors, are codes of coeftest
appropriate? I am wondering that how to set the cluster
option for effect = 'individual
and effect = 'time'
each.
For example, I set coeftest
codes:
cluster = 'group'
in plm
of fem_city for effect = 'individual'
in coeftest
cluster = 'time'
in plm
of fem_year for effect = 'time'
in coeftest
Is this way appropriate?
And, how to compute the robust standard error for twoways of both city
and year
?
Thank you very much!
r plm standard-error robust
r plm standard-error robust
edited Nov 10 at 13:44
Tjebo
2,0971125
2,0971125
asked Nov 9 at 13:36
Suralira.K
51
51
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Set cluster='group'
if you want to cluster on the variable serving as the individual index (city
in your example).
Set cluster='time'
if you want to cluster on the variable serving as the time index (year
in your example).
You can cluster on the time index even for a fixed effects one-way individual model.
For clustering on both index variables, you cannot do that with plm::vcovHC
. Look at vcovDC
from the same packages which provides double clustering (DC = double clustering), e.g.
coeftest(fem_city, vcovDC(fem_city)
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Set cluster='group'
if you want to cluster on the variable serving as the individual index (city
in your example).
Set cluster='time'
if you want to cluster on the variable serving as the time index (year
in your example).
You can cluster on the time index even for a fixed effects one-way individual model.
For clustering on both index variables, you cannot do that with plm::vcovHC
. Look at vcovDC
from the same packages which provides double clustering (DC = double clustering), e.g.
coeftest(fem_city, vcovDC(fem_city)
add a comment |
up vote
0
down vote
accepted
Set cluster='group'
if you want to cluster on the variable serving as the individual index (city
in your example).
Set cluster='time'
if you want to cluster on the variable serving as the time index (year
in your example).
You can cluster on the time index even for a fixed effects one-way individual model.
For clustering on both index variables, you cannot do that with plm::vcovHC
. Look at vcovDC
from the same packages which provides double clustering (DC = double clustering), e.g.
coeftest(fem_city, vcovDC(fem_city)
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Set cluster='group'
if you want to cluster on the variable serving as the individual index (city
in your example).
Set cluster='time'
if you want to cluster on the variable serving as the time index (year
in your example).
You can cluster on the time index even for a fixed effects one-way individual model.
For clustering on both index variables, you cannot do that with plm::vcovHC
. Look at vcovDC
from the same packages which provides double clustering (DC = double clustering), e.g.
coeftest(fem_city, vcovDC(fem_city)
Set cluster='group'
if you want to cluster on the variable serving as the individual index (city
in your example).
Set cluster='time'
if you want to cluster on the variable serving as the time index (year
in your example).
You can cluster on the time index even for a fixed effects one-way individual model.
For clustering on both index variables, you cannot do that with plm::vcovHC
. Look at vcovDC
from the same packages which provides double clustering (DC = double clustering), e.g.
coeftest(fem_city, vcovDC(fem_city)
edited Nov 10 at 12:16
answered Nov 9 at 20:23
Helix123
1,585623
1,585623
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53226737%2fr-fixed-effect-of-panel-data-analysis-and-robust-standard-errors%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password