Announcement

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

  • #16
    Thanks for pointing that out. You can probably tell I'm a SAS programmer. Appreciate the suggestion on the error code. I'll check that out.

    Comment


    • #17
      You can probably tell I'm a SAS programmer.
      Don't worry--it's not fatal, and the brain damage is not permanent either.

      Comment


      • #18
        Ok. Back on this. Note this block of code from my modification of apc_ie:


        Code:
          *estimate;
          if "`exposure'"~="" local exposurestr "exposure(`exposure')";
          if "`offset'"~="" local offsetstr "offset(`offset')";
          `svypre' glm `varlist' `xnames' if `touse' [`weight' `exp'], `constant'
            `exposurestr' `offsetstr' scale(`scale') `options' ;
        
          *check whether a regressor was dropped;
        
          *if so, give up because we can't transform back to original coordinates;
          if `princomps'+`cshift'+`n_extra'>e(k) {;
            di as error "regressor collinear with age, period or cohort variables, or too many empty cells in age-by-period matrix";
            exit=405;
            };

        I've reset the exit to 405. Now, if I run the following commands:


        Code:
        svyset [pw=WTFA_SC3i], strata(STRATUMRi) psu(PSUi) singleunit(centered)
        
        apc_ie4 AMR2Ri /*
        */ if A_imputation_==1 , /*
        */ age(apc_agei)  period(apc_periodi) cohort(apc_cohorti) family(binomial) /*
        */  link(logit) iterate(20) /*
        */ svyopts("svy, subpop(agedom_reci)")
        
        if `c(rc)' == 405 {
        other code here...
        ]

        The program still stops (due to a data issue I need to address). I was anticipating the if statement picking up the 405 error and executing the code beneath it. What have I done wrong?

        Comment


        • #19
          No, your logic is wrong. In your first block of code, you exit with a return code of 405 if that particular condition about `princomps'+`cshift'... is satisfied. But if any other errors happen during the execution of -apc_ie4-, then it will exit with whatever error code is thrown by that particular problem. That will not be picked up by -if `c(rc)' == 405-. But more to the point, because your -apc_ie4- command is not preceded by -capture-, Stata has no reason not to break even when your particular condition is met. It has no way to look ahead and see that you plan to trap that error in another block of code.

          So, the short answer, is that you need to precede -apc-ie4- by -capture- (or, if you need to see the output, -capture noisily-). That way, Stata will continue after -apc_ie4- no matter what goes wrong there. If what goes wrong happens to be the condition that throws error code 405, then it will also go into your next block of code to handle that exception. Otherwise it will do whatever comes after that block.

          Comment


          • #20
            Perfect! Thanks for the tip.

            Comment


            • #21
              I would like to consider survey design effect when I use APC_IE package. Could you show me the procedure in detail? Thanks.

              Comment


              • #22

                Hi, Can someone explain what is exposure variable in the command below. I am very new to stata, any advice at this stage would be helpful. Regards, Jothees apc_ie death_f if age<=90, age(age) period(year) cohort(cohort) family(poisson) link(log) exposure(exp_f) agefx(A) cohortfx(C) periodfx(P)

                Comment


                • #23
                  Hi,
                  Can anyone explain what is exposure variable in apc_ie command? How to I calculate this ? is this neccessary for continous dependent variable as well ? regards, Jothees

                  Comment

                  Working...
                  X