Updates to mediation_designer
- simplify code
- add mediation analysis
OK this is being pushed off to next big version.
One issue is the slowness induced by quasi-bayesian simulations. @macartan suggests adding an option to turn off estimators, which I think is a good solution.
also we should really consider submitting PRs to mediation and broom so that we can tidy() the mediation output.
- [x] PR tidy method for mediate
- [ ] PR to broom
- [ ] clean up code and get looking good
- [x] add option to switch off mediate()
Where are we at with this, @medinali ? Did we ever end up doing the PRs to broom and mediate? I believe all the other changes have been implemented, oder?
na klar!
-
The PR to broom was merged, which is enough to be able to tidy(). Though I forgot to include CIs in tibble and also noticed that columns are of type character and not numeric, so will do a new PR to include those edits.
-
Included estimands for indirect effects.
-
The code is looking good but would look cleaner once the new PR has been merged.
-
I implemented new args names in the code-- I really like how they make formals very intuitive but am a bit unsure about how they look on the printed code; there are lot of Z_s, Y_s and M_s.
remaining task
-
[x] finish up tibble and PR broom
-
[x] Run tests and checks and PR master
That sounds amazing, thanks so much!
see updates below
Broom
-
I haven't been able to fix the class of columns in tibble (it's still character!) -- I PR'd broom to change this but their master branch seems to be breaking.
-
however, tidy.mediate() does compute conf.int so we are able to diagnose design without creating a mess in the code
out <- broom::tidy(m, conf.int = TRUE) out <- as.data.frame(apply(out[,c("estimate", "std.error", "p.value", "conf.low", "conf.high")], 2, as.numeric))
Checks, test and coverage all passing and coverage at 100%
Broom's PR has been merged.
Currently having an issue when printing code for the vignette, when mediation_package option is turned on.
The following chunk throws an error
{r, code = get_design_code( mediation_analysis_designer(mediation_package = TRUE)), eval=TRUE}
Error in cat(x$quantities_added[[i]], sep = "\n" : arguement 1 (type 'list) cannot be handled by 'cat' Calls <Anonymous>...print.design <- primt.summary.design -> cat Execution halted )
Same happens for eval = FALSE
I'll look into it and do PR once it's solved
Awesome, thanks
Error fixed in fb4f5d642e1cde60eaf878aaeb30aa7bf120da99
great!
One last thing: this branch currently depends on the GitHub's version of broom --@jaspercooper, would that be ok esp now that tidy should be imported from generics?
or is it better to wait until broom is pushed to CRAN?