Displaying 4 results from an estimated 4 matches for "no_of_st".
Did you mean:
no_of_x
2017 Aug 28
5
"Improvement with the R code"
...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$clusterNum[j]==k)
{
if(checkdf$clusterNum[j+1]==1){
cou...
2017 Aug 28
0
"Improvement with the R code"
...te <- 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 implement a formula
>
> aij= transition from state S_i to S_j/...
2017 Aug 28
0
"Improvement with the R code"
...t;>> }
>>>
>>> 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.co...
2017 Aug 28
0
"Improvement with the R code"
...or (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 ni...