I have data frame with two variables: PPCE and PDPI (examples are from Gujarati Basic Econometrics textbook). I run first regression:
lm(df$PPCE ~ df$PDPI) -> lm1
then create lagged series od PDPI with lag one:
c(NA, head(PDPI, -1)) -> lagged1
and then run second regression:
lm(df$PPCE ~ df$PDPI + lagged1) -> lm2
When I run anova(lm1, lm2)
to find out should I include lagged variable of PDPI I get:
Error in anova.lmlist(object, ...) : models were not all fitted to the same size of dataset
So my questio is, how can I check with anova funcion in R if lagged variables should be included in the model?