Hello everyone,
After struggling over this problem for a bit I've decided to break and ask for help. I can't for the life of me see where the problem is so I'm hoping someone else can put me out of my misery.
In brief, I'm running a series of regressions in a loop and I want to use collect to put them into a succinct table. As you will see in the code, there are a variety of outcomes with the same independent variable in each of the regressions.
I keep getting the error message
I have done this before with success but I am stymied as to why it is not working now. Admittedly I use -collect- infrequently so I am hoping someone with more familiarity will help me out. The reason for the complexity is that I want the table arranged horizontally with each model on a separate row (omitting the constant) and the columns being the beta-coefficient, confidence intervals and p-values as columns.
Thank you to whoever can point what is probably a simple omission on my part.
Chris
After struggling over this problem for a bit I've decided to break and ask for help. I can't for the life of me see where the problem is so I'm hoping someone else can put me out of my misery.
In brief, I'm running a series of regressions in a loop and I want to use collect to put them into a succinct table. As you will see in the code, there are a variety of outcomes with the same independent variable in each of the regressions.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(frozen round n_oocytes d3embryos d5embryos embryotransfer dayofET hcg pregnancy miscarriage livebirth) 1 0 4 2 2 0 5 0 0 0 0 0 0 0 0 0 . . . . . . 0 0 0 0 0 . . . . . . 0 0 7 6 6 0 5 1 1 0 1 1 0 2 0 0 . . . . . . 0 0 1 0 0 . . . . . . 1 0 1 1 0 0 3 1 0 0 0 1 0 5 1 0 . . . . . . 1 0 3 3 0 . . . . . . 1 0 0 0 0 . . . . . . 1 0 0 0 0 . . . . . . 1 0 1 1 0 0 3 0 0 0 0 0 0 1 0 0 . . . . . . 1 0 8 2 1 0 5 1 1 1 0 1 0 0 0 0 . . . . . . 1 0 2 1 1 0 3 0 0 0 0 0 0 9 5 3 . . . . . . 1 0 2 0 0 . . . . . . 1 0 2 1 1 0 5 0 0 0 0 1 0 5 3 3 0 5 0 0 0 0 1 0 2 1 1 0 5 0 0 0 0 1 0 2 0 0 . . . . . . 1 0 5 2 2 0 5 1 0 0 0 1 0 8 2 3 0 5 0 0 0 0 1 0 8 2 3 1 5 0 0 0 0 0 0 13 7 2 0 5 0 0 0 0 1 0 6 3 0 0 3 0 0 0 0 1 0 0 0 0 . . . . . . 1 0 2 1 0 0 3 0 0 0 0 1 0 2 1 0 . . . . . . 1 0 2 1 0 . . . . . . 0 0 0 0 0 . . . . . . 1 0 1 1 0 0 3 0 0 0 0 1 0 7 2 0 0 3 0 0 0 0 1 0 1 0 0 . . . . . . 0 0 0 0 0 . . . . . . 1 0 0 0 0 . . . . . . 0 0 4 1 0 . . . . . . 1 0 1 0 0 . . . . . . 1 0 2 1 0 . . . . . . 1 0 5 3 3 0 5 0 0 0 0 0 0 4 2 0 0 3 0 0 0 0 1 0 0 0 0 . . . . . . 1 0 5 4 2 0 5 0 0 0 0 1 0 1 1 0 . . . . . . 1 0 5 3 0 . . . . . . 1 0 7 2 0 0 3 0 0 0 0 1 0 10 2 1 0 5 0 0 0 0 1 0 2 2 1 0 5 0 0 0 0 1 0 3 1 0 . . . . . . 1 0 0 0 0 . . . . . . 0 0 3 2 2 0 5 0 0 0 0 1 0 4 2 0 . . . . . . 1 0 1 0 0 . . . . . . 0 0 0 0 0 . . . . . . 0 0 2 1 1 0 5 0 0 0 0 1 0 3 1 0 . . . . . . 1 0 2 1 0 . . . . . . 1 0 2 2 0 0 3 0 0 0 0 0 0 5 2 0 . . . . . . 0 0 2 0 0 . . . . . . 1 0 4 2 1 0 5 0 0 0 0 1 0 7 0 0 . . . . . . 1 0 5 3 1 0 5 0 0 0 0 1 0 3 1 1 1 5 0 0 0 0 0 0 1 1 0 . . . . . . 1 0 6 6 2 0 5 0 0 0 0 1 0 4 3 2 1 5 0 0 0 0 1 0 4 3 2 1 5 0 0 0 0 1 0 1 0 0 . . . . . . 1 0 0 0 0 . . . . . . 0 0 2 0 0 . . . . . . 1 0 2 1 1 0 5 0 0 0 0 1 0 1 0 0 . . . . . . 1 0 2 2 0 0 3 0 0 0 0 1 0 5 5 0 0 3 0 0 0 0 1 0 4 1 0 0 3 0 0 0 0 0 0 4 0 0 . . . . . . 1 0 1 1 0 0 3 0 0 0 0 1 0 2 0 0 . . . . . . 1 0 0 . . . . . . . . 1 0 2 2 0 . . . . . . 0 0 3 0 0 . . . . . . 1 0 1 0 0 . . . . . . 0 0 1 1 1 0 5 0 0 0 0 1 0 2 0 0 . . . . . . 1 0 9 6 2 0 5 0 0 0 0 1 0 9 6 2 1 5 0 0 0 0 1 0 3 3 1 0 5 0 0 0 0 1 0 4 0 0 . . . . . . 1 0 0 0 0 . . . . . . 1 0 0 0 0 . . . . . . 1 0 0 0 0 . . . . . . 0 0 2 1 0 . . . . . . 1 0 3 3 0 1 5 1 1 0 1 1 0 1 0 0 . . . . . . 1 0 1 0 0 . . . . . . 1 0 0 0 0 . . . . . . 1 0 0 0 0 . . . . . . 1 0 0 0 0 . . . . . . end label values frozen frozen label values embryotransfer frozen label def frozen 0 "fresh", modify label def frozen 1 "frozen", modify label values round round label def round 0 "elongated", modify label var frozen "fresh vs. frozen spermatids" label var round "elongated vs. round spermatids" label var n_oocytes "number of oocytes fertilized" label var d3embryos "number of d3 embryos" label var d5embryos "number of d5 embryos" label var embryotransfer "fresh vs. frozen embryo transfer" label var dayofET "Day of embryo transfer" label var hcg "Positive hCG" label var pregnancy "Clinical Pregnancy" label var miscarriage "Miscarriage" label var livebirth "Live Birth"
Code:
collect clear foreach var of varlist n_oocytes d3embryos d5embryos embryotransfer dayofET hcg pregnancy miscarriage livebirth { qui collect _r_b _r_ci _r_p, tag(model[`var']): regress `var' frozen } collect style cell, nformat(%5.2f) collect style cell result[_r_ci], sformat("(%s)") collect style cell result[_r_ci], cidelimiter(-) collect style cell result, halign(center) collect title "Fresh vs. Frozen spermatids" collect layout (colname) (result[_r_b _r_ci _r_p])
Your layout specification does not uniquely match any items. One or more of the following
dimensions might help uniquely match items: cmdset, coleq, model.
dimensions might help uniquely match items: cmdset, coleq, model.
Thank you to whoever can point what is probably a simple omission on my part.
Chris
Comment