Skip to content

media coefficient posterior distribution comes out too sparse #55

Answered by ghost
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

I have resolved the issue myself now. I found that the code below appends posterior samples column-wise instead of row-wise. After switching i and j assignments, I am able to get the same plots as in the original medium post.

# plot media coefficients' distributions
# red line: mean, green line: median
beta_media = {}
for i in range(len(mmm['media_vars'])):
    md = mmm['media_vars'][i]
    betas = []
    for j in range(len(mmm['beta_list'])):
        betas.append(mmm['beta_list'][j][i])
    beta_media[md] = np.array(betas)

f = plt.figure(figsize=(18,15))
for i in range(len(mmm['media_vars'])):
    ax = f.add_subplot(5,3,i+1)
    md = mmm['media_vars'][i]
    x = beta_media[md]
    mean_…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
0 participants