I have some transactional data and I wish to convert this to a transition matrix if possible.
The data represents the sequence of products each customer purchased from a company.
Here is a sample of the data I am working with:
sales <- data.frame(MBR_ID = c(1,1,1,2,2,2,2,3,3,3,3,3),DATE = as.Date(c('2020-01-01','2020-02-01','2020-03-01','2020-01-01','2020-02-01','2020-03-01','2020-04-01','2020-04-01','2020-04-02','2020-04-03','2020-04-04','2020-04-05')), PROD = c('A','B','C','A','C','A','A','D','D','D','D','D'))
Can this data be converted into matrix format such that the cells in the matrix represent the probability of moving between products?
My ultimate goal is to use this matrix in a Markov Model (markovchain package) to estimate what the market share for each of the products will be in X time periods from now.
I would be very grateful for any feedback.