【问题标题】:Uncertainties of measures in multivariate linear regression多元线性回归中测量的不确定性
【发布时间】:2020-09-03 14:08:00
【问题描述】:

我有一个数据集来进行多元线性回归:

                 Y = C + aX1 + bX2 + ε

但考虑因变量和自变量测量错误的情况(Y ± α,X1 ± β,X2 ± γ)。这条线是,

           Y = C + aX1 + bX2 + (ε + α + βa + γb)

我的问题是如何在回归中实现这些不确定性(α、β、γ)。每个 x 和 y 都有不同的不确定性。 python 中是否有库可以进行这种稳健的回归?

Sklearn.linear_model 执行多元线性回归,但没有不确定性(α、β、γ)。

【问题讨论】:

    标签: python python-3.x regression uncertainty


    【解决方案1】:

    我不明白你想问什么,问题不清楚,但我希望这能在我们从示例中学到一些东西。

    import pandas as pd
    import matplotlib.pyplot as plt
    
    # Initializing a dictionary 
    **Stock_Market = {'Year':[2017,2017,2017,2017,2017,2017,2017,2017,2017,2017,2017,2017,2016,2016,2016,2016,2016,2016,2016,2016,2016,2016,2016,2016],'Month': [12, 11,10,9,8,7,6,5,4,3,2,1,12,11,10,9,8,7,6,5,4,3,2,1],'Interest_Rate': [2.75,2.5,2.5,2.5,2.5,2.5,2.5,2.25,2.25,2.25,2,2,2,1.75,1.75,1.75,1.75,1.75,1.75,1.75,1.75,1.75,1.75,1.75],'Unemployment_Rate': [5.3,5.3,5.3,5.3,5.4,5.6,5.5,5.5,5.5,5.6,5.7,5.9,6,5.9,5.8,6.1,6.2,6.1,6.1,6.1,5.9,6.2,6.2,6.1], 'Stock_Index_Price': [1464,1394,1357,1293,1256,1254,1234,1195,1159,1167,1130,1075,1047,965,943,958,971,949,884,866,876,822,704,719]}**
    
    df = pd.DataFrame(Stock_Market,columns = ['Year','Month','Interest_Rate','Unemployment_Rate','Stock_Index_Price'])
    
    plt.scatter(df['Interest_Rate'], df['Stock_Index_Price'], color='red')
    plt.title('Stock Index Price Vs Interest Rate', fontsize=14)
    plt.xlabel('Interest Rate', fontsize=14)
    plt.ylabel('Stock Index Price', fontsize=14)
    plt.grid(True)
    plt.show()
    

    【讨论】:

    • 感谢您的警告。我试图改进解释。
    猜你喜欢
    • 2018-08-05
    • 2021-01-04
    • 2019-05-02
    • 2021-03-12
    • 2010-11-23
    • 2021-02-02
    • 2021-01-19
    • 2023-03-25
    • 2019-01-25
    相关资源
    最近更新 更多