Announcement

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

  • -if- regression

    Dear Statalists,

    I need to run a regression for specific range of year (94-96). Can I use -if-?
    Already generated dummy variable: post93=(year>1993).

    For example:

    Regress var1 var2, if(post93==1)

    Regards.

  • #2
    You don't need to create a new variable. Use instead if inrange(year,94,96).
    For example:
    regress var1 var2 if inrange(year,94,96)

    Comment


    • #3
      Thank you for your reply.

      I created the new variable because the question asked me to.

      Cheers,
      Was really helpful.

      Comment


      • #4
        Note further that if your selected data are for 1994-1996 then any indicator for 1994 or more is identically 1 and so useless for regression.

        Comment


        • #5
          Is there a way that the output for all different ranges will be in 1 table? I need to do the same for 25 ranges of data but Stata will give me 25 output tables.

          Click image for larger version

Name:	Untitled.png
Views:	1
Size:	2.2 KB
ID:	1394552

          With the dots in the center being the coefficients.

          Comment


          • #6
            For example:
            Regress var1 var2, if(post93==1)
            There are several issues on the command showed in #1.

            First, it is - regress -, not Regress.

            Second, you are supposed to use the -if- clause before the comma, not afterwards.

            Third, there is not need to use the parenthesis.

            These reasons being remarked, such a command is not bound to work properly.
            Best regards,

            Marcos

            Comment


            • #7
              Dear Marcos,

              Thank you for your answer. Do you also have an answer for the question in #5? When using inrange (yr, 1980, 1983) the output will of course be in one table. However, my goal is to have a table with the coefficients for multiple ranges as shown in #5 without having to copy the content in a new table.

              Kind regards,

              Martin Euwe

              Comment


              • #8
                You may wish to create a 'range variable', then - regress - under -bysort- , use estimates store, then type -estimates table - command.
                Best regards,

                Marcos

                Comment

                Working...
                X