Statalist


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

st: bootstrap error: insufficient observations ...


From   Guido Heineck <[email protected]>
To   [email protected]
Subject   st: bootstrap error: insufficient observations ...
Date   Sun, 30 Sep 2007 22:15:48 +0200

Dear all.

I run a multinomial logit model and want to examine differences in predicted probabilities for different hypothetical groups of my sample.
Using the auto-data, the following code shows what I do.

*------------ example -------------------------;
set more off

sysuse auto, clear

/* artificial y */
xtile lhs = price, nq(4)

/* additional covariate */
gen forXmpg = foreign * mpg

/* backup orig vars */
qui gen ofor=foreign
qui gen ompg=mpg
qui gen oformpg=forXmpg

/* prog. to get diffs in pred. probs */
program define bs_test
version 9.2

mlogit lhs foreign mpg forXmpg

/* 1. hypothetical group */
qui replace foreign=1
qui replace mpg=14
qui replace forXmpg=14

predict yfor11, outcome(1)
predict yfor13, outcome(3)

/* 2. hypothetical group */
qui replace foreign=0
qui replace forXmpg=0

predict ydom11, outcome(1)
predict ydom13, outcome(3)

/* 3. hypothetical group */
qui replace foreign=1
qui replace mpg=22
qui replace forXmpg=22

predict yfor21, outcome(1)
predict yfor23, outcome(3)

/* 4. hypothetical group */
qui replace foreign=0
qui replace forXmpg=0

predict ydom21, outcome(1)
predict ydom23, outcome(3)

/* calculate differences */
gen temp11 = yfor11 - ydom11
su temp11
gen diff11=_result(3)

gen temp13 = yfor13 - ydom13
su temp13
gen diff13=_result(3)

gen temp21 = yfor21 - ydom21
su temp21
gen diff21=_result(3)

gen temp23 = yfor23 - ydom23
su temp23
gen diff23=_result(3)

end

/* bootstrap std. err. of differences in pred. probs */
bootstrap diff11 diff13 diff21 diff23, noisily reps(100) saving("D:\bs_test", replace) seed(999): bs_test

/* restore orig vars */
replace foreign=ofor
replace forXmpg=oformpg
replace mpg=ompg

*------------ end example -------------------------;

Now, using the noisily-option, Stata returns
"yfor11 already defined
an error occurred when bootstrap executed bs_test, posting missing values"
after the mlogit-estimations and - consequently -
"insufficient observations to compute bootstrap standard errors".
after all replications.

I tried several things, but so far I was not successful. I would thus appreciate any helpful hint.

Guido

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




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