0

我正在使用“markovchain”库在 R 中构建马尔可夫链,我重新运行代码并总是得到略有不同的结果,尽管输入的数据没有变化。

我测试了设置种子以尝试消除随机种子的变化,但结果仍然有很小的变化。谁能解释为什么会这样?

下面的示例代码选择了导致二进制响应的客户路径,结果在底部

干杯伊恩

#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

结果

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
4

0 回答 0