Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Marginal structural models: estimating the controlled direct effect WITHIN imputations

    Hello,

    I am using marginal structural models to estimate the controlled direct effect of parenting practices on adolescent self-harm in the presence of time-dependent confounding.

    Variable list:
    propensity scores = IPTCW_withdrawal_mi_trunc
    dichotomous outcome = COPY_any_harm
    dichotomous exposure = COPY_mean_withdrawal_dich_MI
    mediator (quartiles) = COPY_quart_SDQ_comp_MI

    Using: Stata/SE 18.0

    I conducted multiple imputation using MICE and generated my propensity scores in the MI set data using “mi xeq:”. The problem I am having is with estimating effects within each imputation and then pooling the results.
    To date, I have been doing the following to svyset the data and obtain an estimate of the controlled direct effect:

    Code:
    mi svyset SPTN00 [pweight=IPTCW_withdrawal_mi_trunc], strata(PTTYPE2) fpc(NH2)
    mi estimate: svy: glm COPY_any_harm i.COPY_mean_withdrawal_dich_MI i.COPY_quart_SDQ_comp_MI, fam(poisson) link(log) nolog eform
    However, if I understand correctly, the svyset command acts globally, so even though the propensity scores vary across imputation, Stata is only using one set (from one imputation) of propensity scores to estimate the controlled direct effect when using the above code. The other svyset variables (SPTN00, PTTYPE2, and NH2) do not vary across imputations (i.e., complete data).

    I have tried several workarounds, but none seem to work. Example of one attempt:
    Code:
    .     scalar M = r(M)
    Code:
    .  forvalues m = 1/75 {
      2.     mi xeq `m': svy: glm COPY_any_harm i.COPY_mean_withdrawal_dich_MI i.COPY_quart_SDQ_comp_MI [pweight=IPTCW_withdrawal_mi_trunc], ///
    > fam(poisson) link(log) nolog eform
      3. }
    
    m=1 data:
    -> svy: glm COPY_any_harm i.COPY_mean_withdrawal_dich_MI i.COPY_quart_SDQ_comp_MI [pweight=IPTCW_withdrawal_mi_trunc], fam(poisson) link(log) nolog eform
    weights not allowed with the svy prefix
        The svy prefix assumes survey weights were already specified using svyset.
    r(101);
    
    end of do-file
    
    r(101);
    I cannot seem to combine “mi xeq” with svyset or use “pweight” without svyset. Is it possible to svyset and estimate a model within each imputation and then pool (using Rubin’s rules) to obtain an overall measure of association?

    Thank you kindly,
    Nicole G. Hammond
    Last edited by Nicole Hammond; 15 Jul 2025, 10:14.

  • #2
    Originally posted by Nicole Hammond View Post
    I cannot seem to combine “mi xeq” with svyset or use “pweight” without svyset.
    Just a comment on your code in relation to your question:


    . forvalues m = 1/75 {
    2. mi xeq `m': svy: glm COPY_any_harm i.COPY_mean_withdrawal_dich_MI i.COPY_quart_SDQ_comp_MI [pweight=IPTCW_withdrawal_mi_trunc], ///
    fam(poisson) link(log) nolog eform
    3. }

    m=1 data:
    svy: glm COPY_any_harm i.COPY_mean_withdrawal_dich_MI i.COPY_quart_SDQ_comp_MI [pweight=IPTCW_withdrawal_mi_trunc], fam(poisson) link(log) nolog eform
    weights not allowed with the svy prefix
    The svy prefix assumes survey weights were already specified using svyset.
    r(101);

    end of do-file
    Here, you are using both the -svy- prefix and specifying -pweight- (highlighted), which causes Stata to throw an error. You can use either svy (after setting survey design with svyset) or specify weights directly, but not both at the same time.

    Also, note that -pweights- are only equivalent to using the svy prefix if there is no stratification, which is not the case in your setup.

    Comment

    Working...
    X