-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
report.lm
: "Warning: Using $
in model formulas can produce unexpected results", but doing so errors
#379
Comments
Some additional info: Warnings come from: library(report)
data(sleep)
d <- datawizard::data_modify(sleep, group = as.integer(group) - 1L)
d_wide <<- datawizard::data_to_wide(
d,
names_from = "group",
values_from = "extra",
names_prefix = "group"
)
x <- lm(d_wide$group0 - d_wide$group1 ~ 1)
params <- parameters::model_parameters(x, ci_random = FALSE)
#> Warning: Using `$` in model formulas can produce unexpected results. Specify your
#> model using the `data` argument instead.
#> Try: group0 - group1 ~ 1,
#> data =
#> Warning: Using `$` in model formulas can produce unexpected results. Specify your
#> model using the `data` argument instead.
#> Try: group0 - group1 ~ 1,
#> data =
#> Warning: Using `$` in model formulas can produce unexpected results. Specify your
#> model using the `data` argument instead.
#> Try: group0 - group1 ~ 1,
#> data =
out <- insight::get_data(x)
#> Warning: Using `$` in model formulas can produce unexpected results. Specify your
#> model using the `data` argument instead.
#> Try: group0 - group1 ~ 1,
#> data =
#> Warning: Using `$` in model formulas can produce unexpected results. Specify your
#> model using the `data` argument instead.
#> Try: group0 - group1 ~ 1,
#> data =
#> Warning: Could not recover model data from environment. Please make sure your
#> data is available in your workspace.
#> Trying to retrieve data from the model frame now. Created on 2023-07-01 with reprex v2.0.2 Error comes from: library(report)
data(sleep)
d <- datawizard::data_modify(sleep, group = as.integer(group) - 1L)
d_wide <<- datawizard::data_to_wide(
d,
names_from = "group",
values_from = "extra",
names_prefix = "group"
)
x <- lm(group0 - group1 ~ 1, data = d_wide)
params <- parameters::model_parameters(x, ci_random = FALSE)
effsize <- report_effectsize(x)
#> Error in eval(predvars, data, env): object 'group0' not found
#> Error: Unable to refit the model with standardized data.
#> Try instead to standardize the data (standardize(data)) and refit the
#> model manually. Created on 2023-07-01 with reprex v2.0.2 @etiennebacher do you think these are coming from |
Looks like it comes from library(report)
library(datawizard)
data(sleep)
d <- data_modify(sleep, group = as.integer(group) - 1L)
d_wide <- data_to_wide(
d,
names_from = "group",
values_from = "extra",
names_prefix = "group"
)
model1 <- lm(d_wide$group0 - d_wide$group1 ~ 1)
standardize(model1)
#> Warning: Using `$` in model formulas can produce unexpected results. Specify your
#> model using the `data` argument instead.
#> Try: group0 - group1 ~ 1,
#> data =
#> Warning: Using `$` in model formulas can produce unexpected results. Specify your
#> model using the `data` argument instead.
#> Try: group0 - group1 ~ 1,
#> data =
#> Warning: Using `$` in model formulas can produce unexpected results. Specify your
#> model using the `data` argument instead.
#> Try: group0 - group1 ~ 1,
#> data =
#>
#> Call:
#> lm(formula = d_wide$group0 - d_wide$group1 ~ 1, data = data_std)
#>
#> Coefficients:
#> (Intercept)
#> -1.58
model1 <- lm(group0 - group1 ~ 1, data = d_wide)
standardize(model1)
#> Error in eval(predvars, data, env): objet 'group0' introuvable
#> Error: Unable to refit the model with standardized data.
#> Try instead to standardize the data (standardize(data)) and refit the
#> model manually. Created on 2023-07-01 with reprex v2.0.2 |
Note that standardizing the components of a composite variable will probably lead to nonsense results. |
It would be nice to get rid of the several warnings in R CMD check, but the proposed fix leads to an error:
Created on 2023-07-01 with reprex v2.0.2
Session info
The text was updated successfully, but these errors were encountered: