easystats / easystats/datawizard

`standardize()` fails in some cases

Open
#441 7 comments 1 reaction 1 assignee View on GitHub

@strengejacke is already working on this.

Since Jul 1, 2023.

Dominant language
R
Stars
238
Forks
18
Avg merge
1d 15h
Merged PRs (30d)
4

Description

Cf https://github.com/easystats/report/issues/379

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.