Tuesday, October 25, 2011

Can 'margins' be used after 'mi estimate'?

Can 'margins' be used after 'mi estimate'?

The -margins- command may not be used in the usual way after -mi estimate-. You'll need to write a short "wrapper command" that can be run with the -mi estimate- prefix. My colleagues outlined the method on Statalist: Average marginal effects for a multiply imputed complex survey. You'll want to change the 11 in the -version 11- statement to 12. One of our FAQs will also be helpful: How can I combine results other than coefficients in e(b) with multiply imputed data? - by A Statistician, Stata


Here is my modified program based on codes of UCLA Stata Portal

use http://www.ats.ucla.edu/stat/data/hsbmar, clear
/* set MI dataset */
mi set mlong
mi register imputed female math read science socst
mi svyset [pw=write], strata(ses)
mi impute chain (logit) female (regress) math read science socst ///
       =ses write awards, add(10) rseed(123456)
/* program */
capture program drop mimargins
program mimargins, eclass properties(mi)
  version 12
  svy: logit honors i.female##i.prog read math science socst
  margins female#prog, post
end
/* run the program */ 
mi estimate, cmdok: mimargins 1
matlist r(table)'*100, tw(20) format(%8.2f)
mi estimate (_b[1.female#2.prog]/_b[1.female#1bn.prog]): mimargins 1

Notes: The 'cmdok' option forces 'mi estimate' to estimate the current Stata unsupported model. The 'cmdok' is not necessary because of already including the 'properties(mi)' in the program.

mi estimate: svy: logit honors i.female##i.prog read math science socst
mi test 1.female#2.prog 1.female#3.prog

mi estimate (diff:1.female#2.prog-1.female#3.prog), saving(miest, replace): svy: logit honors i.female##i.prog read math science socst
mi testtransform diff

mi estimate (rdiff:1.female#2.prog/1.female#3.prog - 1) using miest
mi testtr rdiff


Useful Resources:


Monday, October 24, 2011

Abramowitz and Stegun: Handbook of Mathematical Functions



“The present volume is an outgrowth of a Conference on Mathematical Tables held at Cambridge, Mass., on September 15-16, 1954, under the auspices of the National Science Foundation and the Massachusetts Institute of Technology. The purpose of the meeting was to evaluate the need for mathematical tables in the light of the availability of large scale computing machines. It was the consensus of opinion that in spite of the increasing use of the new machines the basic need for tables would continue to exist.


Numerical tables of mathematical functions are in continual demand by scientists and engineers. A greater variety of functions and higher accuracy of tabulation are now required as a result of scientific advances and, especially, of the increasing use of automatic computers. In the latter connection, the tables serve mainly for preliminary surveys of problems before programming for machine operation. For those without easy access to machines, such tables are, of course, indispensable...”


You can view or download the tenth printing of this famous reference here: http://people.math.sfu.ca/~cbm/aands/

Wednesday, October 19, 2011

How to Estimate Percentiles and Confidence Intervals

How to Estimate Percentiles and Confidence Intervals
By CDC

Including percentiles whose estimate falls on a value that is repeated multiple times in the dataset
A common practice to calculate confidence intervals from survey data is to use large-sample normal approximations. Ninety-five percent confidence intervals on point estimates of percentiles are often computed by adding and subtracting from the point estimate a quantity equal to twice its standard error. This normal approximation method may not be adequate, however, when estimating the proportion of subjects above or below a selected value, especially when the proportion is near 0.0 or 1.0 or when the effective sample size is small. In addition, confidence intervals on proportions deviating from 0.5 are not theoretically expected to be symmetric around the point estimate. Further, adding and subtracting a multiple of the standard error to an estimate near 0.0 or 1.0 can lead to impossible confidence limits (i.e., proportion estimates below 0.0 or above 1.0). The approach used for the Report data tables (and for previous Reports) produces asymmetric confidence intervals consistent with skewed (nonnormal) biologic data distributions. ...

You can read the whole article here: http://www.cdc.gov/exposurereport/data_tables/appendix_a.html

Monday, October 17, 2011

Recipes and Meal Planning from the American Diabetes Association

Recipes and Meal Planning from the American Diabetes Association

If you are looking for healthy recipes to lose weight, prevent, or manager diabetes, you may like the MyFoodAdvisor – Recipes for healthy Living from the American Diabetes Association. You must register to access these recipes, which I don’t like the way of access, but it’s FREE.

Wednesday, October 12, 2011

Top 50 Statistics Blogs of 2011

The Best Colleges has published a long list of statistic related blogs. Wish they could have reduced the number to 10.

Monday, October 03, 2011


Tips: SAS code matched to Stata code and others
Usually, I think that SAS is an analog to a product of Microsoft, Stata is an analog to a product of Apple, and R is an analog to a product of Google. I have used the SAS for many years, but have been attracted by Stata for some new features. I am always trying to find the same handy data management features using Stata, and notice there are a few websites providing these equivalents.

Resources for Disability Research
                                            - these materials highly recommended by my colleague J.C., an expert in this disability area.