[R] vectorized "leave one out" analyses
    Allan Strand 
    stranda at cofc.edu
       
    Mon Feb  3 20:29:05 CET 2003
    
    
  
Hi all,
I'm implementing a population genetic statistic that requires repeated
re-estimation of population parameters after a single observation has
been left out.  It seems to me that one could:
a) use looping in R,
b) use a vectorized approach in R,
c) loop in a dynamically loaded c-function,
d) or use an existing jackknife routine.
an untested skeleton of the code for  'a':
foo <- function(datfrm)
{
  retvec <- rep(0,nrow(datfrm))
  selvec <- rep(T,nrow(datfrm))
  for (i in 1:nrow(datfrm))
    {
       selvec[i] <- F
       retvec[i] <- popstat(datfrm[selvec]) 
       selvec[i] <- T
    }
  retvec
}
I suppose that 'd' is the easiest option if such a routine exists, but
I have not come across one by means of an archive search.  I'd like to
avoid 'a' because of efficiency, and 'c' because of additional coding
and linking steps.  I like the idea of 'b' because it would be nifty
and likely fast, though there may be memory issues.  I'm sure that
this is a general problem that somebody has solved in an elegant
fashion.  I'm just looking for the solution. 
-- 
Allan Strand,   Biology    http://linum.cofc.edu
College of Charleston      Ph. (843) 953-9189
Charleston, SC 29424       Fax (843) 953-9199
    
    
More information about the R-help
mailing list