Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Alex Olssen <alex.olssen@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | st: Can -bootstrap- handle vectors |
Date | Sat, 13 Aug 2011 20:40:20 +1200 |
Hi Statalisters, It seems to me that -bootstrap- cannot handle vectors? Is this correct? If so, does anyone know if there is a way to use a loop to send each element of a Mata vector to a separate Stata local so I can bootstrap the vector element by element? Sample code is below. All help greatly appreciated! ************************************************************ capture program drop my_vector program define my_vector, rclass syntax varlist mata: m_my_vector("`varlist'") return list return add end capture mata mata drop m_my_vector() mata: void m_my_vector(string scalar varlist) { real matrix data, data_cov st_view(data, ., varlist) data_cov = variance(data) st_matrix("r(v1)", data_cov[., 1]) st_numscalar("r(v11)", data_cov[1, 1]) } end sysuse auto, clear my_vector price length weight di r(v11) matrix list r(v1) bootstrap r(v11), reps(200) seed(13082011): my_vector price length weight bootstrap r(v1), reps(200) seed(13082011): my_vector price length weight ************************************************************ Cheers, Alex Olssen * * 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/