[R] vectorized "leave one out" analyses

About this list Date view Thread view Subject view Author view Attachment view

From: Allan Strand (stranda@cofc.edu)
Date: Tue 04 Feb 2003 - 06:28:04 EST


Message-id: <87isw1nozf.fsf_-_@linum.cofc.edu>

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

______________________________________________ R-help@stat.math.ethz.ch mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jul 2003 - 09:11:21 EST