0

First of all I build the following dataframe (country_Id as factor variable and year as numeric):

mydata = pdata.frame(mydata, index = c("country_Id","year"),row.names = TRUE)

Then I check it with:

index(mydata)  
pdim(mydata)
is.pconsecutive(mydata)
class(mydata)

Everything seems to be fine but I want to include country-dummies in the fixed-effects model it does not work

femodel_1 <- plm(y~x + ldvx + factor(country_Id) , data= mydata, model = "within")

And another problem is that my random model shows that the individual variance is 0

remodel_1 <- plm(y~x + ldvx  , data= mydata, model = "random")

Unfortunately I can not find the problem.

StupidWolf
  • 45,075
  • 17
  • 40
  • 72
vap
  • 1
  • Welcome to StackOverflow! Please read the following [post](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on how to make a reproducible example so that the community can more easily and quickly help you. – emilliman5 Feb 05 '21 at 16:11

1 Answers1

0

Your one-way fixed effect model already takes care of the country fixed effects. This is why you cannot add them to the model's formula again - it would not make sense- they just disappear. So you are fine with:

femodel_1 <- plm(y~x + ldvx, data= mydata, model = "within")

If you want to values of the country fixed effects, use fixef(fe_model1).

About your random effect model:

The Swamy-Arora RE estimator does not guarantee positive variance estimates (read up on this in a good econometrics text book or look here: https://stats.stackexchange.com/questions/176827/error-in-plm-random-effects-swamy-arora-swar-estimator-with-lagged-dependent/181444#181444). You can try to change your model (if it makes sense) and/or change your data a bit (e.g., more observations). Also, you can try to switch to a different RE estimator - plm offers a few.

Helix123
  • 3,502
  • 2
  • 16
  • 36