# Health Economics

> Health economic analysis in R, including cost-effectiveness, QALYs, decision models, and budget impact.

- **Type:** Skill
- **Install:** `agentstack add skill-choxos-biostatagent-health-economics`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [choxos](https://agentstack.voostack.com/s/choxos)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [choxos](https://github.com/choxos)
- **Source:** https://github.com/choxos/BiostatAgent/tree/main/plugins/r-tidy-modeling/skills/health-economics

## Install

```sh
agentstack add skill-choxos-biostatagent-health-economics
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Health Economics Evaluation in R

## Overview

Health economic evaluation methods covering cost-effectiveness analysis (CEA), quality-adjusted life years (QALYs), incremental cost-effectiveness ratios (ICERs), budget impact analysis, Markov cohort models, partitioned survival analysis, probabilistic sensitivity analysis, and value of information analysis.

## Cost-Effectiveness Fundamentals

### Basic Calculations

```r
# Treatment comparison data
# Intervention vs Comparator
costs_int 
  mutate(
    delta_cost = cost_trt - cost_base,
    delta_qaly = qaly_trt - qaly_base,
    icer = delta_cost / delta_qaly
  )

# CEAC calculation
wtp_range  0)
})

# Plot CEAC
plot(wtp_range, ceac, type = "l",
     xlab = "Willingness-to-Pay ($/QALY)",
     ylab = "Probability Cost-Effective",
     main = "Cost-Effectiveness Acceptability Curve")
```

## Value of Information Analysis

### Expected Value of Perfect Information (EVPI)

```r
library(BCEA)

# EVPI from BCEA object
evpi_result 
  mutate(
    Total_Cost = Cost_New + Cost_Current,
    Budget_Impact = Total_Cost - Cost_Reference
  )

# Summary
print(budget_impact)

# Total 5-year budget impact
total_impact 
  select(Year, Cost_New, Cost_Current, Cost_Reference) |>
  pivot_longer(
    cols = -Year,
    names_to = "Category",
    values_to = "Cost"
  )

# Stacked bar chart
ggplot(bi_long |> filter(Category != "Cost_Reference"),
       aes(x = factor(Year), y = Cost / 1e6, fill = Category)) +
  geom_bar(stat = "identity") +
  geom_line(data = bi_long |> filter(Category == "Cost_Reference"),
            aes(y = Cost / 1e6, group = 1), linetype = "dashed", size = 1) +
  labs(x = "Year", y = "Cost ($ millions)",
       title = "Budget Impact Analysis",
       fill = "Treatment") +
  scale_fill_brewer(palette = "Set2") +
  theme_bw()
```

## Decision Trees

### Using dampack Package

```r
library(dampack)

# Define decision tree parameters
params <- list(
  p_disease = 0.10,          # Probability of disease
  p_cure_trt = 0.80,         # Cure probability with treatment
  p_cure_notrt = 0.50,       # Cure probability without treatment
  c_test = 100,              # Cost of diagnostic test
  c_treatment = 5000,        # Cost of treatment
  c_disease = 20000,         # Cost of disease (if not cured)
  u_healthy = 1.0,           # Utility healthy
  u_disease = 0.60           # Utility with disease
)

# Strategy 1: Treat all
cost_treat_all <- params$c_treatment +
  params$p_disease * (1 - params$p_cure_trt) * params$c_disease
qaly_treat_all <- params$p_disease * (
  params$p_cure_trt * params$u_healthy +
  (1 - params$p_cure_trt) * params$u_disease
) + (1 - params$p_disease) * params$u_healthy

# Strategy 2: Test then treat
cost_test_treat <- params$c_test +
  params$p_disease * (params$c_treatment +
  (1 - params$p_cure_trt) * params$c_disease)

# Calculate all strategies and compare
```

## Discounting

```r
# Discount costs and effects
discount <- function(values, rate, time_points) {
  values / (1 + rate)^time_points
}

# Example: 30-year costs
years <- 0:29
annual_costs <- rep(5000, 30)
discount_rate <- 0.03

# Present value
pv_costs <- sum(discount(annual_costs, discount_rate, years))
cat("Undiscounted total:", sum(annual_costs), "\n")
cat("Present value (3% discount):", round(pv_costs, 0), "\n")

# Differential discounting (costs vs QALYs)
# Some guidelines recommend different rates
discount_costs <- 0.03
discount_qalys <- 0.015

pv_costs <- sum(discount(annual_costs, discount_costs, years))
pv_qalys <- sum(discount(annual_qalys, discount_qalys, years))
```

## Key Packages Summary

| Package | Purpose |
|---------|---------|
| BCEA | Bayesian cost-effectiveness analysis |
| heemod | Markov cohort models for HE |
| hesim | Health economic simulation modeling |
| dampack | Decision-analytic modeling tools |
| survHE | Survival analysis for HE |
| flexsurv | Parametric survival for extrapolation |
| CEAutil | CEA utility functions |
| valueEQ5D | EQ-5D utility mapping |

## Best Practices

1. **Model structure**: Match model type to disease natural history
2. **Time horizon**: Sufficient to capture all relevant costs and effects
3. **Discounting**: Apply recommended rates (often 3% for both costs and effects)
4. **Uncertainty**: Always conduct PSA and report CIs/CrIs
5. **Transparency**: Document all assumptions and data sources
6. **Validation**: Internal consistency checks and external validation
7. **Reporting**: Follow CHEERS checklist for publications
8. **Perspective**: Clearly state healthcare payer vs societal perspective

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [choxos](https://github.com/choxos)
- **Source:** [choxos/BiostatAgent](https://github.com/choxos/BiostatAgent)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-choxos-biostatagent-health-economics
- Seller: https://agentstack.voostack.com/s/choxos
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
