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.
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.
@Rick_SAS did wrote a couple of blog about Markov Chain .
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.
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?
"mean arrange the states from left to right left being the earliest"
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.