Skip to content

Commit

Permalink
update requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
tdebray123 committed Nov 20, 2023
1 parent 85a56cb commit 836d350
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ jobs:
uses: r-lib/actions/setup-r@v2
with:
r-version: '4.2.3' # Update to most recent version of R

- name: Install R packages
uses: r-lib/actions/setup-r-dependencies@v2
with:
packages:
any::rmarkdown
any::kableExtra
any::dplyr
any::ggplot2
- name: Render and Publish
Expand Down
2 changes: 1 addition & 1 deletion chapter_06.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bibliography: 'https://api.citedrive.com/bib/0d25b38b-db8f-43c4-b934-f4e2f3bd655
required_packages <- c("dplyr", "cobalt", "data.table", "ggplot2",
"knitr", "lmtest", "marginaleffects", "MASS",
"survey", "tableone", "truncnorm", "sandwich",
"MatchIt", "boot", "WeightIt", "survey")
"MatchIt", "boot", "WeightIt", "survey", "optmatch")
# Install required packages
for (pkg in required_packages) {
Expand Down
30 changes: 23 additions & 7 deletions chapter_16.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ execute:
bibliography: 'https://api.citedrive.com/bib/0d25b38b-db8f-43c4-b934-f4e2f3bd655a/references.bib?x=eyJpZCI6ICIwZDI1YjM4Yi1kYjhmLTQzYzQtYjkzNC1mNGUyZjNiZDY1NWEiLCAidXNlciI6ICIyNTA2IiwgInNpZ25hdHVyZSI6ICI0MGFkYjZhMzYyYWE5Y2U0MjQ2NWE2ZTQzNjlhMWY3NTk5MzhhNzUxZDNjYWIxNDlmYjM4NDgwOTYzMzY5YzFlIn0=/bibliography.bib'
---

``` {r}
#| message: false
#| warning: false
#| echo: false
# List of required packages
required_packages <- c("dplyr", "table1", "kableExtra", "bipd")
# Install required packages
for (pkg in required_packages) {
if (!requireNamespace(pkg, quietly = TRUE)) {
install.packages(pkg)
}
}
```

In this chapter, we discuss statistical methods for developing models to predict patient-level treatment effects using data from multiple randomized and non-randomized studies. We will first present prediction models that assume a constant treatment effect and discuss how to address heterogeneity in baseline risk. Subsequently, we will discuss approaches that allow for treatment effect modification by adopting two different approaches in an IPD-MA context, namely the risk modelling and the effect modelling approach. For both approaches, we will first discuss how to combine IPD from RCTs comparing the same two treatments. We will then discuss how these methods can be extended to include randomized data from multiple treatments, real-world data, and published aggregate data. We will discuss statistical software to implement these approaches and provide example code as supporting information. Real examples will be used throughout to illustrate the main methods.

## Estimating heterogeneous treatment effects in pairwise meta-analysis
Expand Down Expand Up @@ -64,7 +80,7 @@ The simulated dataset contains information on the following variables:
#| warning: false
dstbl <- ds %>% mutate(treat = as.factor(treat),
studyid = as.factor(studyid))
table1(~ z1+z2+studyid | treat, data=dstbl)
table1(~ z1+z2+studyid | treat, data = dstbl)
```

#### Model fitting
Expand All @@ -74,7 +90,7 @@ ipd <- with(ds, ipdma.model.onestage(y = y, study = studyid, treat = treat,
X = cbind(z1, z2),
response = "normal",
shrinkage = "none"),
type="random")
type = "random")
```

The JAGS model can be accessed as follows:
Expand Down Expand Up @@ -165,7 +181,7 @@ The simulated dataset contains information on the following variables:
#| warning: false
dstbl <- ds2 %>% mutate(treat = as.factor(treat),
studyid = as.factor(studyid))
table1(~ w1+w2+studyid | treat, data=dstbl)
table1(~ w1+w2+studyid | treat, data = dstbl)
```

#### Model fitting
Expand All @@ -184,7 +200,7 @@ ipd2 <- with(ds2, ipdma.model.onestage(y = y, study = studyid, treat = treat,
X = cbind(w1, w2),
response = "binomial",
shrinkage = "laplace"),
type="random", hy.prior = list("dunif", 0, 1))
type = "random", hy.prior = list("dunif", 0, 1))
ipd2$model.JAGS
samples <- ipd.run(ipd2, n.chains = 2, n.iter = 20,
Expand Down Expand Up @@ -496,11 +512,11 @@ samps4.3 <- coda.samples(jags.m, params, n.iter = 50)
summary(samps4.3)
# calculate treatment effects
samples.all=data.frame(rbind(samps4.3[[1]], samps4.3[[2]]))
newpatient= c(1,2)
samples.all = data.frame(rbind(samps4.3[[1]], samps4.3[[2]]))
newpatient = c(1,2)
median(
samples.all$delta.2.+samples.all$gamma.1.1.*newpatient[1]+
samples.all$delta.2. + samples.all$gamma.1.1.*newpatient[1] +
samples.all$gamma.2.1.*newpatient[2]
)
Expand Down

0 comments on commit 836d350

Please sign in to comment.