Announcement

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

  • How to make a ttest with conditions?

    Hi! I don't know how to create a ttest for this null hypothesis:
    - H0: b1 +4b3 <= 50
    - H1: b1 +4b3 >50
    - (b2 ismultiplied by 0)

    The case is about tha variables that determinate the vote rate for a candidate to reelection. Growth is the first variable and Inflation is the second one.
    Now I need to solve the following case:
    Test if in an economy with growth=0 and inflation=4 the candidate can have more than the 50% of the votes.
    I attached the database

    Thank you very much!
    Andrés
    Attached Files
    Last edited by Andres Henriquez; 22 Oct 2019, 19:42.

  • #2
    Attachments, in general, are discouraged here. Many people are reluctant to download an attachment from a stranger. The most useful way to show example data is to use the -dataex- command. If you are running version 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    That said, your question is also unclear. Are b1 and b3 some kind of coefficients from a regression analysis? If so, then -lincom- will give you what you asked for. Read -help lincom- for the details. If b1 and b3 are variables in your data set, then just -gen combo - b1 + 4*b3- and then -ttest combo = 50-.

    Comment


    • #3
      Thank you very much Clyde. You have helped me so much.
      And about your cuestion, b1, b2 and b3 are coefficients from a regression analysis. The variables are vote, growth, and inflation. In this case growth=0 and inflation=4, so the H0 will be
      b1 +4b3 <= 50.
      I'm trying to understand how to use lincom.

      This is the output that I have from execute data ex:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(year vote party person duration war growth inflation goodnews)
      1880 50.22 -1 0 1.75 0 3.879 1.974 9
      1884 49.846 -1 0 2 0 1.589 1.055 2
      1888 50.414 1 1 0 0 -5.553 .604 3
      1892 48.268 -1 1 0 0 2.763 2.274 7
      1896 47.76 1 0 0 0 -10.024 3.41 6
      1900 53.171 -1 1 0 0 -1.425 2.548 7
      1904 60.006 -1 0 1 0 -2.421 1.442 5
      1908 54.483 -1 0 1.25 0 -6.281 1.879 8
      1912 54.708 -1 1 1.5 0 4.164 2.172 8
      1916 51.682 1 1 0 0 2.229 4.252 3
      1920 36.119 1 0 1 1 -11.463 0 0
      1924 58.244 -1 1 0 0 -3.872 5.161 10
      1928 58.82 -1 0 1 0 4.623 .183 7
      1932 40.841 -1 1 1.25 0 -14.499 7.2 4
      1936 62.458 1 1 0 0 11.765 2.497 9
      1940 54.999 1 1 1 0 3.902 .081 8
      1944 53.774 1 1 1.25 1 4.279 0 0
      1948 52.37 1 1 1.5 1 3.579 0 0
      1952 44.595 1 0 1.75 0 .691 2.362 7
      1956 57.764 -1 1 0 0 -1.451 1.935 5
      1960 49.913 -1 0 1 0 .377 1.967 5
      1964 61.344 1 1 0 0 5.109 1.26 10
      1968 49.596 1 0 1 0 5.043 3.139 7
      1972 61.789 -1 1 0 0 5.914 4.815 4
      1976 48.948 -1 0 1 0 3.751 7.63 5
      1980 44.697 1 1 0 0 -3.597 7.831 5
      1984 59.17 -1 1 0 0 5.44 5.259 8
      1988 53.902 -1 0 1 0 2.178 2.906 4
      1992 46.545 -1 1 1.25 0 2.662 3.28 2
      1996 54.736 1 1 0 0 3.121 2.062 4
      2000 50.265 1 0 1 0 1.219 1.605 8
      2004 51.233 -1 1 0 0 2.69 2.325 1
      2008 46.6 -1 0 1 0 .22 2.88 3

      Thank you again

      Comment


      • #4
        Code:
        regress vote growth inflation
        lincom growth + 4*inflation - 50

        Comment


        • #5
          Is it not necessary to add the constant and multiply growth by 0? (lincom 52.15653 + 0*growth + inflation*4 -50)

          Comment


          • #6
            I don't understand what you say in #5. No, you don't have to multiply anything by zero: you just leave it out. In you said you wanted b1 + 4 b3 compared to 50. I assume that by b1 you meant growth and by b3 you meant inflation. That's what motivated my response in #4. If b1 and b3 stand for different things, then replace my growth and inflation by what b1 and b3 stand for. As for 52.15653, I have no clue where that might come from, but I can't see how it would be relevant to responding to #1.

            Comment


            • #7
              I did'nt mean that. What I say is that I have this regression: b1 + b2*X2 + b3*X3
              Where
              b1 = contant = 52.15653
              b2 and b3 are coefficients
              X2 = growth = 0
              X3 = inflation = 4

              Comment


              • #8
                Oh, I see.

                So then you want
                Code:
                lincom _cons + 4*inflation - 50

                Comment


                • #9
                  Thank you Clyde!

                  Comment

                  Working...
                  X