konfound-project / konfound

R package for carrying out sensitivity analysis
https://konfound-project.github.io/konfound/
Other
15 stars 7 forks source link

one last konfound error #70

Closed jrosen48 closed 5 months ago

jrosen48 commented 5 months ago
library(forcats)
library(lme4)
#> Loading required package: Matrix
library(konfound)
#> Sensitivity analysis as described in Frank, Maroulis, Duong, and Kelcey (2013) and in Frank (2000).
#> For more information visit http://konfound-it.com.
library(testthat)

m3 <- fm1 <- lme4::lmer(Reaction ~ Days + (1 | Subject), sleepstudy)
output3 <- konfound(m3, Days, to_return = "raw_output")
#> Note that the Kenward-Roger approximation is used to estimate degrees of freedom for the predictor(s) of interest. We are presently working to add other methods for calculating the degrees of freedom for the predictor(s) of interest. If you wish to use other methods now, consider those detailed here: https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#why-doesnt-lme4-display-denominator-degrees-of-freedomp-values-what-other-options-do-i-have. You can then enter degrees of freedom obtained from another method along with the coefficient, number of observations, and number of covariates to the pkonfound() function to quantify the robustness of the inference.

test_that("konfound works for lme4 model", {
    expect_equal(output3$percent_bias_to_change_inference, 84.826, tolerance = .001)
})
#> ── Warning ('<text>:10:5'): konfound works for lme4 model ──────────────────────
#> Unknown or uninitialised column: `percent_bias_to_change_inference`.
#> Backtrace:
#>     ▆
#>  1. ├─testthat::expect_equal(...)
#>  2. │ └─testthat::quasi_label(enquo(object), label, arg = "object")
#>  3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
#>  4. ├─output3$percent_bias_to_change_inference
#>  5. └─tibble:::`$.tbl_df`(output3, percent_bias_to_change_inference)
#> 
#> ── Failure ('<text>:10:5'): konfound works for lme4 model ──────────────────────
#> output3$percent_bias_to_change_inference not equal to 84.826.
#> target is NULL, current is numeric
#> Error in `reporter$stop_if_needed()`:
#> ! Test failed

Created on 2024-02-08 with reprex v2.1.0

@wwang93 I think this is due to 0c46c1a20e0be520672ed43e589a7b75e59bb98a -- I think these = can be kept as they are within the tibble() function (confusing, I know).

wwang93 commented 5 months ago

Yep, I will update these.