Hello to all statalist users,
I'm doing a loop to get kdensity, but I have a problem. In the loop that I attached below, I do not run a line of code, which is very important and I do not know how to fix it.
Where it fails is in the following line of code: local h1 = (`h1 ') * (` scaledown')
The complete code is the following:
Error in:
Thank you very much for the suggestions.
Alexis Rodas
I'm doing a loop to get kdensity, but I have a problem. In the loop that I attached below, I do not run a line of code, which is very important and I do not know how to fix it.
Where it fails is in the following line of code: local h1 = (`h1 ') * (` scaledown')
The complete code is the following:
Code:
gen area2=zona_conasami2012=="Zona C" sum lrsalary global B=200 gen r0=(_n-1)/($B-1) replace r0=. if _n>$B *r0 should span [0,1] global a=4 global b=7 replace r0=$a+r0*($b-$a) *r0 should span [$a,$b] *IMPORTANT: bandwidth "scaledown" factor for density estimation local scaledown=2 forval yr=2012/2018 { sum lrsalary if area2==1 & year==`yr' [aw=weight_ta6], det di min(r(sd),((r(p75)-r(p25))/1.349))*(r(N)^(-1/5))*0.9 local h1=min(r(sd),((r(p75)-r(p25))/1.349))*(r(N)^(-1/5))*0.9 di `h1' local h1=(`h1')*(`scaledown') di `h1' kdensity lrsalary if area2==1 & year==`yr' [aw=weight_ta6], at(r0) gen(lrsalary_hat1_`yr') bwidth(`h1') nograph sum lrsalary if area2==0 & year==`yr' [aw=weight_ta6], det di min(r(sd),((r(p75)-r(p25))/1.349))*(r(N)^(-1/5))*0.9 local h0=min(r(sd),((r(p75)-r(p25))/1.349))*(r(N)^(-1/5))*0.9 di `h0' local h0=(`h0')*(`scaledown') di `h0' kdensity lrsalary if area2==0 & year==`yr' [aw=weight_ta6], at(r0) gen(lrsalary_hat0_`yr') bwidth(`h0') nograph } .
Code:
local h1=(`h1')*(`scaledown') invalid syntax r(198); t=0.00 19:01:05
Alexis Rodas
Comment