[R] Unexp. behavior from boot with multiple statistics

2011-05-03 Thread algorimancer
I am attempting to use package boot to summarize and compare the performance
of three models.  I'm using R 2.13.0 in a Win32 environment.

My statistic function returns a vector of 6 values, 3 of which are error
rates for different models, and 3 are pairwise differences between those
error rates.  It looks like:

multiEst<-function(dat,i)
{
   
c(E1,E2,E3,E2-E1,E3-E1,E3-E2);
}

then I call boot (using R=4 for simplicity of description) with:

multiBoot=boot(data,multiEst,R=4)

which gives reasonable results:

Bootstrap Statistics :
original  biasstd. error
t1* 0.07  0.3775  0.04193249
t2* 0.08  0.3750  0.04654747
t3* 0.04  0.4200  0.05354126
t4* 0.01 -0.0025  0.0050
t5*-0.03  0.0425  0.0150
t6*-0.04  0.0450  0.01290994

and the resulting "t0" contains the expected estimates of the statistics,
> multiBoot$t0
[1]  0.07  0.08  0.04  0.01 -0.03 -0.04

however "t", which is supposed to contain bootstrap replicates of the
statistic, doesn't.  It looks like this:
> multiBoot$t
 [,1] [,2] [,3] [,4] [,5]  [,6]
[1,] 0.46 0.47 0.46 0.01 0.00 -0.01
[2,] 0.39 0.39 0.39 0.00 0.00  0.00
[3,] 0.45 0.46 0.47 0.01 0.02  0.01
[4,] 0.49 0.50 0.52 0.01 0.03  0.02

It is not clear where these columns come from --- they clearly do not
resemble the estimates in "t0".

If I define a separate statistic function for each desired estimate, the
resulting "t" and "t0" are as expected, however it is important in this case
that the separate estimates derive from the same bootstrap replicates.

Any helpful suggestions? Or have I come upon a bug in the implementation?

Note: the documentation provides the following definitions for these
returned variables:

t0  The observed value of statistic applied to data.
t   A matrix with R rows each of which is a bootstrap replicate of 
statistic. 









--
View this message in context: 
http://r.789695.n4.nabble.com/Unexp-behavior-from-boot-with-multiple-statistics-tp3493300p3493300.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Unexp. behavior from boot with multiple statistics

2011-05-04 Thread algorimancer
Thanks, that clears things up quite a bit.  Now I'm left wondering why there
is so much bias, but that's a separate issue.

--
View this message in context: 
http://r.789695.n4.nabble.com/Unexp-behavior-from-boot-with-multiple-statistics-tp3493300p3495590.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to *completely* stop a script after stop()?

2011-04-08 Thread algorimancer
I too am encountering this problem.  When I have a large script, if I select
all in the editor and then ctrl-r to run, if it encounters a stop() function
it simply prints an error message and continues to execute the remainder of
the script, as opposed to terminating execution at that line.  The quit()
function exits R altogether, which I don't want.  Yes, I could manually
select only the portion of script which I want to run, but for lengthy
scripts which I run repeatedly (generally changing only the name of the file
I want analyzed), this can be quite tedious.  It appears that the only
solution is to put most of the code in a separate file and call it using
source(); this has the downside of reducing the clarity of the code -- it's
a sort-of structural spaghetti code approach.

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-completely-stop-a-script-after-stop-tp3218808p3436704.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to *completely* stop a script after stop()?

2011-04-08 Thread algorimancer
Thank you all for the astoundingly quick responses.  I think that the
bounding open/closed braces approach sounds like the easiest solution for
the moment -- though I look forward to seeing this all automated in a future
version of R :)

Incidentally, I have indeed encapsulated much of the code as functions which
I call using source(); the problematic (lengthy) front-end is a decision
tree which tailors a specific analysis to designated files.  This mimics the
switch/case structure which I'm more familiar with in c/c++.  There's a
limit to how much can be neatly moved to a separate file.

Thank you again for your assistance.

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-completely-stop-a-script-after-stop-tp3218808p3437025.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.