Skip to content

order and rm()

6 messages · Peter Wolf, Andrew Beckerman, Vaidotas Zemlys +3 more

#
Jess Balint wrote:

            
brevity.
out. In
character?
1. # to remove all objects whose names starts by "xyz" followed by a
digit use:
See: ->  help(ls) -> use of argument "pattern" -> regular expressions
Take care: wild characters / regular expressions are dangerous in
removal processes

2. # to sort a vector of strings by the last and the last but one
characters
Peter Wolf

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
1 day later
#
R1.61, WinNT

Dear listers - I am trying to implement the SPLUS example for boostrapping 
coefficients from a linear model -

boot(data.frame, coef(eval(model$call)))

I get errors saying that my statistic is not defined and that the 
replicates are not defined.  Changing this to -

boot(recTTM, statisitic=coef(eval(mod$call)),R=999)

still gives the error about the statistic.  Clearly I do not understand 
what the statisitic is and how to make the coefficients a function as in 
the examples in the help... can someone guide me on syntax?

cheers
andrew
----------------------------------------------------------
Dr. Andrew Beckerman
Institute of Biological Science
University of Stirling
Stirling FK9 4LA
+44 (0)1786 then wk-467808 fx-464994
(APB is not responsible for anything below this)
#
Hi,
Try ?boot. There are some examples and good explanation of arguments
boot function needs. 

As for a simple explanation, in your case (with default parameters)
statistic must be a function of two arguments, first argument the data,
and second the vector of indices which define the bootstrap sample.  For
example let us say that our data is my.data, and we want to bootstrap
linear regression coefficients, where dependent variable is the first
column of my.data, and independent variables are the rest columns of
my.data. Then the call to boot function would be

boot(my.data,statistic=boot.fun,R=999),

where

boot.fun <-
function(data,ind) {
    coef(lsfit(data[ind,-1],data[ind,1],intercept=TRUE))
    #Note: we could use the lm, but if we only need the regression
    #coefficients, lsfit is faster
}

Hope it helps

Vaidotas Zemlys

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Dear Andrew,

My R and S-PLUS Companion has an on-line appendix on bootstrapping 
regression models that might be of help. You can find it (and other 
appendices) at 
<http://www.socsci.mcmaster.ca/jfox/Books/Companion/appendix.html>.

I hope that this answers your questions.
  John
At 02:17 PM 11/20/2002 +0000, Andrew Beckerman wrote:
____________________________
John Fox
Department of Sociology
McMaster University
email: jfox at mcmaster.ca
web: http://www.socsci.mcmaster.ca/jfox
____________________________

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Let's see?  boot is not part of R, but there is one in package boot.
However, S-PLUS does not come with boot at all.  I think you are
trying to use an example from the wrong package, perhaps for a
function called `bootstrap'?

The boot package and the book it supports (and MASS and the book it
supports) have plenty of examples of this, so why not follow them?
You do need to be aware of the difference beween bootstrapping
cases and bootstrapping residuals.  There's an example of the latter in
?boot.
On Wed, 20 Nov 2002, Andrew Beckerman wrote:

            

  
    
#
Your error is based on a misunderstanding of what the 'statistic' should
look like for the boot() function.  The statistic needs to take the data
as an argument and a vector of indices -- it is the indicies which get
resampled.  

I wrote a very simple package for bootstrapping in a few classical
situations, including linear models.  You can resample rows and residuals.
It's available at http://department.stat.ucla.edu/~rpeng/uclaboot.  The
interface is (in my opinion, of course!) a little easier to use than the
boot library.  

-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng
On Wed, 20 Nov 2002, Andrew Beckerman wrote:

            
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._