Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

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

From |
"Fleming, Fiona M" <f.fleming@imperial.ac.uk> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: Bootstrapping: Comparing the difference between means |

Date |
Wed, 3 Apr 2013 19:28:52 +0000 |

Nick, Many thanks for your quick and useful response, makes me wish I had sent out the request for advice sooner. I didn't mention starting with on-line help and manual entry but that is where I did start. I couldn't figure out, in the more simple manner that you have demonstrated, how to do the bootstrap for the difference in means, so went in search for a more complicated way.... Thanks again for the advice. Fiona -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: 03 April 2013 17:42 To: statalist@hsphsun2.harvard.edu Subject: Re: st: Bootstrapping: Comparing the difference between means I don't see that you need to write a program here. sysuse auto bootstrap (r(mu_1) - r(mu_2)), reps(10000) nowarn nodots : ttest mpg, by(foreign) What are you doing wrong? You don't mention starting with the on-line help and manual entry. The very first example shows that you can calculate the results of expressions containing different saved results on the fly with the -bootstrap- command. ... if (del==1) + (del==2) should give the right result, but it's better style to use logical operators. simulate diffa_1=r(mu_1) diffa_2 = (r(mu_2), reps(100) : the parentheses aren't balanced. Nick On 3 April 2013 17:22, Fleming, Fiona M <f.fleming@imperial.ac.uk> wrote: > I am hoping someone can help! I have been trying to work out, all day, how I can perform a bootstrap on the mean difference of two samples. I have scoured the Statalist, FAQ etc to get ideas and have recently been trying to replicate the programming and commands illustrated in Example 2 on http://statistics.ats.ucla.edu/stat/stata/faq/ownboot.htm with my own data set i.e.: > > // step 1 > ttest dcp if (del==1) + (del==2), by(del) return list matrix mu = > (r(mu_1), r(mu_2)) matrix list mu > > // step 2 > capture program drop mydiffa > program define mydiffa, rclass > preserve > bsample > ttest dcp if (del==1) + (del==2), by(del) estat mu return scalar > diffa_1 = r(mu_1) return scalar diffa_2 = r(mu_2) restore end > > // step 3 > simulate diffa_1=r(mu_1) diffa_2 = (r(mu_2), reps(100) seed(12345): > mydiffa bstat, stat (mu) n(200) estat bootstrap, all > > after running this 'simulate' I get the following error and cannot > proceed- '' found where ':' expected r(198); > > > Please could you offer any advice as to what I am doing wrong? > > In addition, what I have written above will only give me the bootstrap SE and CI for each of the means and not the difference of the means, if you have any further advice on how I might run that I would be extremely grateful. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Bootstrapping: Comparing the difference between means***From:*"Fleming, Fiona M" <f.fleming@imperial.ac.uk>

**Re: st: Bootstrapping: Comparing the difference between means***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**RE: st: playing a media sound (.wav) from Stata in Windows 7** - Next by Date:
**RE: st: Bootstrapping: Comparing the difference between means** - Previous by thread:
**Re: st: Bootstrapping: Comparing the difference between means** - Next by thread:
**Re: st: Bootstrapping: Comparing the difference between means** - Index(es):