Trying to build a matrix model.. Keep getting this error:
"Error in N.project[, 1] <- No :
number of items to replace is not a multiple of replacement length"
I have no idea how to fix this.
((((code below))))
n <- 4
A <- matrix(c(0,0,33.3,125.6,326.0,0.053,0,0,0,0,0,0.396,0,0,0,0,0,0.143,0,0,0,0,0,0.167,0,0,0,0,0,0),
nrow=6, byrow=TRUE)
# and the number of years, m, to be included in the projection
t.proj <- 20
N.project <- matrix(0, nrow = nrow(A), ncol = t.proj + 1)
No <- c(4,3,2,1)
N.project[,1] <- No
for (i in 1:t.proj) {
N.project[,i + 1] <- A %*% N.project[, i]
}
matplot(t(N.project),log="y")