I am new to quadratic programming and having trouble running the function QPmat in the package popbio, which uses a matrix of stage class counts to calculate stage class transition probabilities.
The code I am running:
####Create a matrix of time series stage class counts
Total<-
matrix(c(17,74,86,41,17,11,75,84,46,25,7,60,90,46,24,10,61,82,44,25),nrow=5,
ncol=4)
Total
## list nonzero elements counting by column, indices
nonzero <- c(1,2,7,8,13,14,19,20,25)
## create a constraint matrix, C
C <- rbind(diag(-1,5), c(1,1,0,0,0), c(0,0,1,0,0), c(0,0,0,0,1))
C
## calculate b vector
b <- apply(C, 1, max)
b
QPmat(Total,C,b,nonzero)
This call returns the error "Amat and dvec are incompatible!"
I think the problem is in the constraint matrix, C, but I have been unable to troubleshoot this. I have worked through a couple examples of the solve.QP function in quadprog but to no avail.