Friday, September 16, 2011

why I get error message, when using 'margins' for complex sampling data

Tips - Stata: why I get error message, when using 'margins' for complex sampling data

When I use 'margins' for complex sampling data, after a logistic regression:
  . svy, subpop(if suball==1): logit arthritis i.diabetes c.age i.sex i.bmi4grp
  . margins diabetes, vce(unconditional) post

I've got an error message sometime:
  "missing predicted values encountered within the estimation sample r(322)"


The answer is to include 'subpop' in the 'margins' command:
  .margins diabetes, subpop(if suball==1) vce(unconditional) post

3 comments:

Anonymous said...

Thanks! This is very helpful!

Anonymous said...

Thanks for the comment. Very helpful and worked!!

Anonymous said...

What if you do not want the marginal effects for the subpop, but for the whole sample?