Flexible Mediation Analysis Using Natural Effect Models
Overview
Run flexible mediation analyses using natural effect models as described in Lange, Vansteelandt and Bekaert (2012) DOI:10.1093/aje/kwr525, Vansteelandt, Bekaert and Lange (2012) DOI:10.1515/2161-962X.1014 and Loeys, Moerkerke, De Smet, Buysse, Steen and Vansteelandt (2013) DOI:10.1080/00273171.2013.832132.
- Issue related to changes missing package anchors in the "Rd cross-references" check (in version 0.6-10) fixed
From NEWS in the release
Install
Health
ERRORexamplesr-devel-linux-x86_64-debian-gcc
Running examples in ‘medflex-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: neImpute.default
> ### Title: Expand the dataset and impute nested counterfactual outcomes
> ### Aliases: neImpute.default
>
> ### ** Examples
>
> data(UPBdata)
>
> ## example using glm imputation model with binary exposure
> fit.glm <- glm(UPB ~ factor(attbin) + negaff + gender + educ + age,
+ family = binomial, data = UPBdata)
> impData <- neImpute(fit.glm)
> head(impData)
id attbin0 attbin1 att attcat negaff initiator gender educ age
1 1 1 1 1.0005617 M 0.840461 myself F M 41
2 1 0 1 1.0005617 M 0.840461 myself F M 41
3 2 0 0 -0.7085889 L -1.257465 both M M 42
4 2 1 0 -0.7085889 L -1.257465 both M M 42
5 3 0 0 -0.7085889 L -1.202256 both F H 43
6 3
...[truncated]...
1 M 0.840461 myself F M 41 0.5106796 1
2 1 low high 1 M 0.840461 myself F M 41 0.4059912 1
3 2 low low 0 L -1.257465 both M M 42 0.1999050 0
4 2 high low 0 L -1.257465 both M M 42 0.2761580 0
5 3 low low 0 L -1.202256 both F H 43 0.1668007 0
6 3 high low 0 L -1.202256 both F H 43 0.2341212 0
>
> # test with gam?
> if (requireNamespace("gam", quietly = TRUE)) {
+ library(gam)
+ impFit4 <- gam(UPB ~ att + negaff + gender + educ + age, family = binomial, data = UPBdata)
+ impData4 <- neImpute(impFit4)
+ head(impData2); head(impData4)
+ # check!
+ }
Loading required package: foreach
Loaded gam 1.22-7
Attaching package: ‘gam’
The following object is masked from ‘package:VGAM’:
s
Error in a$specials[[i]] : subscript out of bounds
Calls: neImpute ... predict.glm -> predict.lm -> delete.response -> off
Execution halted- ERROR12 OK, 1 ERROR2026-10-24
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-06-09
- ERROR12 OK, 1 ERROR2026-06-08
Show 1 earlier changeHide 1 earlier change
- OK14 OK2026-03-10
Documentation
- Help pages
- 15
- Examples that run
- 100%11 run in a plain check
- Exported functions with examples
- 60%
- Documented parameters
- 100%
- Return-value docs
- 80%
- Help pages citing references
- 27%
Downloads
Repository
- PRs merged (all time)
- 100%
- Median days to close, 50 most recently updated closed issues
- 12
- Median days to close, 50 most recently updated closed PRs
- 6
Stars over time
Forks over time
Issues over time
PRs over time
2 development-tooling and community-health practices detected across 2 families in the upstream repository
Checks run against github.com/jmpsteen/medflex on 2026-10-21.
Dependencies
Installing medflex adds 64 packages (33 with compiled code, 66 MB of source tarballs). Heaviest: stringi 11 MB, TH.data 8.2 MB, ggplot2 6.0 MB.
Code & Tests
Datasets
People & History
Pick two releases to compare their code metrics.
- RR 4.6.0 released · 2026-04-24
- 0.6-11Latest
- RR 4.5.0 released · 2025-04-11
- RR 4.4.0 released · 2024-04-24
- unarchivedReturned to CRAN2023-06-22
- 0.6-102023-06-22 · diff ↗
- RR 4.3.0 released · 2023-04-21
- archivedRemoved from CRAN2023-04-13issues were not corrected in time
- RR 4.2.0 released · 2022-04-22
- RR 4.1.0 released · 2021-05-18
- unarchivedReturned to CRAN2020-08-03
- 0.6-72020-08-03 · diff ↗
- archivedRemoved from CRAN2020-05-01check issues were not corrected despite reminders
- RR 4.0.0 released · 2020-04-24
- RR 3.6.0 released · 2019-04-26
- 0.6-62018-09-03 · diff ↗
Show 11 earlier eventsHide 11 earlier events
Package metadata
- First published
- 2014-12-11
- Total releases
- 10 / 12 yrs
- License
- GPL-2 OSI
- Minimum R
- ≥ 3.1.2
- Bundled data
- 4.6 KB / 1 file
- Download size
- 626 KB
Cite
Cite this package
Run in R for the authors' entry:
citation("medflex")The package provides a citation file, so citation() returns the authors' own entry.
It points to 10.18637/jss.v076.i11, 10.1093/aje/kwr525, 10.1515/2161-962x.1014, 10.1080/00273171.2013.832132.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-24, which the citation names so these numbers can be found later. More on citing and the projects behind them.