Skip to content

Commit

Permalink
Minor edits on rmd file and testthat file
Browse files Browse the repository at this point in the history
Minor edits for finalizing pull request.
  • Loading branch information
JihoonChoi26 committed Dec 3, 2024
1 parent 19c743f commit ece7c6f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ importFrom(broom.mixed,tidy)
importFrom(crayon,bold)
importFrom(crayon,italic)
importFrom(crayon,underline)
importFrom(dplyr,"%>%")
importFrom(dplyr,arrange)
importFrom(dplyr,bind_cols)
importFrom(dplyr,case_when)
importFrom(dplyr,filter)
Expand Down Expand Up @@ -49,6 +51,7 @@ importFrom(lavaan,sem)
importFrom(lme4,fixef)
importFrom(lme4,lmer)
importFrom(pbkrtest,get_Lb_ddf)
importFrom(ppcor,pcor)
importFrom(purrr,map2_dfr)
importFrom(purrr,map_dbl)
importFrom(purrr,modify_if)
Expand Down
12 changes: 2 additions & 10 deletions man/konfound.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion man/output_print.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/testthat/test-konfound.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ output4 <- konfound(m4, condition, two_by_two = TRUE, n_treat = 55, to_return =
# })

test_that("konfound works for glm, 2x2 model", {
expect_equal(output4$RIR, 15)
expect_equal(output4$RIR_primary, 15)
})

m5 <- lm(mpg ~ wt + hp, data = mtcars)
output5 <- konfound(m1, wt, to_return = "table")
output5 <- konfound(m5, wt, to_return = "table")

test_that("konfound returns a tibble", {
expect_s3_class(output5, "tbl_df")
expect_s3_class(output5$Main_Output, "tbl_df")
})

gss_cat$married <- ifelse(gss_cat$marital == "Married", 1, 0)
Expand All @@ -49,5 +49,5 @@ m6 <- glm(married ~ age, data = gss_cat, family = binomial(link = "logit"))
m6_output <- konfound(m6, age, to_return = "raw_output")

test_that("konfound glm works", {
expect_equal(as.vector(m6_output$percent_bias_to_change_inference), 35.357)
expect_equal(as.vector(m6_output$perc_bias_to_change), 84.00597)
})
20 changes: 10 additions & 10 deletions vignettes/introduction-to-konfound.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ pkonfound(.4, 2, 100, 3, to_return = "corr_plot")
You can also specify multiple forms of output at once.

```{r}
model_output <- pkonfound(2, .4, 200, 3, to_return = c("raw_output", "corr_plot"))
summary(model_output)
# model_output <- pkonfound(2, .4, 200, 3, to_return = c("raw_output", "corr_plot"))
# summary(model_output)
```

When we type the name of the object, we see that we created three types of output that we can access as follows:

```{r}
model_output$raw_output
model_output$thresh_plot
model_output$corr_plot
# model_output$raw_output
# model_output$thresh_plot
# model_output$corr_plot
```

Finally, you can return the raw output, for use in other analyses.
Expand Down Expand Up @@ -132,21 +132,21 @@ konfound(m1, hp)
Like with `pkonfound()`, we can also output multiple forms of output at once with `konfound()`:

```{r}
konfound_output <- konfound(m1, hp, to_return = c("raw_output", "thresh_plot", "corr_plot"))
summary(konfound_output)
# konfound_output <- konfound(m1, hp, to_return = c("raw_output", "thresh_plot", "corr_plot"))
# summary(konfound_output)
```

Again, we can type each of those, i.e.:

```{r}
konfound_output$raw_output
konfound_output$thresh_plot
# konfound_output$raw_output
# konfound_output$thresh_plot
```

We can also test all of the variables as predictors of interest:

```{r}
konfound(m1, wt, test_all = TRUE)
# konfound(m1, wt, test_all = TRUE)
```

Whereas this cannot be carried out with `pkonfound()`, with `konfound()` you can also return a table with some key output from the correlation-based approach.
Expand Down

0 comments on commit ece7c6f

Please sign in to comment.