R Transition Matrix -
R Transition Matrix -
i convert vector transitions matrix. have vector t , divided max value values between 0 , 1. made matrix
t <- c(22, 65, 37, 84, 36, 14, 9, 19, 5, 49) x <- t/max(t) y <- x%*%t(x) my problem want columns of matrix (y) add together 1, i.e. create transition matrix i'm not sure how that. suggestions appreciated!
sweep() versatile little function can utilize here split each column own sum:
yy <- sweep(y, margin = 2, stats = colsums(y), fun = "/") ## confirm columns of yy sum 1 colsums(yy) ## [1] 1 1 1 1 1 1 1 1 1 1 r
Comments
Post a Comment