What is the difference in the estimates of plm and least squares dummy variable (LSDV) models? And how does the interpretation of the variables differ in general?

Imagine the following plm() and lm() + factor():

within <- plm(dependent_var ~ independent_var, data = dataset, method = "within" , effect = "twoways")

LSDV <- lm(dependent_var ~ independent_var + factor(individual) - 1 + factor(time), data = dataset)

1 Answer 1


The "within estimator" and the least squares dummy variable (LSDV) estimator yield equivalent estimates of independent_var. Including a full series of indicator variables for the panel and/or temporal identifier is algebraically equivalent to estimation in deviations from means. Though the mechanics may differ, it should not affect your interpretation of independent_var.


It isn't necessary to drop the intercept inside of the lm() function, though it shouldn't affect your point estimates.

Also, don't forget to set your indexes when using plm() to estimate a panel model. Either coerce your data frame using pdata.frame():

panel_dataset <- pdata.frame(dataset, index = c("individual", "time"))

or, simply set the panel indexes inside of your call to plm() after the model formula. The latter approach saves you some extra keystrokes:

plm(y ~ x, data = dataset, index = c("individual", "time"), method = "within", effect = "twoways")
  • $\begingroup$ Thank you @thomas bilach!! $\endgroup$
    – mag123
    Mar 17, 2021 at 0:21
  • $\begingroup$ Also, don't forget to set your indexes. I'm sure you've already pre-processed the data frame, but I couldn't be sure. I updated my answer with some suggestions. $\endgroup$ Mar 17, 2021 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.