Announcement

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

  • Regressor not found in a loop with existing variable.

    Hello, I am trying to run this loop to generate F* variables. When I run the loop it stops because it says regressor lt3m_qe not found. However, lt3m_qe exist and it is not full of missing values.

    Here is the code:

    Code:
    foreach s in qe nqe {
    foreach pi in t3m t6m t1y t2y t3y t5y t7y t10y { 
    foreach iv of varlist  mp1  mp2 mp3 mp4 ff1 ff2 ff3 ff4 ed1 ed2 ed3 ed4 { 
    forval h  = 0(1)7{
    set level 90 
    *reghdfe f`h'r_p_asset  l(1/4).lr_p_asset_`s' l(1/4).`pi'_e_`s'  l(0/4).p_grgdp_`s' l(0/4).p_policyrate_`s' crisis (`pi'_e_`s'  = `iv'_`s')  if clean_f`h'r_p_asset==0 & date>tq(1991q4) & p_policyrate<1000  & eme==0 & r_p_asset>0.005, absorb(pifscode) cluster(date)
    qui: xtivreg2 lr_p_asset (`pi'_e=`iv') l(1/3).lr_p_asset_`s' l(0/3).p_grgdp_`s' l(1/3).l`pi'_`s' l(0/3).qe  , fe cluster(pairid)
    *xtivreg2 lr_p_asset (`pi'_e=`iv') l(1/3).lr_p_asset_nqe l(0/3).p_grgdp_nqe l(1/3).`pi'_nqe l(0/3).qe  , fe cluster(paired) 
    replace F10_`pi'_`iv'_`s'_90= e(widstat)-16.38 if _n == `h'+1 /* Diff with Kleibergen-Paap rk Wald F statistic*/
    replace F15_`pi'_`iv'_`s'_90= e(widstat)-8.96 if _n == `h'+1 /* Diff with Kleibergen-Paap rk Wald F statistic*/
    qui: lincomest l`pi'_`s'
    tab date if e(sample)==1
    parmest,label saving(`"asset_`pi'_`iv'_`h'_90_`s'"', replace)
    set level 68
    qui: xtivreg2 lr_p_asset (`pi'_e=`iv') l(1/3).lr_p_asset_`s' l(0/3).p_grgdp_`s' l(1/3).l`pi'_`s' l(0/3).qe  , fe cluster(pairid)
    *reghdfe f`h'r_p_asset  l(1/4).lr_p_asset_`s' l(1/4).`pi'_e_`s'  l(0/4).p_grgdp_`s' l(0/4).p_policyrate_`s' crisis (`pi'_e_`s'  = `iv'_`s') if clean_f`h'r_p_asset==0 & date>tq(1991q4) & p_policyrate<1000  & eme==0 & r_p_asset>0.005, absorb(pifscode) cluster(date) 
    replace F10_`pi'_`iv'_`s'_68= e(widstat)-16.38 if _n == `h'+1 /* Diff with Kleibergen-Paap rk Wald F statistic*/
    replace F15_`pi'_`iv'_`s'_68= e(widstat)-8.96 if _n == `h'+1 /* Diff with Kleibergen-Paap rk Wald F statistic*/
    qui: lincomest l`pi'_`s'
    parmest,label saving(`"asset_`pi'_`iv'_`h'_68_`s'"', replace)
    }
    }
    }
    }


    Thank you for your help!!

  • #2
    You didn't get a quick answer. You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters (which you do), readable Stata output, and sample data using dataex. Being able to replicate your problem would help us diagnose it. Also, simplify your code as much as possible so we can see the issues quickly. Don't post code with lines commented out etc. If the problem is in a regression, then don't include all the replacement statements after the regressions (assuming you still get the same error without the replacement statements). You have two xtivreg2 commands, and you don't even tell us which one creates the problem. You're asking us to help you out of the goodness of our hearts - the least you can do is take the time to make it easy as possible for us to help you.

    Do you really have lt3m_qe or do you have t3m_qe and want to lag it (L.t3m_qe)? After clearing out all the clutter, you should add to the loop before the xtivreg2 statements (i) a display statement with precisely the macro combinations that you use in the xtregs and (ii) su lt3m_qe l`pi'_`s' to see if the variables are there. If these don't identify a problem, then, run it with set trace on. This will tell you how xtivreg2 is interpreting the xtivreg2 statement.






    Comment

    Working...
    X