1
votes

I have an unbalanced panel with weekly data and want to do a panel regression with both, individual and time fixed effects.

Following the code in https://www.princeton.edu/~otorres/Panel101R.pdf my code looks like this:

tfe <- plm(y ~ x1 + x2 + factor(index), data, model = "within", index = c("id", "index"))

where index is 1 for the first week, 2 for the second and so on and id is the identifier for each individual in the data set.

From my understanding this code should create the same results as:

tfe <- plm(y ~ x1 + x2, data, effect = "twoways", model = "within", index = c("id", "index"))

is that correct? (see R plm time fixed effect model for example)

However, while my coefficients are identical, the time fixed effects and especially the R² are not.

Can someone help me in understanding the difference between my two regressions?

1

1 Answers

1
votes

This is a statistical question and not a programming question.

Degrees of freedom vary between the two model estimations and these are part of the calculation of e.g. the R squared.