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

Should the LHS be checked for interaction terms? Other things? #21

Closed
DavisVaughan opened this issue Feb 14, 2019 · 4 comments
Closed

Comments

@DavisVaughan
Copy link
Member

No description provided.

@DavisVaughan
Copy link
Member Author

library(hardhat)
library(gapminder)

# warning? same as rhs when indicators=FALSE?
mold(country:continent ~ year, gapminder)
#> $predictors
#> # A tibble: 1,704 x 1
#>     year
#>    <dbl>
#>  1  1952
#>  2  1957
#>  3  1962
#>  4  1967
#>  5  1972
#>  6  1977
#>  7  1982
#>  8  1987
#>  9  1992
#> 10  1997
#> # … with 1,694 more rows
#> 
#> $outcomes
#> # A tibble: 1,704 x 2
#>    country     continent
#>    <fct>       <fct>    
#>  1 Afghanistan Asia     
#>  2 Afghanistan Asia     
#>  3 Afghanistan Asia     
#>  4 Afghanistan Asia     
#>  5 Afghanistan Asia     
#>  6 Afghanistan Asia     
#>  7 Afghanistan Asia     
#>  8 Afghanistan Asia     
#>  9 Afghanistan Asia     
#> 10 Afghanistan Asia     
#> # … with 1,694 more rows
#> 
#> $preprocessor
#> Formula Preprocessor: 
#>  
#> # Predictors: 1 
#>   # Outcomes: 2 
#>    Intercept: FALSE 
#>   Indicators: TRUE 
#> 
#> $offset
#> NULL

mold(year ~ country:continent, gapminder, indicators = FALSE)
#> Warning: Interaction terms have been detected in `formula`. These are
#> not expanded when `indicators = FALSE`, but the individual terms will be
#> included in the output.
#> $predictors
#> # A tibble: 1,704 x 2
#>    country     continent
#>    <fct>       <fct>    
#>  1 Afghanistan Asia     
#>  2 Afghanistan Asia     
#>  3 Afghanistan Asia     
#>  4 Afghanistan Asia     
#>  5 Afghanistan Asia     
#>  6 Afghanistan Asia     
#>  7 Afghanistan Asia     
#>  8 Afghanistan Asia     
#>  9 Afghanistan Asia     
#> 10 Afghanistan Asia     
#> # … with 1,694 more rows
#> 
#> $outcomes
#> # A tibble: 1,704 x 1
#>     year
#>    <int>
#>  1  1952
#>  2  1957
#>  3  1962
#>  4  1967
#>  5  1972
#>  6  1977
#>  7  1982
#>  8  1987
#>  9  1992
#> 10  1997
#> # … with 1,694 more rows
#> 
#> $preprocessor
#> Formula Preprocessor: 
#>  
#> # Predictors: 2 
#>   # Outcomes: 1 
#>    Intercept: FALSE 
#>   Indicators: FALSE 
#> 
#> $offset
#> NULL

Created on 2019-02-16 by the reprex package (v0.2.1.9000)

@DavisVaughan
Copy link
Member Author

maybe check the attr(terms, "factor")` matrix for interactions?

@DavisVaughan
Copy link
Member Author

DavisVaughan commented Feb 20, 2019

Can use a modified version of detect_factors_in_interactions() to look for : in the factor matrix of the terms (* and ^ and %in% are all recoded with : in the factor matrix). This would let us prevent interactions on the LHS because only model.frame() is run.

@github-actions
Copy link

github-actions bot commented Jul 1, 2021

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant