## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----basic, eval = FALSE------------------------------------------------------ # library(causalfrag) # # # 1. Fit your model # fit <- lm(mpg ~ am + wt + hp, data = mtcars) # # # 2. Run the full sensitivity pipeline # result <- sens_report( # model = fit, # treatment = "am", # data = mtcars # ) # # # 3. Print the structured results + fragility flag # print(result) # # # 4. Access the plain-language narrative # cat(result$narrative) ## ----stepwise, eval = FALSE--------------------------------------------------- # library(causalfrag) # # fit <- lm(mpg ~ am + wt + hp, data = mtcars) # # # Step 1: detect the design # design <- detect_design(fit) # # # Step 2: run sensitivity analysis # res <- run_sensitivity(fit, treatment = "am", data = mtcars, design = design) # # # Step 3: flag fragility # res <- flag_fragility(res) # # # Step 4: interpret (uses LLM if configured, template otherwise) # res <- interpret_sensitivity(res) # # # Step 5: visualize (uses confoundvis if installed) # plot(res) # # # Step 6: generate a report paragraph # cat(generate_report(res)) ## ----llm, eval = FALSE-------------------------------------------------------- # # Anthropic (key from ANTHROPIC_API_KEY environment variable) # use_llm_provider("anthropic") # # # OpenAI # use_llm_provider("openai") # # # Disable explicitly # use_llm_provider("none") ## ----confoundvis, eval = FALSE------------------------------------------------ # # Visualize with confoundvis (if installed) # visualize_sensitivity(res, engine = "confoundvis")