subseting dataframe conditions on factor(binary) column(vector in r language)

﹥>﹥吖頭↗ 提交于 2019-12-20 06:13:41

问题


i have a sequence of 1/0's indicating if patient is in remission or not,

assume the records of remission or not were taken at discrete times,

how can i check the markov property for each patient, then summarize the findings, that is the assumption that the probability of remission for any patient at any time depends only if the patient had remission the last time/not remission last time(same as thing as saying probability of remission for any patient at any time depends only if the patient had remission in the previous row, well if not first observation)

P(r=1 at t=t+1|r=1 at t)=p(r=1 at t+1|r=1 at t, r=0 at t=t-1, r=1 at t=t-2, r=1 at t=t-3)

easy to understand if you understand the markov property

this is an exercept of my df

patientId remission

ju67       1

ju67       0

ju67       0

ju88       1

ju88       1

ju23       1

ju23       0

any ideas? subsetting the dataframe with the required condtions then computing probabilities using 'msm' package or (probably better way) just viewing the state transitions table will work but how do i do this, for the subsets of dataframe i would need for example to include only patients with three consecutive 0's in remission(including 0 in remission now) and compare this to subset of a dataframe with two consecutive 0's in remission(including 0 in remission now) –

来源:https://stackoverflow.com/questions/29804288/subseting-dataframe-conditions-on-factorbinary-columnvector-in-r-language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!