Announcement

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

  • CMP Mata Run-time error

    Hi all,

    I'm running user-written command cmp for simultaneous equation models with random coefficients. The system has 5 equations and after fitting the five equations, Stata shows an error below: I wonder if anyone knows why this error occurs and how to fix it.

    Thanks
    Click image for larger version

Name:	error.jpg
Views:	1
Size:	563.9 KB
ID:	1675278



  • #2
    You unfortunately do not choose to share with us the actual command you ran.

    I will guess that error message is telling you that you used either the redraws() or ghkdraws() option and specified the type(halton) suboption, or did not specify the type() suboption and cmp used halton as the default. It is advising you that having done so, your problem is too large for type(halton) and recommends that you instead use the type(random) suboption to the redraws() or ghkdraws() option.

    This is just a guess; the author of cmp David Roodman is active on Statalist and may be able to enlighten us further.

    I note that the latest version of cmp installed from SSC just now is given as
    Code:
    . which cmp
    /.../Application Support/Stata/ado/plus/c/cmp.ado
    *! cmp 8.7.3 21 July 2022
    *! Copyright (C) 2007-22 David Roodman
    so if you have an older version, you should update it and try again in case the latest version corrects the problem.

    Comment


    • #3
      I consider a crash like that to be a bug. It would help me diagnose it if you sent me exact data and code that causes it. Or at least the code if it is not possible to share the data.

      Comment


      • #4
        Originally posted by David Roodman View Post
        I consider a crash like that to be a bug. It would help me diagnose it if you sent me exact data and code that causes it. Or at least the code if it is not possible to share the data.
        Hi William and David,

        Thanks a lot for your reply. Below are the codes I used. I have 5 simultaneous equations and 40,000 obs. brand dummy has 3000 categories. Please see if the code helps and look forward to your reply!

        ssc install cmp


        cmp setup

        eststo: cmp(lndaily_quantity=C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10 daily_sku_avg_promotion_d1 daily_price_avg_d1 lninter_timing lnl_purchase_quantity lnconsumertenure lndelivery_cost daily_weight_d daily_size_d lnlength lnrain lntemp i.user_type i.status i.income_level i.new_id i.subcat31 i.delivery i.public_holiday i.week i.age i.brandi1||hktv_ad_id:C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10 daily_sku_avg_promotion_d1 daily_price_avg_d1)(lninter_timing=C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10 daily_sku_avg_promotion_d1 daily_price_avg_d1 lnl_purchase_quantity lnl_inter_timing lnconsumertenure lndelivery_cost daily_weight_d daily_size_d lnlength lnrain lntemp i.user_type i.status i.income_level i.new_id i.subcat31 i.delivery i.public_holiday i.week i.age i.brandi1||hktv_ad_id:C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10 daily_sku_avg_promotion_d1 daily_price_avg_d1) (daily_price_avg_d1=C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10 l_daily_price_avg_d1 lnconsumertenure lndelivery_cost daily_weight_d daily_size_d lnlength lnrain lntemp i.user_type i.status i.income_level i.new_id i.subcat31 i.delivery i.public_holiday i.week i.age i.brandi1||hktv_ad_id:C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10) (daily_sku_avg_promotion_d1=C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10 l_daily_sku_avg_promotion_d1 daily_price_avg_d1 lnconsumertenure lndelivery_cost daily_weight_d daily_size_d lnlength lnrain lntemp i.user_type i.status i.income_level i.new_id i.subcat31 i.delivery i.public_holiday i.week i.age i.brandi1||hktv_ad_id:C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10 daily_price_avg_d1) (lnnonc10=lncovidnonc10_2 lnrain_1 lntemp_1), ind( $cmp_cont $cmp_cont $cmp_cont $cmp_cont $cmp_cont)

        Comment


        • #5
          Originally posted by David Roodman View Post
          I consider a crash like that to be a bug. It would help me diagnose it if you sent me exact data and code that causes it. Or at least the code if it is not possible to share the data.
          Hi David,

          I revised the code below and got another error. I wonder if you know how to revise the option "nolr redraws(101, type(random))" part. Do you know how to revise the number of the draws based on the dataset?

          Thanks!


          cmp setup

          eststo: cmp(lndaily_quantity=C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10 daily_sku_avg_promotion_d1 daily_price_avg_d1 lninter_timing lnl_purchase_quantity lnconsumertenure lndelivery_cost daily_weight_d daily_size_d lnlength lnrain lntemp i.user_type i.status i.income_level i.new_id i.subcat31 i.delivery i.public_holiday i.week i.age i.brandi1||hktv_ad_id:C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10 daily_sku_avg_promotion_d1 daily_price_avg_d1)(lninter_timing=C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10 daily_sku_avg_promotion_d1 daily_price_avg_d1 lnl_purchase_quantity lnl_inter_timing lnconsumertenure lndelivery_cost daily_weight_d daily_size_d lnlength lnrain lntemp i.user_type i.status i.income_level i.new_id i.subcat31 i.delivery i.public_holiday i.week i.age i.brandi1||hktv_ad_id:C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10 daily_sku_avg_promotion_d1 daily_price_avg_d1) (daily_price_avg_d1=C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10 l_daily_price_avg_d1 lnconsumertenure lndelivery_cost daily_weight_d daily_size_d lnlength lnrain lntemp i.user_type i.status i.income_level i.new_id i.subcat31 i.delivery i.public_holiday i.week i.age i.brandi1||hktv_ad_id:C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10) (daily_sku_avg_promotion_d1=C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10 l_daily_sku_avg_promotion_d1 daily_price_avg_d1 lnconsumertenure lndelivery_cost daily_weight_d daily_size_d lnlength lnrain lntemp i.user_type i.status i.income_level i.new_id i.subcat31 i.delivery i.public_holiday i.week i.age i.brandi1||hktv_ad_id:C_lnnonc10 C_lncovidnonc10 C_lntime1 C_lntime1_lnnonc10 C_lntime1_lncovidnonc10 daily_price_avg_d1) (lnnonc10=lncovidnonc10_2 lnrain_1 lntemp_1), ind( $cmp_cont $cmp_cont $cmp_cont $cmp_cont $cmp_cont) nolr redraws(101, type(random))
          Click image for larger version

Name:	error3.jpg
Views:	1
Size:	735.8 KB
ID:	1675551


          Click image for larger version

Name:	error2.jpg
Views:	1
Size:	446.6 KB
ID:	1675552

          Comment


          • #6
            I will look at. cmp shouldn't crash like that, but this seems like a hugely ambitious model, with at least 12000 parameters, which one the one hand is a lot, and on the other may not be many for 40000 observations. And estimating correlations among those 33(?) random effects and coefficients--there are 33*(33-1)/2=528 of those. Look at the covariance() options to remove some of those from the model.

            Comment


            • #7
              Originally posted by David Roodman View Post
              I will look at. cmp shouldn't crash like that, but this seems like a hugely ambitious model, with at least 12000 parameters, which one the one hand is a lot, and on the other may not be many for 40000 observations. And estimating correlations among those 33(?) random effects and coefficients--there are 33*(33-1)/2=528 of those. Look at the covariance() options to remove some of those from the model.
              Hi David,

              Thanks for your comments. Unfortunately, the model is finalized for now and we can't remove variables based on their meanings for our interpretation. I wonder if changing the specification of the option would work?

              Comment


              • #8
                I'm cautiously optimistic that I've fixed both crashes. Install the latest version with:
                Code:
                net install cmp, replace from(https://raw.github.com/droodman/cmp/v8.7.4)
                However, as I say, any crashes aside, I'll be impressed if this works.

                You could look at ivreghdfe for estimating parts of the model separately (though it cannot do random effects and coefficients). Or using the Frisch-Waugh-Lovell theorem, you could use "reghdfe ..., resid" followed by "predict ..., resid" commands to partial out all those shared dummy sets from the other variables and then run cmp on the other variables, so modified. This would greatly reduce the number of parameters in the cmp model. Even then I doubt it will be able to converge without some restrictions on the correlation structure of the random effects and coefficients.

                --David
                Last edited by David Roodman; 28 Jul 2022, 11:51.

                Comment


                • #9
                  Originally posted by David Roodman View Post
                  I'm cautiously optimistic that I've fixed both crashes. Install the latest version with:
                  Code:
                  net install cmp, replace from(https://raw.github.com/droodman/cmp/v8.7.4)
                  However, as I say, any crashes aside, I'll be impressed if this works.

                  You could look at ivreghdfe for estimating parts of the model separately (though it cannot do random effects and coefficients). Or using the Frisch-Waugh-Lovell theorem, you could use "reghdfe ..., resid" followed by "predict ..., resid" commands to partial out all those shared dummy sets from the other variables and then run cmp on the other variables, so modified. This would greatly reduce the number of parameters in the cmp model. Even then I doubt it will be able to converge without some restrictions on the correlation structure of the random effects and coefficients.

                  --David
                  Hi David,

                  Thanks a lot for your time! I rerun the code below and got error :

                  Click image for larger version

Name:	error4.jpg
Views:	1
Size:	991.1 KB
ID:	1675580


                  I wonder if you have any insights about this?

                  Thanks a lot!

                  Comment


                  • #10
                    That looks less like a cmp bug and more like a normal error message for the user. It's saying one of the equations has no complete observations. Can you prove it wrong?

                    Comment


                    • #11
                      Originally posted by David Roodman View Post
                      That looks less like a cmp bug and more like a normal error message for the user. It's saying one of the equations has no complete observations. Can you prove it wrong?
                      Hi David,

                      I have used all these variables for fixed effect before and each of the variables has around 40,000 obs. So it's very confusing that the error says no observations. Is there any other possible reasons?

                      Comment


                      • #12
                        Originally posted by Melody Brown View Post

                        Hi David,

                        I have used all these variables for fixed effect before and each of the variables has around 40,000 obs. So it's very confusing that the error says no observations. Is there any other possible reasons?
                        Even when I run cmp separately now, there is same error.

                        Comment


                        • #13
                          Be a detective. Find the simplest example that causes the problem, then pinpoint what small change--dropping another variable, say--eliminates the error message. Then dig into whether you're right or the program's right. Look at the data. If you can demonstrate there's a bug, post the minimum working example of it.

                          Comment


                          • #14
                            Originally posted by David Roodman View Post
                            Be a detective. Find the simplest example that causes the problem, then pinpoint what small change--dropping another variable, say--eliminates the error message. Then dig into whether you're right or the program's right. Look at the data. If you can demonstrate there's a bug, post the minimum working example of it.
                            Hi David,

                            Thanks a lot for your suggestions. I finally find where went wrong:

                            https://raw.github.com/droodman/cmp/v8.7.4

                            I couldn't get access to the link above, it shows error 400: invalid request.

                            I wonder if you could have a look to see if the link works on your side?

                            Thanks a lot!

                            Comment


                            • #15
                              The instructions I posted work for me:

                              Code:
                              . net install cmp, replace from(https://raw.github.com/droodman/cmp/v8.7.4)
                              checking cmp consistency and verifying not already installed...
                              all files already exist and are up to date.

                              Comment

                              Working...
                              X