Displaying 4 results from an estimated 4 matches for "generate_transition_matrix".
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 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
5
"Improvement with the R code"
Hello,
I am trying to implement a formula
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
2017 Aug 28
0
"Improvement with the R code"
...e <
>> 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...