- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have a dataset that contains the state details for 50 customers from time T1 to T20. The rows have customer ID followed by the sequence of states they were in for the past 20 time periods. There are only 4 states A, B, C, D. the data looks like this:
CUS-ID T1 T2 ... T20
C1 D C ... B
C2 C D ... A
...
C50 A C ... B
Using Markov chains I want to predict the state at time T21 and the associated probability of being in that predicted state. Is there a way in SAS where I can use a PROC or do I have to code from scratch? I also need help writing the code from scratch if there are no special PROCs.
I also do not have any initial transition probabilities. Is there a good rule that I can base my initial transition probabilities on?
Any help on documentation specific to similar problems will be much appreciated.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I think you should transform your data like:
ID PREV CURRENT
C1 D C
C1 C A
After that ,using proc freq to get transform probability .
And PROC TRANSPOSE to get transform matrix .
And put this matrix into SAS/IML and do some matrix multiply operator.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Rick_SAS did wrote a couple of blog about Markov Chain .
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I think you should transform your data like:
ID PREV CURRENT
C1 D C
C1 C A
After that ,using proc freq to get transform probability .
And PROC TRANSPOSE to get transform matrix .
And put this matrix into SAS/IML and do some matrix multiply operator.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Are you implying that I have only 2 time periods ( prev and current) and then calculate the transition probabilities or did you mean arrange the states from left to right left being the earliest?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
"mean arrange the states from left to right left being the earliest"
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content