Hi Forum,
I have tried this loop (see below) ten thousand times and something really strange happens. The loop is bigger than shown, but I think it is sufficient to formulate my question.
After the number 2., I have a esttab where I can see my regression results where the two scalars marked in bold are shown. However, my problem is that only one scalar appears in my excel sheet, and the other in blank, and it is always the first one in order. So, when I change the order of the two scalars (e.g. I put number 2. first and then 1.), I get the first scalar result on my regression sheet and the other in blank. I have no idea why this happens, but it would be great if someone has any suggestions for this problem.
local i = 0
forval i = 1/${_`sgm'_ct}{
forval j = 1/$controls_ct {
forval t = 1/$r {
*1. Compute lower bound
cap gen x_`i'_`j'_`t' = (((invttail(e(df_r),0.05)* _se[flag] * flag)*NumberOfProducts_`i'_`j'_`t')/TotalSales_`i'_`j'_`t')*100
su x_`i'_`j'_`t' if e(sample) & flag_ == 1
estadd scalar x = r(mean)
*2. Compute and test
cap gen y_`i'_`j'_`t' = (((flag_ * _b[flag])*NumberOfProducts_`i'_`j'_`t')/TotalSales_`i'_`j'_`t')*100
su y_`i'_`j'_`t' if e(sample) & flag_== 1
estadd scalar y = r(mean)
}
}
}
Many thanks in advance!
Best regards,
Lena
Related Posts with Loop - Forvalues - works in different order
hausman test after heckmandear all I hope to use hausman test after heckman is there any way to test hausman after heckman? …
Moderators in DID regressionHello everyone. I am writing my thesis and I am not sure if what I am doing with DID on Stata is cor…
Transforming Ordinal Variable to Continuous VariableI have an ordinal variable having the categories 0, 1, 2, 3, 4. The categories are based on an unkno…
Compute sample analog of law of total variance [ V(Y) = E(V(Y|X)) + V(E(Y|X)]I am trying to see how much of the variance of a variable Y occurs between groups of a categorical v…
hausman test interpretationdear statalists, I got hausman test result ---- Coefficients ---- | (b) (B) (b-B) sqrt(diag(V_b-…
Subscribe to:
Post Comments (Atom)
0 Response to Loop - Forvalues - works in different order
Post a Comment