I'm building a Markov Chain in R using the 'markovchain' library, I re-ran the code and always got slightly different results, despite no changes to the data going in.
I tested setting the seed to try to eliminate variation from a random seed, and still got small variations in the result. Can anyone explain why this may be?
Sample code below makes a selection of customer pathways leading to a binary responce, results at the bottom
Cheers Iain
#Create input vectors
uid <- c(1:90)
resp <- rep(c(0,1,0,0,0,1,0,0,1,0), times=9)
non_resp <- 1-resp
state1 <- rep(c('Email','DD'), times=45)
state2 <- rep(c(' > Email',' > DD',''), times=30)
state3 <- rep(c(' > Email',' > Email',' > DD','',' > Email',' > DD','','',' > Email'), times=10)
state4 <- rep(c(' > Email',' > DD','',' > Email',' > DD'), times=18)
path <- paste0(state1,state2,state3,state4)
#Create dataframe
df <- data.frame(uid, path, resp, non_resp)
#Build model
model_df <- markov_model(df,
var_path = 'path',
var_conv = 'resp',
var_null = 'non_resp',
out_more = TRUE)
model_df2 <- markov_model(df,
var_path = 'path',
var_conv = 'resp',
var_null = 'non_resp',
out_more = TRUE)
#Look at attribution
model_df$result
model_df2$result
Result
model_df$result
channel_name total_conversions
1 Email 14.80159
2 DD 12.19841
model_df2$result
channel_name total_conversions
1 Email 14.83336
2 DD 12.16664