我在Lepkovitch矩阵中为R中的matplot中的4个年龄类创建了一个图。该图给出了4行。我不知道这些矩阵的哪些元素对应。如何显示图例以找出我的图中的线条代表什么?任何建议表示赞赏。
C<-matrix(c(0, 0.0043, 0.1132, 0,
0.9775, 0.9111, 0, 0,
0, 0.0736, 0.9534, 0,
0, 0, 0.0452, 0.9804),nr=4, byrow=TRUE)
## Find eigen values
eigs.C<-eigen(C)
## calculate the dominant eigenvalue
dominant<-which.max(eigs.C[["values"]])
## Assign the dominant value to lambda
lambda<-Re(eigs.C[["values"]] [dominant])
## For finding the stable stage distribution:
w<-Re(eigs.C[["vectors"]] [, dominant])
ssd<-w/sum(w)
## And for the reproductive values
M<-eigen(t(C))
v<-Re(M$vectors[, which.max(Re(M$values))])
RV<-v/v[1]
## To get there calculate the sensitivities:
vw.s<-v%*%t(w)
S<-vw.s/as.numeric(v %*% w)
## Then, for calculating the elasticities:
elas<-(C/lambda)*S
round(elas,4)
K<-300
Yield<-c()
T=100; N0<-matrix(c(15,50,80,60),ncol=1)
N<-matrix(0,nrow=nrow(C), ncol=T+1)
N[,1]<-N0
Popsize<-matrix(0,ncol=T)
Popsize[1]<-sum(N0)
for (i in 1:T)
{
C[1,3]<-0.05*(1-(sum(N[,i])/K)); C[1,3]<-C[1,3]-rnorm(1,0,0.1);
if (C[1,4]<0) {C[1,4]<-0}
C[1,4]<-0.35*(1-(sum(N[,i])/K)); C[1,4]<-C[1,4]-rnorm(1,0,0.1);
if (C[1,4]<0) {C[1,4]<-0}
Yield[i]<-round(0.1*N[1,i],digits=0)
N[1,i]<-N[1,i]-Yield[i]
N[,i+1] <- C%*%N[,i]
Popsize[i] <- sum(N[,i])
}
matplot(0:T,t(N),type="l",lty=1:3,col=1,ylab="Stage
abundance",xlab="Year")
plot(1:T,Popsize,type="o")