Hello everyone!
I'd like to save two scalars generated in a loop to a variable. My current code reads as follows:
-------------------------
forvalues i = 1(1)158 {
gen z = _b[_cons] + _b[republican]*republican + _b[ideology]*ideology + _b[vulnerability]*vulnerability + _b[seniority]*seniority if vote_id == 'i'
gen Phi_z = normal(z)
gen newvote = 1 if vote_id == 'i'
replace newvote = 0 if Phi_z < .5 if vote_id == 'i'
sum vote_behavior if vote_id == 'i'
scalar vote_old = r(mean)
sum newvote
scalar vote_new = r(mean)
}
-------------------------
I'd like to save the scalars vote_old and vote_new to new variables. I'd appreciate any suggestions on how to do that.
G.
Related Posts with How do I save scalars in a loop to a variable?
sensitivity analysis for robustness of results over the study periodGreetings, I am conducting a case-control study to assess the effect of ethnicity (six main ethnic g…
Daily Stock returnsDear all, I am entirely new to stata, so in case I am leaving out any information that might be req…
panel data: exploring factors affecting incidence/persistence/remission of a condition over timeDear statalisters, I have some panel data that include four binary clinical outcomes (0=absent, 1=p…
Problem with interaction terms in logit modelHi everyone, I am working on a logistic regression model with five independent, continuous key varia…
Panel data estimation with differenced variablesHello Everyone, So after testing my var. with xtcips, several of my variables are not stationary at …
Subscribe to:
Post Comments (Atom)
0 Response to How do I save scalars in a loop to a variable?
Post a Comment