I have a 30x30 symmetric matrix that I would like to use as a substitution cost matrix in TraMineR to analyze sequences of length 10 with an alphabet of 30. When I try to perform OM with this matrix, however, I get an error about the triangle inequality (see below).
Other matrices that I have made by hand seem to work fine (see example below). I thought the subcost matrix could be set any way I want as long as it was symmetric and the dimensions reflected the size of the alphabet. Are there limitations on how I can set the subcosts? Or perhaps something else is causing the problem?
Thanks
> diss1vs <- seqdist(bhpsfup.seqw, method = "OM", indel = .1*maxsub, sm = upsubcosts)
[>] 536 sequences with 30 distinct events/states
Error in checktriangleineq(sm, warn = FALSE, indices = TRUE, tol = tol) :
REAL() can only be applied to a 'numeric', not a 'integer'
Example matrix that works
zeroblock <- diag(6)
zeroblock[zeroblock == 1] <- 0
zeroblock
twoblock <- diag(6)
twoblock[twoblock == 0] <- 2
twoblock[twoblock == 1] <- 2
twoblock
submat.up1 <- cbind(zeroblock,twoblock,twoblock,twoblock,twoblock)
submat.up2 <- cbind(twoblock,zeroblock,twoblock,twoblock,twoblock)
submat.up3 <- cbind(twoblock,twoblock,zeroblock,twoblock,twoblock)
submat.up4 <- cbind(twoblock,twoblock,twoblock,zeroblock,twoblock)
submat.up5 <- cbind(twoblock,twoblock,twoblock,twoblock,zeroblock)
submat.up <- rbind(submat.up1, submat.up2, submat.up3, submat.up4, submat.up5)
submat.up