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

From |
Steven Samuels <sjhsamuels@earthlink.net> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: standard error of prediction (with weights) |

Date |
Tue, 16 Sep 2008 10:12:18 -0400 |

On Sep 16, 2008, at 6:01 AM, Hans Olav Melberg wrote:When using the following:

logit c6 $x6 [pweight=w2all], or

mfx compute, at(gateway=0)

I get:

Marginal effects after logit

y = Pr(c6) (predict)

= .00067379

etc

How do I find standard error of the predicted value?

The predicted value (y = 0.00067) is calculated using weights as well

as at the mean of the variables, except for one variable which is 0.

I found some commands that might be useful, but they did not accept weights.

Hans, you need to use -adjust- for this purpose. However -adjust- will not hold variables at their weighted means. Here is code that creates the weighted means and then calls -adjust-. If it is badly mangled in transmission to the list, I will send you a copy privately.

-Steve

*****************Code begins *****************

/*

Program to created adjusted prediction and CI for weighted data, holding one variable at a specified value and the others at their weighted means

For the auto data, the command will be: svy: logit foreign rep78 mpg weight trunk

-adjust- will be called to predict the probability for rep78=3 and other predictors held at their means

*/

sysuse auto,clear

svyset _n [pweight=length]

local rhs mpg weight trunk // all variables to be held at their means ///

/* Create weighted means */

svy: mean `rhs'

foreach v of varlist `rhs' {

local m_`v' = _b[`v']

}

/* build up statement for -adjust- command */

local l_adj " "

foreach v of varlist `rhs' {

local lv "`v' = `m_`v'' "

local l_adj `l_adj' `lv'

}

di "`l_adj'"

/* Survey command itself */

svy: logit foreign rep78 `rhs'

adjust "`l_adj'" rep78=3, pr ci

**************Code Ends**********************

*

* For searches and help try:

* http://www.stata.com/help.cgi?search

* http://www.stata.com/support/statalist/faq

* http://www.ats.ucla.edu/stat/stata/

**References**:**st: standard error of prediction (with weights)***From:*"Hans Olav Melberg" <hans.melberg@gmail.com>

- Prev by Date:
**Re: st: Likelihood-ratio test for frontier models** - Next by Date:
**RE: st: bar colours in -graph hbar, over()-** - Previous by thread:
**Re: st: standard error of prediction (with weights)** - Next by thread:
**Re: st: standard error of prediction (with weights)** - Index(es):

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