Learn R Programming

rqlm (version 4.5-1)

ttemsm: Pooled logistic regression for target trial emulation

Description

This function implements pooled logistic regression for use in target trial emulation. Before running the function, the user must prepare an analysis dataset by stacking the sequential‐trial datasets in long format. If inverse probability weights (such as IPCW) are required, the corresponding weight variable should be included in the dataset in advance. The regression model is specified through the formula argument, and the individual identifier must be provided via the id argument, so that cluster‐robust standard errors are computed across repeated trials for each individual. When a weight variable is specified through weights, the function performs inverse probability weighting. The output includes point estimates of the hazard ratio, corresponding confidence intervals, and P-values.

Usage

ttemsm(formula, data, id, weight=NULL, family=quasibinomial(link="cloglog"), 
eform=TRUE, cl=0.95, digits=4, var.method="MBN")

Value

An object of class "ttemsm" containing the following components.

  • call: The matched function call.

  • formula: The model formula.

  • coefficients: Coefficient estimates on the model scale, irrespective of eform.

  • se: Cluster-robust standard errors on the coefficient scale.

  • cl, cu: Lower and upper confidence limits on the coefficient scale.

  • z, p: Wald statistics and two-sided P-values.

  • eform, cl.level, digits, var.method: The corresponding analysis and display settings.

  • vcov: The full estimated covariance matrix.

  • model: The fitted glm object.

  • n: The number of analysis rows after missing-value handling.

  • n.clusters: The number of independent participants.

Arguments

formula

An object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted.

data

A data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model.

id

Column name in data identifying individual participants, supplied without quotes or as one character string. Missing IDs in the analysis sample are not allowed.

weight

Column name in data containing the analysis weights, supplied without quotes or as one character string. The default NULL uses uniform weights of one.

family

A description of the error distribution and link function to be used in the model. When the goal is to estimate hazard ratios using a discrete-time Cox model, the complementary log–log (cloglog) link should be used. When the objective is to estimate risk differences or cumulative incidence (e.g., via the g-formula or standardization), the logit link should be used.

eform

A logical value that specify whether the outcome should be transformed by exponential function (default: TRUE)

cl

Confidence level for calculating confidence intervals (default: 0.95)

digits

Number of decimal places in the output (default: 4).

var.method

Method for estimating standard errors. Standard cluster-robust variance estimator (standard) and Morel-Bokossa-Neerchaal-type corrected cluster-robust estimator (MBN) are available (default: MBN).

Details

The methods coef, vcov, and family are available; see rqlm-methods. The full covariance matrix can be used for contrasts involving several coefficients. Predictions from model are available through predict, but its default prediction standard errors are model-based, not based on the outer object's robust covariance. Supplied weights are treated as fixed. At least two participants are needed for standard; MBN requires more independent participants than model parameters. The existing MBN formula, including the cluster-count adjustment in sandwich::vcovCL before the additional MBN factors, is retained.

This function is retained for compatibility. Further target trial emulation development is provided in the TTE package, including TTE::discsurvreg; its arguments and defaults are not identical.

References

Gosho, M., Ishii, R., Noma, H., and Maruo, K. (2023). A comparison of bias-adjusted generalized estimating equations for sparse binary data in small-sample longitudinal studies. Statistics in Medicine 42, 2711-2727.

Hernan, M. A., Alonso, A., Logan, R., et al. (2008). Observational studies analyzed like randomized experiments: an application to postmenopausal hormone therapy and coronary heart disease. Epidemiology 19, 766-779.

Hernan, M. A., Dahabreh, I. J., Dickerman, B. A., and Swanson, S. A. (2025). The Target Trial Framework for Causal Inference From Observational Data: Why and When Is It Helpful? Annals of Internal Medicine 178, 402-407.

Hernan, M. A., Wang, W., and Leaf, D. E. (2022). Target Trial Emulation: A Framework for Causal Inference From Observational Data. JAMA 328, 2446-2447.

Morel, J. G., Bokossa, M., and Neerchal, N. (2003). Small sample correction for the variance of GEE estimators. Biometrical Journal 45, 395-409.

Examples

Run this code
data(exdata04)

ttemsm( Y ~ A + L1 + L2 + L3 + time + I(time^2) + trial,
  data    = exdata04, id = ID, weight = w_pp,
  family = quasibinomial(link="cloglog"),  
  eform   = TRUE, cl = 0.95, var.method="standard")
# Pooled logistic regression for target trial emulation with cloglog link
# For estimating hazard ratios using a discrete-time Cox model

ttemsm( Y ~ A + L1 + L2 + L3 + time + I(time^2) + trial,
  data    = exdata04, id = ID, weight = w_pp,
  family = quasibinomial(link="logit"),
  eform   = TRUE, cl = 0.95, var.method="standard")
# Pooled logistic regression for target trial emulation with logit link
# For estimating RDs or cumulative incidence (e.g., via the g-formula)

ttemsm( Y ~ A + L1 + L2 + L3 + time + I(time^2) + trial,
  data    = exdata04, id = ID, weight = w_pp,
  eform   = TRUE, cl = 0.95, var.method="MBN")
# Pooled logistic regression for target trial emulation with cloglog link
# Morel-Bokossa-Neerchaal-type corrected SE estimator is used.

Run the code above in your browser using DataLab