Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Bootstrap error: insufficient observations


From   "Garth Rauscher" <[email protected]>
To   <[email protected]>
Subject   st: Bootstrap error: insufficient observations
Date   Fri, 23 Apr 2010 13:23:59 -0500

Dear List,

I am writing a program to perform model-based standardization (predictive
margins) from logistic regression for models that include a single product
term between the exposure and another covariate. I am able to run the
program and view the scalars that have been calculated, but when I attempt
to obtain bootstrapped confidence intervals I get the following error
message: "xxxxxxxxxx insufficient observations to compute bootstrap standard
errors no results will be saved." Acccording to the details of the error
message, apparently I am attempting to perform a calculation when there are
no data. 

The problem arose when I added to the program the possibility of an
interaction term between the main exposure and another covariate (macro
variable `4'). When I set the main exposure to a specific value I have to
recalculate the value of the interaction variable to reflect the change in
the main exposure, and this appears to be where the probelm arises. However,
I cannot figure out how to tweak the program to get the bootstrapping to
work. 

The program is below. If anyone out there happens to see the problem I'd
appreciate hearing from you. Thanks, Garth


***********************************************************************
*  Program to calculate predictive margins 
*  `1'=Dependent Variable
*  `2'=Main exposure variable
*  `3'=Main Covariate
*  `4'=exposure times covariate product term
*  `5'=all other covariates in the model
***********************************************************************

*---------------------------- start program ---------------------------
program drop margins
program margins, rclass
capture drop meanp meanp0 meanp1  

*** Temporary variables for predicted probabilities under 3 data scenarios 
tempname p p0 p1

	logit `1' `2' `3' `4' `5',  or 
	predict `p'

	rename  `2' was`2'      //preserve original values of exposure
	rename  `4' was`4' 	//preserve original values of interaction
var

	gen `2' =0    		//set exposure=0
	gen `4' =`2'*`3'		//recalculate values of interaction
var

	predict `p0'

	replace  `2'=1		//set exposure=1
	replace  `4' =`2'*`3'	//recalculate values of interaction var

	predict `p1'

	drop  `2'
	rename was`2'  `2'	//return original values to exposure
	drop  `4'
	rename was`4'  `4'	//return original values to interaction var
	
	
	su `p',meanonly
	return scalar meanp=r(mean) 	

	su `p0', meanonly
	return scalar meanp0=r(mean) 

	su `p1', meanonly
	return scalar meanp1=r(mean) 
end
*---------------------------- end program ---------------------------
 
use predmarg, clear
bootstrap  meanp=r(meanp) meanp1=r(meanp1) meanp0=r(meanp0), /// 
reps(10): margins binarystage path2 doublenegative doublepath "education
income r1 r3"	
 


Garth Rauscher
Associate Professor of Epidemiology
Division of Epid/Bios (M/C 923)
UIC School of Public Health
1603 West Taylor Street
Chicago, IL 60612
ph: (312)413-4317
fx:  (312)996-0064
em: [email protected]
 


*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index