statistics - 统计测试 : how do (perception; actual results; and next) interact?

标签 statistics regression probability non-linear-regression hypothesis-test

perception之间有什么互动, outcome , 和 outlook ?

我已将它们带入分类变量以 [潜在地] 简化事情。

import pandas as pd
import numpy as np

high, size = 100, 20
df = pd.DataFrame({'perception': np.random.randint(0, high, size),
                   'age': np.random.randint(0, high, size),
                   'smokes_cat': pd.Categorical(np.tile(['lots', 'little', 'not'],
                                                        size//3+1)[:size]),
                   'outcome': np.random.randint(0, high, size),
                   'outlook_cat': pd.Categorical(np.tile(['positive', 'neutral',
                                                          'negative'],
                                                          size//3+1)[:size])
                  })
df.insert(2, 'age_cat', pd.Categorical(pd.cut(df.age, range(0, high+5, size//2),
                                              right=False, labels=[
                                               "{0} - {1}".format(i, i + 9)
                                               for i in range(0, high, size//2)])))

def tierify(i):
    if i <= 25:
        return 'lowest'
    elif i <= 50:
        return 'low'
    elif i <= 75:
        return 'med'
    return 'high'

df.insert(1, 'perception_cat', df['perception'].map(tierify))
df.insert(6, 'outcome_cat', df['outcome'].map(tierify))

np.random.shuffle(df['smokes_cat'])

在线运行:http://ideone.com/fftuSvhttps://repl.it/repls/MicroLeftSequences

这是伪造的数据,但应该提出这个想法。个人看法 perception ,然后他们会看到实际的 outcome ,从中可以决定他们的outlook .

使用 Python( Pandas ,或任何真正开源的东西),我如何显示概率 — 和 p 值— 这些之间的相互作用 3 依赖 栏目 (可能使用 agesmokes_cat 作为潜在的混杂因素)?

最佳答案

您可以为此特定目的使用交互图。这非常适合您的情况。我会为你的数据使用这样的情节。我已经针对问题中生成的虚拟数据进行了尝试,您可以编写如下代码。虽然将其视为伪代码,但您必须根据需要定制代码。

以其简单的形式:

  • 如果图中的线与其他值有交点或可能有交点,则您可以假设存在交互作用。
  • 如果线平行或不太可能有交点,则您假设没有交互作用。

  • 然而,为了获得更多和更深入的理解,我放置了一些您可以查看的链接。

    代码
    ... # The rest of the code in the question.
    
    # Interaction plot
    import matplotlib.pyplot as plt
    from statsmodels.graphics.factorplots import interaction_plot
    
    p = interaction_plot(
                   x = df['perception'],
                   trace=df['outlook_cat'],
                   response= df['outcome']
         )
    plt.savefig('./my_interaction_plot.png') # or plt.show()
    

    您可以找到 interaction_plot() 的文档here .此外,我还建议您运行方差分析。

    进一步阅读

    您可以查看这些链接:
  • (一篇论文)题为Interaction Effects in ANOVA .
  • (一案例)实践中case .
  • (另一种情况)实践中case .
  • 关于statistics - 统计测试 : how do (perception; actual results; and next) interact?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57536795/

    相关文章:

    python - Python 中的 OLS Breusch Pagan 测试

    algorithm - OpenCV线拟合算法

    matlab - 两个向量之间的马氏距离

    machine-learning - 使用梯度下降的逻辑回归

    python - 如何在 plotly express scatter 中为多种颜色设置一条趋势线?

    statistics - 计算点击率时如何避免展示偏差?

    python - 在 jupyter 笔记本下使用 scipy.optimize 中的 fmin 进行数据拟合

    java - 检查 20 个随机 boolean 值是否具有相同的值

    java - Alias 方法的开源实现

    neural-network - 焦点损失实现