[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Predicted probabilities in graph

From   Steven Samuels <>
Subject   Re: st: Predicted probabilities in graph
Date   Wed, 3 Sep 2008 23:26:36 -0400


Try this.


sysuse auto,clear
svyset _n
tab foreign

local rhvar "mpg weight"

svy: logit foreign `rhvar'
predict phat

adjust `rhvar', gen(xb se) se

/*Compare Prediction at Mean to Actual Proportion */
gen p2=exp(xb)/(1+exp(xb))
sum phat p2

foreach v of varlist `rhvar' {
egen m`v' = mean(`v')
gen xb_`v' = xb + _b[`v']*(`v' - m`v')
gen pred_`v'=exp(xb_`v')/(1+exp(xb_`v'))
label var pred_`v' "Est Prob"

foreach v of varlist `rhvar' {
twoway scatter pred_`v' `v', title("Plot of Prediction against `v'" "Other Predictors at their Mean") saving(graph_v', replace)

On Aug 28, 2008, at 8:07 AM, Richard Ohrvall wrote:


I am trying to illustrate predicted probabilities for a successful
outcome in a logistic regression, e.g. when one independent variable
goes from min to max when all other variables are kept at their mean.

This can be done by using the user-written program -prgen- by J. Scott
Long and J. Freese and the way that they explain in their book
Regression Models for Categorical Depedent Variables Using Stata
(2006), Stata Press. However, according to the book, the program can
not be used when data comes from a complex sample, i.e.  when prefix
svy is used.

Since I mainly use survey data with complex sample design, this is a
problem for me if I want to present the confidence intervals in the
graph. Therefore, I wonder if there is some other program or some
other way to make predicted probabilities for such graphs when taking
the sampling design into account when estimating the confidence

Any help would be appreciated.

*   For searches and help try:
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index