Is there a difference between the functions fitted() and predict()? I’ve noticed that mixed models from lme4 work with fitted() but not predict().
Is there a difference between the functions fitted() and predict() ? I’ve noticed that
Share
Yes, there is. If there is a link function relating the linear predictor to the expected value of the response (such as log for Poisson regression or logit for logistic regression),
predictreturns the fitted values before the inverse of the link function is applied (to return the data to the same scale as the response variable), andfittedshows it after it is applied.For example:
This does mean that for models created by linear regression (
lm), there is no difference betweenfittedandpredict.In practical terms, this means that if you want to compare the fit to the original data, you should use
fitted.