Announcement

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

  • #16
    Sorry, try this link.
    Steve Samuels
    Statistical Consulting
    [email protected]

    Stata 14.2

    Comment


    • #17
      Thank you all again for your help in resolving my query!

      Paul - I would like to check with you. In a previous thread (https://www.statalist.org/forums/for...r-net-survival), I was advised to create a timevar rather than using _t when using -predict- as below:
      range timevar_new 0 10 100
      predict s1_new, meansurv (at sex 1) timevar(timevar_new) Is this still an option when working with imputed data or should I use _t? Thanks again.
      Last edited by Laura Myles; 07 Nov 2018, 10:27.

      Comment


      • #18
        Thanks Steve Samuels for the nice words about our course. Thanks Laura Myles for identifying this problem. Here is the link to the exercises for our course. I have updated the exercise (285) on multiple imputation. The do file for that exercise can be found here.

        Comment


        • #19
          Originally posted by Laura Myles View Post
          Paul - I would like to check with you. In a previous thread (https://www.statalist.org/forums/for...r-net-survival), I was advised to create a timevar rather than using _t when using -predict- as below:
          Code:
          range timevar_new 0 10 100
          predict s1_new, meansurv (at sex 1) timevar(timevar_new)
          Is this still an option when working with imputed data or should I use _t?
          Yes, this is the recommended option. By default, -predict- provides predictions for all observations at values of _t. By specifying -timevar(_t)- we are just forcing what should be the default behaviour. I made the predictions at _t to avoid adding extra complexity to the code. The dataset in my example has over 15000 observations and we don't need that many predictions so in practice I would use another temptime variable, such as in your example where we only predict for 100 values of time. One of the reasons it took so long to spot this bug is that most of us routinely use temptime when making predictions.

          Comment


          • #20
            Paul Dickman Thanks again for the clarification!

            Comment


            • #21
              Hi,

              I agree with Paul Dickman that using the timevar() option is often preferable, but you do need to be careful here. We did not see what you wanted to with the predictions. Your original question was around the following
              Code:
               
               mi predictnl survimp2 = predict(survival at(agegrp 2) timevar(_t)) using mi_stpm2
              and we found a solution on how to replicate this. With this you could plot survimp2 vs _t at each level of stage, e.g.
              Code:
              line survimp2 _t if stage==1


              There is an explanation of using the timevar() option here. https://pclambert.net/software/stpm2/stpm2_timevar/

              In the recent code you used the meansurv() option. This predicts marginal survival functions rather than conditional survival functions. Essentially it predicts a survival curve for each individual in your study and then takes an average of the N survival curves. Use of the at() option forces the specified covariates to take specific values.

              So in most cases when you use the
              timevar() option, if you want conditional survival curves, (i.e. for a specific covariate pattern), you should specify all covariate values in the at() option or potentially use the zeros option as well to force unspecified covariates to be zero.

              When using meansurv you only want to specify covariates which you want to force to take specific values, for example when making contrasts between marginal survival functions.

              Paul

              Comment


              • #22
                Hello,

                I am trying to estimate time-dependent marginal hazard ratios in multiply imputed data.

                I have been doing this successfully in complete-case data with standsurv:

                Code:
                standsurv,  at1(var1 0) at2(var1 1) ci contrast(ratio) hazard  contrastvar(hratio_var1) timevar(_t)
                I have tried using mi predictnl with no luck:

                Code:
                mi predictnl hrimp = predict(hr hrnum(var1 1)  timevar(_t) )  using mi_stpm2 , ci(lci uci)  force
                Can anyone suggest code to do this?

                In a related matter, I have also been trying to calculate time-dependent attributable fractions in MI data with no success but can do so in complete-case data.

                Surely others would find the answer useful.

                Thank you,
                Pavel
                Last edited by Pavel Roshanov; 24 Apr 2021, 20:26.

                Comment


                • #23
                  Providing a fully-worked example including data would make it easier to answer.

                  Comment


                  • #24
                    Absolutely. Here is one modifying your code on the colon cancer dataset:

                    Code:
                    set more off
                    use http://pauldickman.com/data/colon.dta, clear
                    
                    stset surv_mm, failure(status=1 2) scale(12) exit(time 10*12)
                    gen _age = min(int(age + _t),99)
                    gen _year = int(yydx + mmdx/12 + _t)
                    merge m:1 _year sex _age using http://pauldickman.com/data/popmort
                    keep if _merge==3
                    replace stage=. if stage==0
                    
                    sts gen H=na
                    
                    gen timevar = .
                    replace timevar = 1 in 1
                    replace timevar = 2 in 2
                    replace timevar = 3 in 3
                    replace timevar = 4 in 4
                    replace timevar = 5 in 5
                    replace timevar = 6 in 6
                    replace timevar = 7 in 7
                    replace timevar = 8 in 8
                    replace timevar = 9 in 9
                    replace timevar = 10 in 10
                    
                    mi set flong
                    mi register imputed stage
                    
                    
                    
                    set seed 29390
                    mi impute chained (mlogit) stage = i.subsite sex i.agegrp H _d, add(10)
                    
                    tab(agegrp),gen(agegrp)
                    tab(stage),gen(stage)
                    
                    mi estimate, dots cmdok sav(mi_stpm2,replace): ///
                        stpm2 stage1 sex, df(5) bhaz(rate) scale(hazard) nolog  ///
                        tvc(stage1) dftvc(stage1:2)
                        
                    mi predictnl hrimp = predict(hr hrnum(stage1 1)  hrdenom(stage1 0) timevar(timevar))  using mi_stpm2, ci(mill miul) force
                    /*output here is:
                    option hr not allowed
                    predict(hr hrnum(stage1 1)  hrdenom(stage1 0) timevar(timevar)) invalid
                    */
                    
                    // compare predictions to first imputation
                    stpm2 stage1 sex if _mi_m==1, df(5) bhaz(rate) scale(hazard) nolog  ///
                        tvc(stage1) dftvc(stage1:2)
                    
                    //using predict
                    predict hrcc if _mi_m==1, hrnum(stage1 1) hrdenom(stage1 0) timevar(timevar) ci
                    
                    //using standsurv
                     standsurv if _mi_m==1,  at1(stage1 0 ) at2(stage1 1) ci contrast(ratio) hazard  contrastvar(hratio_stage1) timevar(timevar)
                     
                      list timevar hrcc hrcc_lci hrcc_uci  hratio_stage1 hratio_stage1_lci hratio_stage1_uci  if inlist(timevar,1,2,3,4,5,6,7,8,9,10) & _mi_m==1
                      
                    /*output here shows that standsurv and predict would give nearly identical results:
                    
                            | timevar        hrcc    hrcc_lci    hrcc_uci   hratio_~1   hrati~lci   hrati~uci |
                            |---------------------------------------------------------------------------------|
                     15565. |       1   .10844999   .09978368   .11786898   .10849877   .09983011   .11792017 |
                     15566. |       2   .15890791   .14671461   .17211458   .15901694   .14681975   .17222743 |
                     15567. |       3   .21908062   .19810078   .24228233   .21925888   .19826885   .24247105 |
                     15568. |       4   .29510389   .25943194   .33568075   .29536435   .25966927   .33596621 |
                     15569. |       5    .3795031   .32253015   .44653997   .37985286   .32283667   .44693868 |
                            |---------------------------------------------------------------------------------|
                     15570. |       6   .46547052   .38154234   .56786045   .46591051    .3819134   .56838174 |
                     15571. |       7   .54522721   .43228679   .68767477   .54575086   .43271411   .68831589 |
                     15572. |       8   .61209619   .47285049   .79234717   .61269039   .47332405   .79309198 |
                     15573. |       9   .66226365   .50314812   .87169787   .66291154   .50365777   .87252045 |
                     15574. |      10   .69521221    .5241272   .92214259   .69589645   .52466367   .92301392 |
                            +---------------------------------------------------------------------------------+
                    */

                    Comment


                    • #25
                      I wonder if anyone has any suggestions for this in a multiple imputation context.

                      Thanks very much,
                      Pavel

                      Comment


                      • #26
                        just following up on this in case anyone has suggestions

                        Comment


                        • #27
                          Originally posted by Steve Samuels View Post
                          I wrote to Paul Lambert about this error, and he replied:

                          "You can’t add a ci option here, but should add it as an option of the mi predictnl command, e.g., ci(lci uci)"
                          I hadn't realized that ci was an option of predictnl. The entire command also requires a force option, so the correct version would be:
                          Code:
                          mi predictnl survimp2 = predict(survival at(agegrp 2) timevar(_t)) using mi_stpm2, ci(surv_ll surv_ul) force
                          Hi, following on this one - is it possible here to change the method of the ci calculation? E.g., Wilson or Jeffreys? I have negative values from the CIs in my prediction, and thus I cannot plot them using a log scale. I'm trying alternatives...

                          Thanks!

                          Comment

                          Working...
                          X