Announcement

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

  • error on demandsys

    Hello,

    I would like to run an AIDS model and although my budget shares are between 0 and 1 and receive an error that they are not. I am not sure how to identify what is the problem.

    Thank you for your help!

  • #2
    Show us the actual command and error message. You should be able to easily see if all share variables are within (0,1) using

    Code:
    summarize

    Comment


    • #3
      Hi Andrew,

      Thank you for the response, I am attaching the output. As you will see the summarize command does not show any values out of the [0, 1] range.

      Click image for larger version

Name:	Screen Shot 2023-11-27 at 4.57.40 PM.png
Views:	1
Size:	23.5 KB
ID:	1735314

      Comment


      • #4
        The error message appears to be misleading. Can you share your data? If so, copy and paste the output of the following:

        Code:
        dataex exp* unit*

        Comment


        • #5
          Unfortunately I can't because of confidentiality issues, but your comment prompted me to think that having the sum of expenditure shares slightly greater than 1 because of rounding might be the problem. I am trying to fix it so that the shares sum up to 1, but in some cases I still get 1.01. Do you believe that this might be a problem or it is something else?

          Thank you again for your response!

          Comment


          • #6
            The error message would be different if that were the case. There must be something else peculiar with your dataset. Consider:

            Code:
            webuse food_consumption, clear
            foreach var of varlist w*{
                replace `var'= round(`var',.01)
            }
            demandsys aids w*, prices(p*) expenditure(expfd)
            Res.:

            Code:
            . demandsys aids w*, prices(p*) expenditure(expfd)
            invalid values found
                The share variables must sum to 1 for each observation in the estimation sample. Some
                observations' shares do not sum to 1.
            r(459);
            Start by updating Stata; there may have been an update to the command at some point. If the update does not fix the issue, someone will ultimately need to examine your dataset to diagnose the problem. Here is how to contact Technical Services: https://www.stata.com/support/tech-support/contact/. Alternatively, you can attempt to create a fake dataset based on your real data that reproduces the issue and use dataex to present that data here.

            Code:
            update all
            Last edited by Andrew Musau; 28 Nov 2023, 00:25.

            Comment


            • #7
              I don't know anything worth knowing about demand systems but if there is a constraint that shares must add to exactly 1 or 100% that clashes with data reporting.

              Here are some references to long-standard papers which explain and analyse how often rounding can produce small anomalies in totals without any person or program being incorrect.

              Diaconis, P. and D. Freedman. 1979. On rounding percentages. Journal of the American Statistical Association 74: 359--364.

              Mosteller, F., C. Youtz and D. Zahn. 1967. The distribution of sums of rounded percentages. Demography 4: 850--858.
              Reprinted in Fienberg, S. E. and D. C. Hoaglin (eds) 2006. Selected Papers of Frederick Mosteller. New York: Springer, 399--411.

              Comment


              • #8
                Could you please tell demandsys command is included in which stata version? I tried using it in stata 16 but it doesn't have it.

                Comment

                Working...
                X