Announcement

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

  • weights not constant within ID variable id

    Survival analysis using marginal-structural-model methodology requires that weights (pweights=inverse of the propensity score for treatment=IPW) are allowed to vary per time point per individual.

    So:

    Code:
    stset time [pweight=varying_weight], failure(death) id(id)
    using this e.g. data

    Code:
    clear
    input float(id death time x varying_weight stable_weight)
    1 0 1  .3488717 .3333333 .3
    1 0 2  .2668857       .5 .3
    1 1 3  .8689333       .2 .3
    2 0 1  .3508549        1 .5
    2 0 2 .07110509       .5 .5
    2 0 3 .32336795      .25 .5
    2 0 4  .5551032       .2 .5
    2 1 5   .875991       .2 .5
    3 0 1 .20470947      .25 .4
    3 0 2  .8927587       .5 .4
    3 0 3  .5844658      .25 .4
    3 0 4  .3697791 .3333333 .4
    3 1 5  .8506309        1 .4
    end
    gives the error "weights not constant within ID variable id".

    A workaround would be to not use survival analysis but its approximate equivalent: "pooled logistic regression" (results in duplicating rows of data to emulate the time structure) - but that comes with its own problems...

    Perhaps I'm missing something - IS there a way Stata could somehow handle per-panel-varying-weights?

    Best

    Stefan
    Last edited by Stefan Kreisel; 06 May 2022, 06:11.

  • #2
    Not much action here. I've posted this query several times in different flavours over the past years and as now: no reaction. It seems to be an off-topic, that's fair enough. I'm wondering though if the meta-topic behind the query, namely "causal analysis" of observational data via the framework of "g-methods" - which resonates in the D. Rubin / J. Robins more statistical/epidemiological potential-outcome world - might simply be un-appealing or lost-in-translation to the more statistical/econometric oriented Stata-crowd (that's a bit of a steep attribution...). With treatment effects Stata has really gone a long way! It would be cool if we could do longitudinal/repeated-measures (survival) stuff with time-varying treatments/confounders in Stata and not having to turn off to R.
    Cheers

    Comment


    • #3
      have you looked at https://www.stata-journal.com/articl...rticle=st0075? or -gformula- from SSC?

      Comment


      • #4
        Stefan
        I came across your post in differrent occasions but had nothing helpful to reply.
        De minimis: if Rich's suggestion is the following gformula: Estimating causal effects in the presence of time-varying confounding or mediation using the g-computation formula the working link seems to be: http://www.stata-journal.com/article...article=st0238
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Carlo Lazzaro has the original; however, the version at SSC is a later version (note that I am not particularly a fan and have not used either) and thus, might be better (same author)

          Comment


          • #6
            Thanks Rich Goldstein I was not aware of that.
            Admittedly, I've never used the community-contributed module -gformula-. However, I was curious about that and clicked on the link that you kindly shared, but it gave me back an error message.
            That's why I tried a different approach without knowing that the two contributions differ.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Stefan Kreisel , thanks for the link to the expository article on g-methods from the IJE. Given the hint provided by the visible text in the nonfunctional link in #3, I think the intended reference is to: Fewell et al., "Controlling for time–dependent confounding using marginal structural models", Stata Journal, Volume 4 Number 4: pp. 402-420 for which a working link is: https://www.stata-journal.com/articl...article=st0075 But Carlo's link to the article on -gformula- looks like an excellent reference also. I am curious if these programs are a complete answer to the needs you express in your query or if on review you think Stata users need something else to answer your initial question.

              Comment


              • #8
                Woops - haven't been online - and now this :--)
                Thanks for the reference to Daniel's gformula ado. I did in fact implement it some time ago to some use (after an introduction by the author, being lost-in-translation previously...) BTW. Rhian Daniel has written a technical paper comparing the benefits of different g-"approaches" -> https://pubmed.ncbi.nlm.nih.gov/23208861/). But there are some limitations (such as, if I understand correctly, gformula is a modelling excercise based on standardization via g-computation and does not implement MSMs using the IPW-approach; see also pp161 in the finally completed and excellent Hernán+Robins) - and that is where Fewell's contribution did come in very handy! I've written a somewhat less technical replica of how-to-implement using Stata -> https://pubmed.ncbi.nlm.nih.gov/29268707/ , being an MD without much affinity to formulas...). Clearly, if Stata would "just implement them all", that would be really nice. Till then, I guess its user-written-routines and no per-panel-varying-weights. Best!

                Comment


                • #9
                  @Stefan Kreisel , thanks for these references. Your own article on the impact of exercise is an interesting example of how sensitive results can be to model specifications. I particularly appreciate the link to the Hernán+Robins (2020) reference, which is the best treatment of causal inference I've seen since Angrist & Pischke . As an economist, I am grateful for Hernám & Robins' introduction to Chapter 16 which reads:

                  The causal inference methods described so far in this book rely on a key untestable assumption: all variables needed
                  to adjust for confounding and selection bias have been identified and correctly measured. If this assumption is
                  incorrect–and it will always be to a certain extent–there will be residual bias in our causal estimates.

                  It turns out that there exist other methods that can validly estimate causal effects under an alternative set
                  of assumptions that do not require measuring all adjustment factors. Instrumental variable estimation is one of
                  those methods. Economists and other social scientists reading this book can breathe now. We are finally going to
                  describe a very common method in their fields, a method that is unlike any other we have discussed so far.
                  It seems to me that, depending on the data-generating-process, time-dependent confounders could be examples of endogenous variables with unmeasured determinants and thus might call for instrumental variable techniques. Thus I wonder whether structural modeling (i.e. MSM) with instrumental variables, as suggested in Paul Allison 's blog might be a helpful approach.
                  Last edited by Mead Over; 29 May 2022, 17:21.

                  Comment

                  Working...
                  X