Website Worth

Total Pageviews

Thursday

How to run a logistic regression in STATA?

When: outcome follows binomial distribution (two values, 0 and 1)
The nature: Outcome values are converted to logits – the distribution is approximately Gaussian (normal)
Assumptions: Linearity between converted outcome values and independent variables, no outliers that may distort estimates, goodness of fit (p is larger than 0.05, basically means the set of predictors can predict well the outcome, or not (p is smaller than 0..05))
IN STATA:
1. Key command:
logit DEPVAR INDVARLIST, or
2. Check for linearity:
boxit: logit
If the results indicate that a predictor is nonlinearly associated with the outcome (p<.05), transform it, or recode it.
3. Check for outliers:
predict res, dx
tw (scatter res DEPVAR)
Outliers are values far away from the main ‘cloud’ of others. Remove them.
4. Check for goodness of fit: do this when two others have been done
estat gof, group(10)
5. Re-run the final model to get estimates.
Report Odd ratios: Understand the meaning of Odds and Odds ratios
For example if you have a predictor sex (male=1, female=0), and an outcome cancer, an estimate for sex =1.2, what does it mean?
It means: the probability of getting cancer among sampled men / probability of getting cancer among sampled women=1.2, or
The probability of getting cancer among sampled men is 1.2 times the probability of getting cancer among sampled women, when all other factors (education, occupation, etc.) are equal.
6. (This is not required but if you like): Take the 'margin' probability: If you want to know what the probability that being a man, 40 years old, manual labourer has done xyz in the last week, when all other factors are the same, then you should you margins function in Stata.
margins, at(female=0 age=40 jobtype=1) atmeans
marginsplot, noci