search for: transition_matrix

Displaying 5 results from an estimated 5 matches for "transition_matrix".

2017 Aug 28
5
"Improvement with the R code"
...Code I have written is working with three state {1,2,3 }, but if the number of states become={1,2,3,4,......n} then the code will not work, so can some help me with this. For and some rows of my data frame look like checkdf=data.frame(clusterNum=c(3,2,3,1,1,3,4,3,2,1,1,3,2,1,3,2) no_of_state=3 transition_matrix=matrix(NA,nrow=no_of_state, ncol=no_of_state) for(k in 1: no_of_state) { count1=0 count2=0 count3=0 #For last point no transition takes place for(j in 1: (nrow(checkdf)-1)) { if(checkdf$clusterNum[j]==k) { if(checkdf$clusterNum[j+1]==1){ count1=count1+1 }...
2017 Aug 28
0
"Improvement with the R code"
Hi, I think you overthought this one a little bit, I don't know if this is the kind of code you are expecting but I came up with something like that: generate_transition_matrix <- function(data, n_states) { #To be sure I imagine you should check n_states is right at this point transitions <- matrix(0, n_states, n_states) #we could improve a little bit here because at step N+1 source is dest from step N #but it would not be as readable for (k...
2017 Aug 28
0
"Improvement with the R code"
Chuck (Is it fine to call you Chuck?) has far more R jutsu than I do obviously. I don't know much about pmin and factor but it might worth looking into if you want to manipulate states by names (I assume this is why one might want to use it?) generate_transition_matrix <- function(data, states) prop.table(table(head(data, -1), tail(data, -1)), 1)[states,] checkdf=data.frame(clusterNum=c(3,2,3,1,1,3,1,3,2,1,1,3,2,1,3,2)) states=c(2,3) transition_matrix= generate_transition_matrix(checkdf$clusterNum, states) transition_matrix 2017-08-28 18:09 GMT+02:0...
2017 Sep 20
1
How to use depmix for HMM with intial parameters
Hello, I have initial parameters for HMM model and I want to use depmixS4 package. The parameters are in the form intial_prob_matrix=matrix(c(0.07614213, 0.45177665, 0.47208122), nrow=1, ncol=3, byrow = TRUE) transition_matrix=matrix(c(0.46666667,0.46666667,0.06666667, 0.06741573,0.5617978,0.37078652, 0.02173913,0.3478261,0.63043478), nrow = 3, ncol = 3, byrow = TRUE) meanval_matrix=matrix(c(545.1737,545.1737,803.5235, 565.7763,673.8019,797.5283,...
2017 Aug 28
0
"Improvement with the R code"
...t;> elie.canonicimerle at gmail.com> wrote: >> >>> Hi, >>> >>> I think you overthought this one a little bit, I don't know if this is >>> the kind of code you are expecting but I came up with something like that: >>> >>> generate_transition_matrix <- function(data, n_states) { >>> >>> #To be sure I imagine you should check n_states is right at this >>> point >>> >>> transitions <- matrix(0, n_states, n_states) >>> >>> #we could improve a little bit here because...