Saskia Sandring
2006-Feb-09  13:45 UTC
[R] bootstrapping lambda values from projections matrices
Dear all,
I'm working with a population projections matrix model from demographic
data. The dominant eigenvalue of the matrix is the growth rate of the
population (lambda). I would like to estimate confidence intervals for the
lambda values with bootstrap. 
The function for calculating the eigenvalue I wrote like this: 
mat.fun <- function(d,i){
    mat<-matrix(c(0,
    sum(d$klyear1[i]==1&d$classyear2[i]==2)/sum(d$classyear1[i]==1),
    sum(d$classyear1[i]==1&d$classyear2[i]==3)/sum(d$classyear1[i]==1), 0,
    sum(d$classyear1[i]==2&d$classyear2[i]==2)/sum(d$classyear1[i]==2),
    sum(d$classyear1[i]==2&d$classyear2[i]==3)/sum(d$classyear1[i]==2),
    sum(d$classyear1[i]==0&d$classyear2[i]==1)/sum(d$classyear1[i]==3),
    sum(d$classyear1[i]==3&d$classyear2[i]==2)/sum(d$classyear1[i]==3),
    sum(d$classyear1[i]==3&d$classyear2[i]==2)/sum(d$classyear1[i]==3),
sum(d$classyear1[i]==3&d$classyear2[i]==3)/sum(d$classyear1[i]==3)),ncol=3)
    abs(eigen(mat,only.values=T)$values[1])
}
Now, in the pooled matrix from all years I would like to sample in a way
that the number of bootstrap samples taken from each year is equal to the
number of data points from each year. Therefore I'm defining strata=year. 
boot1 <- boot(myfile, mat.fun, 5000, strata=myfile$year); boot1
Is this the correct way to do it or did I misunderstand the
strata-argument? I checked in Davison, A.C. and Hinkley, D.V. (1997), but
I'm still not quite sure.
Thanks very much in advance for your help!
Sincerely,
Saskia Sandring
_________________________________________________________________________
Saskia Sandring
Avd. f??r v??xtekologi, Evolutionsbiologiskt centrum, Uppsala universitet
Dept. of Plant Ecology, Evolutionary Biology Centre, Uppsala University
Villav??gen 14			tel: 018-471 2870 (int +46 18 4712870)
SE-752 36 Uppsala		fax: 018-55 34 19 (int +46 18 553419)
SWEDEN				email: saskia.sandring at ebc.uu.se
http://www.vaxtbio.uu.se/resfold/sandring.htm
