So I am working on using a Leslie matrix that I have created using the popbio package in R-Studio, and have succesfully created my Leslie matrix. I am asked in an exercise to now use the pop.projuction function out of the popbio package to calculate the stable age distribution using the Leslie matrix I created (les.mat). I was unsure of how to start so I started by typing ??pop.projection and see that there is something called-
stable.stage - "Estimate of stable stage distribution using proportions in last stage vector"
but I am unsure of how to properly use that stable.stage section with my Leslie matrix (les.mat) to get an estimated stable stage distribution. Here is the code I have tried in my attempt to see if I can figure out this stable.stage part of the pop.projection function.
Sx <- c(0.8,0.8,0.7969,0.6078,0.3226,0)
mx <- c(0,0,0.6,1.09,0.2,0)
n.0 <- c(100,80,64,51,31,10)
Fx <- mx # fecundity values
S <- Sx # dropping the first value
F <- Fx
les.mat <- matrix(rep(0,36),nrow=6)
les.mat[1,] <- F
les.mat
for(i in 1:5){
les.mat[(i+1),i] <- S[i]
}
les.mat
pop.pro <- pop.projection(les.mat, n.0[-7], 50)
pop.pro
??pop.projection
stable.stage(pop.pro)
stable.stage(les.mat)
when I tried running stable.stage with my population projection (pop.pro) I got the error I'll state below-
Error in eigen(A) : non-square matrix in 'eigen'
However when I tried using stable.stage with my Leslie matrix (les.mat) I got an output that shows-
[1] 0.29786502 0.23816811 0.19043542 0.15167908 0.09214261 0.02970975
That code output looks promising to me because this population ecology exercise only provided data for age (x) from 0 years through 6 years and my stable.stage output gave me 6 different (% of population) values.
So I guess I am mainly wondering if using the stable.stage with my Leslie matrix (les.mat) is a correct way of getting an estimated stable age distribution, and if not is there some part of the code I might be missing, that I should be incorporating in when using the stable.stage or should I completely be ignoring that and somehow using the pop.projection function somehow? Before moving on in my analysis I want to try and make sure that the values I received from the stable.stage line of code I ran are correctly done. Thanks so much for anyone who takes the time to work with me on this!