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?