Open arne-henningsen opened 1 year ago
Hi Arne, I am afraid, this has been unanswered for quite a while now! Good observations and indeed, this is something I worked on a bit in the past towards making it more consistent but never fully completed:
Does fitted() return the fitted values of the within-transformed model, while predict() returns the values that correspond to the not-within-transformed dependent variable?
Yes, that is the case currently and fully agreed this should be made clear in the documentation. I think fitted
's behaviour is so deeply rooted in plm that changing it would be quite a burden and predict
came just a few months ago (and - at least to me - the word "predict" feels a little more like what I would expect and indeed get).
For the other questions:
There are the non-exported functions residuals_overall_exp.plm
, residuals_overall_e_exp
, and fitted_exp.plm
in file experimental.R
with some comments and also a test file inst/test_residuals_overall_fitted_exp.plm
. This is my old previous work towards a more consistent behaviour.
And the two-way unbalaned RE model behaves different in another way as its estimation technique is a different one.
I find it surprising that fitted() and predict() (w/o argument 'newdata') return different values.
Does fitted() return the fitted values of the within-transformed model, while predict() returns the values that correspond to the not-within-transformed dependent variable?
I suggest to make fitted() and predict() consistent with each other (or at least to clearly describe the difference between the two methods in the documentation of fitted.plm() and predict.plm().
The following code illustrates the difference for fixed-effects and random effects estimations:
Furthermore, for fixed-effect estimations, the predicted values (but not the fitted values) plus the residuals are equal to the dependent variable, while for random-effects estimations, this is neither the case for the predicted values nor for the fitted values:
I suggest to make predict.plm() and fitted.plm() more consistent with each other and across estimation methods (e.g., fixed effects, random effects) or at least clearly describe the differences between fitted.plm() and predict.plm() and the differences between fixed-effects and random-effects estimations in the documentation of fitted.plm() and predict.plm().