Announcement

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

  • Regression Loop String Variables

    Dear all,

    I have a very detailed but important problem/question: My goal is to run 69 regression in a panel setting for each cross-section individually with some of the same independent being the same and some differ. What I want to set up is, that depending on the id I want to choose a local / string that indicates which variables to choose for the respective cross-section. The variables to choose are being defined by the maximum of product (either 1 2 or 3), which I calculate as a product.

    Here is my approach:

    local xy1 "d(x1)"
    local xy2 "d(x1) d(x2)"
    local xy3 "d(x1) d(x2) d(x3)"

    forval i = 1/69 {
    summarize product if id == `i'
    scalar d`i' = (r(max))
    }

    forval i = 1/69 {
    ivreg2 l.ln_ind_rel d.ind_av_i l.adv `xy`d`i''' (d.adv = d.advprod2 d.advprod3 d.advprod4 l.advprod2 l.advprod3 l.advprod4 `xy`d`i''' ) if id ==`i'
    }

    Stats does not recognize my XY identifier though... Can anyone help me with this??

    Thank you so much.

    MAx

  • #2
    Dear Max: welcome to the Forum. You've posted a question about Stata; this subforum is reserved for Mata issues. Please re-post to the General subforum.

    Comment

    Working...
    X