Skip to content

Commit

Permalink
Update a vignette for glm_betaselect
Browse files Browse the repository at this point in the history
  • Loading branch information
sfcheung committed Oct 29, 2024
1 parent 58bdd83 commit 443cc7c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
22 changes: 13 additions & 9 deletions vignettes/betaselectr_glm.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ including product terms.

Suppose we only need to
solve the first problem, standardizing all
numeric variables,
numeric variables except for the
response variable (which is binary),
with the product
term computed after `iv` and `mod`
are standardized.
Expand All @@ -242,7 +243,7 @@ are standardized.
``` r
glm_beta_select <- glm_betaselect(dv ~ iv*mod + cov1 + cat1,
data = data_test_mod_cat_binary,
not_to_standardize = "dv",
skip_response = TRUE,
family = binomial(),
do_boot = FALSE)
```
Expand All @@ -262,9 +263,9 @@ variable (`dv` in this example) may not
be meaningful or may even be not allowed.
In the case of logistic regression, the
outcome variable need to be 0 or 1 only.
Therefore, `not_to_standardize` is set to
`"dv"`, the name of the outcome variable,
to request that it is *not* standardized.
Therefore, `skip_response` is set to
`TRUE`, to request that the response
(outcome) variable is *not* standardized.

Moreover, categorical variables (factors and
string variables) will not be standardized.
Expand All @@ -286,7 +287,7 @@ summary(glm_beta_select)
#> Waiting for profiling to be done...
#> Call to glm_betaselect():
#> betaselectr::lm_betaselect(formula = dv ~ iv * mod + cov1 + cat1,
#> family = binomial(), data = data_test_mod_cat_binary, not_to_standardize = "dv",
#> family = binomial(), data = data_test_mod_cat_binary, skip_response = TRUE,
#> do_boot = FALSE, model_call = "glm")
#>
#> Variable(s) standardized: iv, mod, cov1
Expand Down Expand Up @@ -367,7 +368,7 @@ set:
glm_beta_select_boot <- glm_betaselect(dv ~ iv*mod + cov1 + cat1,
data = data_test_mod_cat_binary,
family = binomial(),
not_to_standardize = "dv",
skip_response = TRUE,
bootstrap = 5000,
iseed = 4567)
```
Expand All @@ -392,7 +393,7 @@ This is the output of `summary()`
summary(glm_beta_select_boot)
#> Call to glm_betaselect():
#> betaselectr::lm_betaselect(formula = dv ~ iv * mod + cov1 + cat1,
#> family = binomial(), data = data_test_mod_cat_binary, not_to_standardize = "dv",
#> family = binomial(), data = data_test_mod_cat_binary, skip_response = TRUE,
#> bootstrap = 5000, iseed = 4567, model_call = "glm")
#>
#> Variable(s) standardized: iv, mod, cov1
Expand Down Expand Up @@ -470,6 +471,7 @@ this, setting
glm_beta_select_boot_1 <- glm_betaselect(dv ~ iv*mod + cov1 + cat1,
data = data_test_mod_cat_binary,
to_standardize = c("iv", "cov1"),
skip_response = TRUE,
family = binomial(),
bootstrap = 5000,
iseed = 4567)
Expand All @@ -485,6 +487,7 @@ this call, and set
glm_beta_select_boot_2 <- glm_betaselect(dv ~ iv*mod + cov1 + cat1,
data = data_test_mod_cat_binary,
not_to_standardize = c("dv", "mod"),
skip_response = TRUE,
family = binomial(),
bootstrap = 5000,
iseed = 4567)
Expand All @@ -500,7 +503,8 @@ summary(glm_beta_select_boot_1)
#> Call to glm_betaselect():
#> betaselectr::lm_betaselect(formula = dv ~ iv * mod + cov1 + cat1,
#> family = binomial(), data = data_test_mod_cat_binary, to_standardize = c("iv",
#> "cov1"), bootstrap = 5000, iseed = 4567, model_call = "glm")
#> "cov1"), skip_response = TRUE, bootstrap = 5000, iseed = 4567,
#> model_call = "glm")
#>
#> Variable(s) standardized: iv, cov1
#>
Expand Down
15 changes: 9 additions & 6 deletions vignettes/betaselectr_glm.Rmd.original
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,16 @@ including product terms.

Suppose we only need to
solve the first problem, standardizing all
numeric variables,
numeric variables except for the
response variable (which is binary),
with the product
term computed after `iv` and `mod`
are standardized.

```{r, results = FALSE}
glm_beta_select <- glm_betaselect(dv ~ iv*mod + cov1 + cat1,
data = data_test_mod_cat_binary,
not_to_standardize = "dv",
skip_response = TRUE,
family = binomial(),
do_boot = FALSE)
```
Expand All @@ -209,9 +210,9 @@ variable (`dv` in this example) may not
be meaningful or may even be not allowed.
In the case of logistic regression, the
outcome variable need to be 0 or 1 only.
Therefore, `not_to_standardize` is set to
`"dv"`, the name of the outcome variable,
to request that it is *not* standardized.
Therefore, `skip_response` is set to
`TRUE`, to request that the response
(outcome) variable is *not* standardized.

Moreover, categorical variables (factors and
string variables) will not be standardized.
Expand Down Expand Up @@ -269,7 +270,7 @@ set:
glm_beta_select_boot <- glm_betaselect(dv ~ iv*mod + cov1 + cat1,
data = data_test_mod_cat_binary,
family = binomial(),
not_to_standardize = "dv",
skip_response = TRUE,
bootstrap = 5000,
iseed = 4567)
```
Expand Down Expand Up @@ -330,6 +331,7 @@ this, setting
glm_beta_select_boot_1 <- glm_betaselect(dv ~ iv*mod + cov1 + cat1,
data = data_test_mod_cat_binary,
to_standardize = c("iv", "cov1"),
skip_response = TRUE,
family = binomial(),
bootstrap = 5000,
iseed = 4567)
Expand All @@ -344,6 +346,7 @@ this call, and set
glm_beta_select_boot_2 <- glm_betaselect(dv ~ iv*mod + cov1 + cat1,
data = data_test_mod_cat_binary,
not_to_standardize = c("dv", "mod"),
skip_response = TRUE,
family = binomial(),
bootstrap = 5000,
iseed = 4567)
Expand Down

0 comments on commit 443cc7c

Please sign in to comment.