Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formula Expansions by . (dot) in plm Estimation Commands #35

Closed
SebKrantz opened this issue Oct 13, 2022 · 4 comments
Closed

Formula Expansions by . (dot) in plm Estimation Commands #35

SebKrantz opened this issue Oct 13, 2022 · 4 comments
Milestone

Comments

@SebKrantz
Copy link

From Twitter: Is there any reason why in #R with the plm-command for a fixed-effects-regression I cannot for the formula use the usual " y ~ . , data = df, ..." notation? It only works if I explicitly give it " y ~ x1 + x2 + ...". Which is impracticable if you have 440 variables...

PS: It’s a matter of passing the data frame to the data argument of terms.formula e.g. terms(mpg ~ ., data = mtcars) does the job.

@tappek
Copy link
Collaborator

tappek commented Nov 20, 2022

Thank you for bringing this to our attention! I had a first look and need to look at this more closely at some later point in time.
As a reminder for myself: It stems from plm::has.intercept which in turn calls terms without the necessary data argument when a dot is present. Minimal example:

plm::has.intercept(y ~ .) # errors 
plm::has.intercept(y ~ ., data = <dataset>) # works

Another observation about Formula:::model.matrix.Formula which we use:

library(Formula)
model.matrix(as.Formula(inv ~ .), data = Grunfeld[ , -c(1:2)], rhs = 1, dot = "separate") # works
model.matrix(as.Formula(inv ~ .), data = Grunfeld[ , -c(1:2)], rhs = 1, dot = "previous") # errors

-> The branch dot = "previous" does not have the data argument in its call to terms.
Edit: this observation is about Formula 1.2-4 and I addressed it to its maintainer. It is now already fixed on R-Forge in version 1.2-5 by commit https://r-forge.r-project.org/scm/viewvc.php/pkg/R/Formula.R?root=formula&r1=53&r2=54&pathrev=54

@tappek tappek changed the title Formula Expansions in plm Estimation Commands Formula Expansions by . (dot) in plm Estimation Commands Nov 29, 2022
@tappek tappek added this to the next release milestone Nov 29, 2022
@tappek
Copy link
Collaborator

tappek commented Nov 29, 2022

I have something 'almost ready' and hope to commit soon. Will go into next release.

@tappek
Copy link
Collaborator

tappek commented Dec 25, 2022

fixed in 76b03df

This requieres package Formula in min. version 1.2-5 currently not on CRAN but available on R-Forge.

@tappek tappek closed this as completed Dec 26, 2022
@tappek
Copy link
Collaborator

tappek commented Feb 24, 2023

addendum: pkg Formula 1.2-5 now on CRAN / 2023-02-24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants