DesignLibrary icon indicating copy to clipboard operation
DesignLibrary copied to clipboard

Updates to mediation_designer

Open jaspercooper opened this issue 7 years ago • 9 comments

  • simplify code
  • add mediation analysis

jaspercooper avatar Aug 06 '18 13:08 jaspercooper

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()

jaspercooper avatar Aug 23 '18 14:08 jaspercooper

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?

jaspercooper avatar Oct 24 '18 02:10 jaspercooper

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

lilymedina avatar Oct 24 '18 09:10 lilymedina

That sounds amazing, thanks so much!

jaspercooper avatar Oct 24 '18 14:10 jaspercooper

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%

lilymedina avatar Oct 26 '18 13:10 lilymedina

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

lilymedina avatar Oct 29 '18 09:10 lilymedina

Awesome, thanks

jaspercooper avatar Oct 29 '18 14:10 jaspercooper

Error fixed in fb4f5d642e1cde60eaf878aaeb30aa7bf120da99

clarabicalho avatar Oct 31 '18 14:10 clarabicalho

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?

lilymedina avatar Oct 31 '18 15:10 lilymedina