Dear R-help list,
I have a problem storing results from a bootstrap loop. What I doing is
creating an empty matrix before the loop, then run the loop. Before the end
of the loop I have a command line which defines which results inside the
loop will have to go in the empty matrix. Here is the code I am using:

eigen.values<-rep(NA,boots)
#storage file for eigen values (1 for simulation)
ssd.values<-matrix(NA,nrow=boots,ncol=9, byrow=TRUE)          #storage file
for ssd (9 for each simulation)
for(i in
1:boots){
#beginning of bootstrap
B<-A
s<-rbeta(1,a,b)
#survival is sampled from beta distribution defined by a and b
B[2,1]<-s
B[3,2]<-s
#position of matrix where to substitute survival values
B[4,3]<-s
B[5,4]<-s
B[6,5]<-s
B[7,6]<-s
B[8,7]<-s
B[9,8]<-s
B[9,9]<-s
B[1,5]<-s*B[1,5]
#positions where to substitute fecundity values
B[1,6]<-s*B[1,6]
B[1,7]<-s*B[1,7]
B[1,8]<-s*B[1,8]
B[1,9]<-s*B[1,9]
eigs.B<-eigen(B)
#eigs.B
#obtain $values(growth rate) and $vectors(stable stage dist)
dom.pos<-which.max(eigs.B[["values"]])
#extract the dominant eigen value
L1<-Re(eigs.B[["values"]][dom.pos])
#extract only the real part of the eigenvalue (Re)
#L1
###ssd
dom.pos2<-which.max(eigs.B[["vectors"]])
#create index for dominant eigenvector
w<-Re(eigs.B[["vectors"]][,dom.pos2])
#extracting the real part of the eigenvector (Re)
ssd<-w/sum(w)

eigen.values[i]<-L1
#storing values from each iteration
ssd.values[i,]<-ssd

#rv.values[i]<-RV
}

The red bits are the one giving me problems. What I should get writing
ssd.values after the loop is ended is a matrix(100,9) storing in each row 9
values obtained by 1 run of the loop (each row should be different being the
output of a different simulation) of ssd<-w/sum(w). Unfortunately I get the
same 9 values of the first row in the subsequent 99. I have tried to change
the code of the last line ssd.values[i,]<-ssd many times but I only manged
to obtain an incomplete matrix or a single value repeated 100 times.
Can you help me?
Thanks a lot, Cecilia.

	[[alternative HTML version deleted]]

