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

  • Converting factor notation into dummies.

    Dear All,

    I want to conduct a two-stage least squares regression using the ivreg2 command. I have quarterly data (26 quarters ) at the US state level (50 states). I want to include in my regression state specific quadratic time trends. So ideally I want to run:

    ivreg y x1 x2 x3 i.qtr i.state i.state#(c.qtr c.qtrsq) (x4= z), first robust

    However, I get an error:
    factor variables not allowed

    What is the easiest way to convert the
    i.state#(c.qtr c.qtrsq) into dummies that I can include? Sorry if this is a very basic question...but I couldn't find an answer on the list and can't think of a clean solution...

    Will greatly appreciate any help.

  • #2
    Let me first point out that if qtrsq is the square of qtr you weren't using the full potential of factor variable notation, which would have used i.state##c.qtr##c.qtr instead of i.state qtr i.state#(c.qtr c.qtrsq). Be that as it may, you can't use factor variable notation here.

    Before there was factor variable notation, there was -xi-. And it's still around, for precisely these situations where you need to use a command that doesn't support factor variable notation. -help xi- will explain the details.