node10.htm
来自「matlab bootstrap程序设计方法」· HTM 代码 · 共 413 行
HTM
413 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><!--Converted with LaTeX2HTML 2002-2 (1.70)original version by: Nikos Drakos, CBLU, University of Leeds* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan* with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others --><HTML><HEAD><TITLE>The bootstrap: Some Examples</TITLE><META NAME="description" CONTENT="The bootstrap: Some Examples"><META NAME="keywords" CONTENT="web1"><META NAME="resource-type" CONTENT="document"><META NAME="distribution" CONTENT="global"><META NAME="Generator" CONTENT="LaTeX2HTML v2002-2"><META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"><LINK REL="STYLESHEET" HREF="web1.css"><LINK REL="next" HREF="node11.html"><LINK REL="previous" HREF="node9.html"><LINK REL="up" HREF="node6.html"><LINK REL="next" HREF="node11.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html286" HREF="node11.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/home/depot/swtree/depot/latex2html-2002-2/latex2html-2002-2/icons/next.png"></A> <A NAME="tex2html284" HREF="node6.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/home/depot/swtree/depot/latex2html-2002-2/latex2html-2002-2/icons/up.png"></A> <A NAME="tex2html278" HREF="node9.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/home/depot/swtree/depot/latex2html-2002-2/latex2html-2002-2/icons/prev.png"></A> <BR><B> Next:</B> <A NAME="tex2html287" HREF="node11.html">Some notation</A><B> Up:</B> <A NAME="tex2html285" HREF="node6.html">Lectures</A><B> Previous:</B> <A NAME="tex2html279" HREF="node9.html">The questions addressed</A><BR><BR><!--End of Navigation Panel--><!--Table of Child-Links--><A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A><UL><LI><A NAME="tex2html288" HREF="node10.html#SECTION00241000000000000000">A binomial example</A><UL><LI><A NAME="tex2html289" HREF="node10.html#SECTION00241100000000000000">Computing the bootstrap distribution for one sample</A><LI><A NAME="tex2html290" HREF="node10.html#SECTION00241200000000000000">Comparing to a hypothetical parameter</A><LI><A NAME="tex2html291" HREF="node10.html#SECTION00241300000000000000">Computing the bootstrap distribution for two samples</A><LI><A NAME="tex2html292" HREF="node10.html#SECTION00241400000000000000">Without the computer</A></UL><BR><LI><A NAME="tex2html293" HREF="node10.html#SECTION00242000000000000000">First plug-in encounter</A></UL><!--End of Table of Child-Links--><HR><H1><A NAME="SECTION00240000000000000000">The bootstrap: Some Examples</A></H1><BODY bgcolor="#FFFFFF"><P><H2><A NAME="SECTION00241000000000000000">A binomial example</A></H2>Suppose we don't know any probability or statistics,and we are told that <IMG SRC="Aspirin.jpg",width=100><TABLE CELLPADDING=3><TR><TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT">Heart attacks</TD><TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT">Subjects</TD></TR><TR><TD ALIGN="LEFT">Aspirin</TD><TD ALIGN="LEFT">104</TD><TD ALIGN="LEFT">10933</TD><TD ALIGN="LEFT">11037</TD></TR><TR><TD ALIGN="LEFT">Placebo</TD><TD ALIGN="LEFT">189</TD><TD ALIGN="LEFT">10845</TD><TD ALIGN="LEFT">11034</TD></TR></TABLE><BR>The question : Is the true ratio <IMG WIDTH="14" HEIGHT="17" ALIGN="BOTTOM" BORDER="0" SRC="img10.png" ALT="$\theta$">of heart attack rates,the parameter of interest, smaller than 1?<P>Or is the difference between rates in bothpopulations strictly different from zero?<P>We could run a simulation experiment to find out.<P><PRE>>> [zeros(1,10) ones(1,2)]ans = 0 0 0 0 0 0 0 0 0 0 1 1>> [zeros(1,10) ones(1,2)]'ans = 0 0 0 0 0 0 0 0 0 0 1 1>> [zeros(1,10) ; ones(1,2)]??? All rows in the bracketed expression must have the same number of columns.>> sample1=[zeros(1,109) ones(1,1)]';>> sample2=[zeros(1,108) ones(1,2)]';>> orig=sample1>>[n,p]=size(orig)n = 110p = 1>> thetab=zeros(1,1000);</PRE><P><FONT SIZE="+1">File bsample.m:<BR></FONT><PRE>function out=bsample(orig)%Function to create one resample from%the original sample orig, where%orig is the original data, and is a %matrix with nrow observations and ncol variables [n,p]=size(orig); indices=randint(1,n,n)+1; out=orig(indices,:);</PRE><H3><A NAME="SECTION00241100000000000000">Computing the bootstrap distribution for one sample</A></H3><FONT COLOR="#0000ff"><FONT SIZE="+1"><PRE>>> for (b =(1:1000)) res.bsample1=bsample(sample1); thetab(b)=sum(res.bsample1==1); end>>hist(thetab)</PRE></FONT></FONT>This is what the histogram looks like:<IMG SRC="histasp1.gif", width=500><BR>Here is the complete data set computation<FONT COLOR="#ff0000"><FONT SIZE="+1"><PRE>>> sample1=[zeros(1,10933),ones(1,104)]';>> sample2=[zeros(1,10845),ones(1,189)]';>> thetab=zeros(1,1000);>> for (b =(1:1000)) res.bsample1=bsample(sample1); thetab(b)=sum(res.bsample1==1); end</PRE></FONT></FONT><H3><A NAME="SECTION00241200000000000000">Comparing to a hypothetical parameter</A></H3>Suppose that we are trying to test<!-- MATH $\theta=\frac{2}{110}$ --><IMG WIDTH="63" HEIGHT="40" ALIGN="MIDDLE" BORDER="0" SRC="img17.png" ALT="$\theta=\frac{2}{110}$"><FONT COLOR="#0000ff"><FONT SIZE="+1"><PRE>>> for (b =(1:1000)) res.bsample1=bsample(sample1); thetab(b)=sum(res.resample1==1)-2; end>>hist(thetab)>> mean(thetab)ans = -0.9530>> var(thetab)ans = 1.0398>> sum(thetab>0)ans = 96</PRE></FONT></FONT>This is what the histogram looks like:<IMG SRC="histaspc.gif", width=500><BR><P><H3><A NAME="SECTION00241300000000000000">Computing the bootstrap distribution for two samples</A></H3><FONT COLOR="#0000ff"><FONT SIZE="+1"><PRE>>>thetab=zeros(1,1000);>> for (b =(1:1000)) res.bsample1=bsample(sample1); res.bsample2=bsample(sample2); thetab(b)=sum(res.bsample2==1)-sum(res.bsample1==1); end>>hist(thetab)</PRE></FONT></FONT>This is what the histogram looks like:<IMG SRC="histasp2.gif", width=500><BR><H3><A NAME="SECTION00241400000000000000">Without the computer</A></H3>Sample one could be considered as the realization ofa Binomial random variable, from some unkown Binomial distribution, for which the bestestimate given by maximum likelihood would be:<BR><P></P><DIV ALIGN="CENTER"><!-- MATH \begin{displaymath}B(n_1,p_1), \hat{p_1}=\frac{\sum X_i}{n}=\frac{104}{11037}\end{displaymath} --><IMG WIDTH="242" HEIGHT="46" BORDER="0" SRC="img18.png" ALT="\begin{displaymath}B(n_1,p_1), \hat{p_1}=\frac{\sum X_i}{n}=\frac{104}{11037}\end{displaymath}"></DIV><BR CLEAR="ALL"><P></P>The second sample would be considered as coming fromanother Binomial, in the most general case<BR><P></P><DIV ALIGN="CENTER"><!-- MATH \begin{displaymath}B(n_2,p_2), \hat{p_2}=\frac{\sum X_i}{n}=\frac{189}{11034}\end{displaymath} --><IMG WIDTH="242" HEIGHT="46" BORDER="0" SRC="img19.png" ALT="\begin{displaymath}B(n_2,p_2), \hat{p_2}=\frac{\sum X_i}{n}=\frac{189}{11034}\end{displaymath}"></DIV><BR CLEAR="ALL"><P></P>Theoretically, what can we say abou the distributionof <!-- MATH $\hat{p_1} - \hat{p_2}$ --><IMG WIDTH="62" HEIGHT="35" ALIGN="MIDDLE" BORDER="0" SRC="img20.png" ALT="$\hat{p_1} - \hat{p_2}$">?<P>How good would the Normal approximation to<IMG WIDTH="28" HEIGHT="35" ALIGN="MIDDLE" BORDER="0" SRC="img21.png" ALT="$X_1$"> be?<P>Here is an answer, this is NOT a simulationexperiment but the comparisonof the exact probability mass functions for the binomial and the relevantNormal approximation.<PRE>>> x=0:180;>> y=binopdf(x,11037,104/11037);>> plot(x,y,'+'); s=sqrt(104*((11037-104)/11037))s = 10.1499 hold on; z=normpdf(x,104,s); plot(x,z,'g-') text(20,.03,'+ Binomial(11037,104/11037)','FontSize',13,'Color',) text(20,.025,'-- Normal(104,s)','FontSize',13,'Color',) title('Aspirin Group','FontSize',13)hold off;</PRE><P>This is what the comparison looks like:<BR><IMG SRC="binomc.jpg", width=500>\\<P><H2><A NAME="SECTION00242000000000000000">First plug-in encounter</A></H2>It is known that for <!-- MATH $X \sim \B(n,p)$ --><IMG WIDTH="91" HEIGHT="37" ALIGN="MIDDLE" BORDER="0" SRC="img22.png" ALT="$X \sim \B(n,p)$">, the sampling distribution of<!-- MATH $\bar{x}=\hat{p}$ --><IMG WIDTH="50" HEIGHT="35" ALIGN="MIDDLE" BORDER="0" SRC="img23.png" ALT="$\bar{x}=\hat{p}$"> will be <!-- MATH $\N(p,\frac{pq}{n})$ --><IMG WIDTH="54" HEIGHT="37" ALIGN="MIDDLE" BORDER="0" SRC="img24.png" ALT="$\N(p,\frac{pq}{n})$">.So that the standard error of <IMG WIDTH="14" HEIGHT="35" ALIGN="MIDDLE" BORDER="0" SRC="img25.png" ALT="$\hat{p}$">depends on the unkown parameters,in order to estimate the standard error of <IMG WIDTH="14" HEIGHT="35" ALIGN="MIDDLE" BORDER="0" SRC="img25.png" ALT="$\hat{p}$">,it is a well known procedure to replace it by its estimate obtaining:<BR><P></P><DIV ALIGN="CENTER"><!-- MATH \begin{displaymath}\widehat{se}(\hat{p})=\sqrt{\frac{\hat{p}(1-\hat{p})}{n}}\end{displaymath} --><IMG WIDTH="152" HEIGHT="55" BORDER="0" SRC="img26.png" ALT="\begin{displaymath}\widehat{se}(\hat{p})=\sqrt{\frac{\hat{p}(1-\hat{p})}{n}}\end{displaymath}"></DIV><BR CLEAR="ALL"><P></P><P>This is the very first known occurrence of whatBrad Efron coined as the <FONT COLOR="#a52a2a"><EM>Plug in principle</EM></FONT>,which is an essential component in the bootstrap idea.<P>It is interesting to look at the early paper ofEfron's, the <A NAME="tex2html37" HREF="brad.ps">first bootstrap paper</A><P><HR><!--Navigation Panel--><A NAME="tex2html286" HREF="node11.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/home/depot/swtree/depot/latex2html-2002-2/latex2html-2002-2/icons/next.png"></A> <A NAME="tex2html284" HREF="node6.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/home/depot/swtree/depot/latex2html-2002-2/latex2html-2002-2/icons/up.png"></A> <A NAME="tex2html278" HREF="node9.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/home/depot/swtree/depot/latex2html-2002-2/latex2html-2002-2/icons/prev.png"></A> <BR><B> Next:</B> <A NAME="tex2html287" HREF="node11.html">Some notation</A><B> Up:</B> <A NAME="tex2html285" HREF="node6.html">Lectures</A><B> Previous:</B> <A NAME="tex2html279" HREF="node9.html">The questions addressed</A><!--End of Navigation Panel--><ADDRESS>Susan Holmes2004-05-19</ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?