search for: checkdf

Displaying 4 results from an estimated 4 matches for "checkdf".

2017 Aug 28
5
"Improvement with the R code"
...rmula aij= transition from state S_i to S_j/no of transition at state S_i 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$cluster...
2017 Aug 28
0
"Improvement with the R code"
...(data) - 1)) { source_state <- data[k] dest_state <- data[k+1] transitions[source_state, dest_state] <- transitions[source_state, dest_state] + 1 } for (k in 1:n_states) transitions[k,] <- transitions[k,] / sum(transitions[k,]) transitions } checkdf=data.frame(clusterNum=c(3,2,3,1,1,3,4,3,2,1,1,3,2,1,3,2)) no_of_state=4 transition_matrix= generate_transition_matrix(checkdf$clusterNum, no_of_state) transition_matrix 2017-08-28 16:37 GMT+02:00 niharika singhal <niharikasinghal1990 at gmail.com>: > Hello, > > I am trying to im...
2017 Aug 28
0
"Improvement with the R code"
...usly. 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:00 niharika singhal <niharikasinghal1990 at gmail.com>: > yes or S_i= number of state > >...
2017 Aug 28
0
"Improvement with the R code"
...te, dest_state] <- >>> transitions[source_state, dest_state] + 1 >>> } >>> >>> for (k in 1:n_states) >>> transitions[k,] <- transitions[k,] / sum(transitions[k,]) >>> transitions >>> } >>> >>> checkdf=data.frame(clusterNum=c(3,2,3,1,1,3,4,3,2,1,1,3,2,1,3,2)) >>> no_of_state=4 >>> >>> transition_matrix= generate_transition_matrix(checkdf$clusterNum, >>> no_of_state) >>> transition_matrix >>> >>> >>> >>> 2017-08-28 16...