Hot answers tagged

20

Summary: the "random-effects model" in econometrics and a "random intercept mixed model" are indeed the same models, but they are estimated in different ways. The econometrics way is to use FGLS, and the mixed model way is to use ML. There are different algorithms of doing FGLS, and some of them (on this dataset) produce results that are very close to ML. 1....


19

This answer doesn't comment on mixed models, but I can explain what the random-effects estimator does and why it screws up on that graph. Summary: the random-effects estimator assumes $E[u_i \mid x ] = 0$, which is not true in this example. What is the random effects estimator doing? Assume we have the model: $$ y_{it} = \beta x_{it} + u_i + \epsilon_{...


18

In this answer, I would like to elaborate a little on Matthew's +1 answer regarding the GLS perspective on what the econometrics literature calls the random effects estimator. GLS perspective Consider the linear model \begin{equation} y_{it}=\alpha + X_{it}\beta+u_{it}\qquad i=1,\ldots,m,\quad t=1,\ldots,T \end{equation} If it held that $E(u_{it}\vert X_{...


11

I am not really familiar enough with R to comment on your code, but the simple random intercept mixed model should be identical to the RE MLE estimator, and very close to the RE GLS estimator, except when total $N = \sum_i T_i$ is small and the data are unbalanced. Hopefully, this will be useful in diagnosing the problem. Of course, this is all assuming that ...


9

Let me confuse things even more: ECONOMETRICS - FIXED EFFECTS APPROACH The "fixed effects" approach in econometrics for panel data, is a way to estimate the slope coefficients (the betas), by "by-passing" the existence of the individual effects variable $\alpha_i$, and so by not making any assumption as to whether it is "fixed" or "random". This is what the ...


7

Read the text (text book + variable description in the data set) carefully: "C_it represents real capita sales of cigarettes by persons of smoking age (14 years and older), measured in packs of cigarettes per head". While 14 is an obvious typo (should be 16), it is clear that you are supposed to use the variables pop16 ("population above the age of 16") and ...


6

The canonical two-way model is $$ y_{it}=x_{it}'\beta+\alpha_i+\theta_t+\epsilon_{it} $$ Here, the individual effect is $\alpha_i$, and $\theta_t$ is the time effect. It is a two-way model if both are present. Thus, $\alpha_i$ captures effects that are specific to some panel unit but constant over time, whereas $\theta_t$ captures effects that are specific ...


6

I would suggest fitting a multilevel model, with company/firm nested within industry and firm also nested within country. This is just a special case of a mixed effects model and could be specified with this kind of formula (using the notation adopted by the lme4 library and others): ESG ~ fixed_effects + (1 | industry) + (1 | industry:firm) + (1| country) +...


6

Consider the model $$(1) \ \ w_{it} = \mathbf x_{it}^\top \beta + \delta_t +\psi_{a(i,t)} + \eta_{k(i,t)} + \epsilon_{it},$$ with the area effect $\psi_a$ and sector effect $\eta_k$ unobserved. Assuming that $\mathbf x_{it}$ is correlated with the area and sector effect the OLS estimator $$\hat \beta_{OLS}:=(\sum_i \sum_t\mathbf x_{it}\mathbf x_{it}^\top)^{-...


5

You need to extract the fixed effects by fixef and match them to the individual index. Here is an example for the Grunfeld data: data(Grunfeld, package = "plm") fe <- plm(inv ~ value + capital, data=Grunfeld, model = "within") temp <- merge(Grunfeld, data.frame(fixef_firm = names(fixef(fe)), fixef = as.numeric(fixef(fe))), all.x =T, by.x = c("firm"), ...


5

This is all in the documentation of package plm, e.g., the package's vignette. I believe you got confused due to the various fixed effects you would like to estimate. You would need to specify correctly what the observational units (individual dimension) and what the time dimension of your data is and put those into the index argument. If you look at firms, ...


5

The two commands you use estimate two different models. To illustrate, I use the Grunfeld data set; you can think of its firm variable as your Country variable and its year variable as your Year variable. Your 1st model: You effectively estimate a two-ways fixed effects model where the time fixed effect are explicitly modelled via dummies (the part +factor(...


4

I was a bit curious about your question and performed a brief research. I think that the problem you're experiencing might be due to one of the following reasons (these are just some ideas): Your variable dfmfd98 is indeed highly collinear and, thus, plm code just drops the output (I've tried to find that segment of code, but couldn't so far - the code is ...


4

As the test is applied to the residuals of the panel model, you could just regress on a constant, such that the residuals would be nothing but the demeaned variables whose cross-section dependence you want to test.


4

Caveat: I haven't used the plm package. It's impossible to recreate this error because we don't have access to your data. But if the matrix is computationally singular, then you have a problem of multicollonearity. As you've identified, there's essentially two reasons that can happen. Multicollinearity. Even if the pairwise correlations are low, it's ...


4

Indeed, plm will not allow you to run a FE model, when there is a lower-level unit (i.e. you want household instead of individual, country instead of states etc). And indeed, there's nothing wrong about doing what you want. The trick in this case is just to make the time variable unique, crossing it with the sub-level unit: make a time-individual if you do ...


4

Your understanding of fixed effects regression seems perfectly fine. When you do the within transformation to obtain the fixed effects estimator $$y_{it} - \overline{y}_{i} = (X_{it} - \overline{X}_i)\beta + \epsilon_{it} - \overline{\epsilon}_i$$ the time-sorting order does not matter because $\overline{y}_{i} = \frac{1}{T}\sum^{T}_{t=1}y_{it}$, $\overline{...


4

Prediction with panel data is kind of tricky. Your model seems to be $$ Y_{it} = X_{it}'\beta + c_i + u_{it} $$ where $c_i$ is an individual fixed effect. You have estimated the $\beta$'s with plm. But to get a prediction, you need to plug in some values for $X$ and for the fixed effect. Even if you just want to get predictions for the individuals in ...


4

While the question seems as a software question at first, there is some statistics behind it (and, thus, I deem this to be on-topic for xvalidated): The random effect estimator as per Swamy-Arora uses the variation of the associated within model and the associated between model. For a plm-based exposition see one of the package's vignettes https://cran....


3

For count data it is indicated (for reasons of interpretability of estimated parameters) to use a generalized linear model (GLM) with logarithmic link function, see my answer to Goodness of fit and which model to choose linear regression or Poisson But the distribution family can be choosen in different ways. The reason for the advice you refer, to use ...


3

When you fit a plm() you declare a certain set of indexes for cross-section group and time, respectively. When you call vcovHC(..., cluster = "group") subsequently, the grouping variable specified in the original plm() call is used. So it seems you only have to use plm(..., index = c("id", "time")) instead of plm(..., index = c("state", "time")) or ...


3

Thank you Helix. I expect don't breaking any code of politeness answering my own question. In fact, this question is related to this. Yet, I wil try give an answer from the econometrician point fo view now. After long time, I realized that in a Random effects estimates you are running a demeaned regression as is said in equation 6 of the plm package paper ...


3

It depends on your research, in some cases time effects could solve the cross-sectional problem. An article that is very useful is "Estimating Standard Errors in Finance Panel Data Sets: Comparing Approaches" by Mitchell A. Petersen, 2009. In fact, twoways here means both individual and time effects, so it is just two specifications hope this helps


3

As far as I know, in contrast to the lfe-package, the plm-package does not report $R^2$ and adjusted $R^2$ for the full model, but only for the projected model. This blog-entry should answer your question.


3

Your question is not very clear, and the link to the data is no longer working... For the time fixed effects, your call should look like this: fixed <- plm(Price ~ Income + Housing_units + Population_age + Population_density + Unemployment + Real_mortgage_rate + Expected_GDP_growth, data=df, index=c("Id", "Year"), model="within", effect="time") ...


3

Well I finally managed it out, applying the suggestions by the authors of the plm package here http://r.789695.n4.nabble.com/fitted-from-plm-td3003924.html So what I did is just to apply fitted <- as.numeric(fe.full$model[[1]] - fe.full$residuals) where I need the as.numeric function since I need to use it as a vector to plug in for further ...


3

If you only care about the correct estimation of standard errors, and you don't have any other particular reason to use the plm package, you can use the lfe package. Still, you can use the data created with the plm package library(lfe) form_iv <- formula(y~z | id + year | x ~ inst) my_iv_reg <- felm(form_iv, data = p.lmdb) wald_iv <- waldtest(...


3

For first-difference (and between) models, the model frame (what you get via model_object$model) is the original data and has more observations than the transformed data the first-differenced model is estimated on (you lose 1 observation per individual due to first-differencing). This is why the number of rows do not match the number of entries of the ...


3

The following code implemented the practice of putting interaction between Female dummy and year. The F test at the bottom test your null $\beta_{Female} = \beta_{Male}$. The t-statistic from plm output tests your null $\beta_{Female:year=1.5}=\beta_{Male:year=1.5}$. In particular, for year=1.5, the p-value is 0.32. library(plm) # Use plm library(car) # ...


3

Dynamic panels are usually dealt with using GMM. Check pgmm in plm. It should be quite straightforward to follow. https://www.jstatsoft.org/article/view/v027i02/v27i02.pdf


Only top voted, non community-wiki answers of a minimum length are eligible