Thanks for responding :) Again...
 
 I understand how indexing works (basically as in any other programming language), that is why I am so confused as to why that statement made my bootstraping work!  It seems like, if anything, it would completely screw up everything.
 
 Here is the (now working) cs function after I amended it to what you said to do (i.e. I added the _very confusing_ statement data<-data[w,]):
 
 >cs<-function(data, w){
 data<-data[w,];
 y<-data[1];
 x1<-data[2];
 x2<-data[3];
 x3<-data[4]; 
 z<-data[5];  
 c1<-x1*z;
 c2<-x2*z;
 c3<-x3*z;
 X<-cbind(x1,x2,x3,z,c1,c2,c3);
 regcoef<-lsfit(X,y)$coefficients;
 bx1<-regcoef[[2]];
 bx2<-regcoef[[3]];
 bx3<-regcoef[[4]];
 bz<-regcoef[[5]];
 bc1<-regcoef[[6]];
 bc2<-regcoef[[7]];
 bc3<-regcoef[[8]];
 fx<-bx1*x1+bx2*x2+bx3*x3;
 gy<-bz*z;
 hxy<-bc1*c1+bc2*c2+bc3*c3;
 sfx1<-cov(fx,x1); 
 sfx2<-cov(fx,x2); 
 sfx3<-cov(fx,x3); 
 sgx1<-cov(gy,x1); 
 sgx2<-cov(gy,x2); 
 sgx3<-cov(gy,x3); 
 shx1<-cov(hxy,x1); 
 shx2<-cov(hxy,x2);
 shx3<-cov(hxy,x3); 
 sTx1<-cov(y,x1); 
 sTx2<-cov(y,x2); 
 sTx3<-cov(y,x3); 
 dataout<-c(sfx1,sgx1,shx1,sTx1,sfx2,sgx2,shx2,sTx2,sfx3,sgx3,shx3,sTx3);
 dataout
 }
 
 An example data frame would be
 
 >mydata<-data.frame(Y=rnorm(20,0,1),X1=rnorm(20,0,1),X2=rnorm(20,0,1),X3=rnorm(20,0,1),Z=rnorm(20,0,1))
 
 The  boot statement is
 
 >boot(mydata,cs,R=999)
 
 Why does this rather mysterious indexing statement "data<-data[w,]" make the bootstrap work when it didn't beforehand?
 
 Thanks,
 Ben
 
 ps. I'll tell Melanie and Storfer hello.
 
-------------------------------
Benjamin Ridenhour
School of Biological Sciences
Washigton State University
P.O. Box 644236
Pullman, WA 99164-4236
Phone (509)335-7218
-------------------------------- 
"Nothing in biology makes sense except in the light of evolution."
-T. Dobzhansky


----- Original Message ----
From: Andrew Robinson <A.Robinson@ms.unimelb.edu.au>

Cc: r-help@stat.math.ethz.ch
Sent: Wednesday, January 18, 2006 15:45:15
Subject: Re: [R] Bootstrapping help

Ben,

although I appended a smiley to my first note, the message was
serious.  If you don't show us what you're doing, we can't help you.
Please provide an example in which you:

1) generate a small dataframe similar in structure to yours
2) provide cs
3) show the boot statement that applies cs to the example dataframe.

Also, it seems that you are unfamiliar with the use of indexing and
datframes.  Please read the Introduction to R, carefully, it is freely
available on CRAN.  You have asked R to provide you with all the rows
that are numbered 1/sample size.R; since the row numbers are integers
there aren't any.

And, please say hello to Andrew Storfer and Melanie Murphy from me.

Andrew

On Wed, Jan 18, 2006 at 11:39:36AM -0800, Ben Ridenhour wrote:
> 
>    Andrew,
>    Thanks for the suggestion!  This seems to have fixed things.  I was
>    wondering if you could explain why this works and what was wrong.  If
>    I issue the command
>    >my.boot<-boot(dataframe,cs,R=999)
>    and in order to what effect the command you told me use has I then do
>    something like
>    >dataframe[my.boot$weights,]
>    my.boot$weights looks to be a vector where element is 1/sample size.R
>    reports that
>    [1] var1    var2   var3   var4 var5
>    <0 rows> (or 0-length row.names)
>     Which indicates to me that I then have a dataframe with no data in
>    it! (Am I wrong about this?)  What is going on here?  Why did this
>    work?  Sorry for the basic questions.
>    Ben

-- 
Andrew Robinson  
Department of Mathematics and Statistics            Tel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia         Fax: +61-3-8344-4599
Email: a.robinson@ms.unimelb.edu.au         http://www.ms.unimelb.edu.au




	[[alternative HTML version deleted]]


