简体   繁体   中英

Uncertainties of measures in multivariate linear regression

I have a dataset to do a multivariate linear regression:

                 Y = C + aX1 + bX2 + ε

But consider the case where the dependent and independent variables are measured in error (Y ± α, X1 ± β, X2 ± γ). The line is,

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

My question is how to implement these uncertainties (α, β, γ) in the regression. Each x and y has different uncertainties. Are there libraries in python to do this kind of robust regression?

Sklearn.linear_model performs multivariate linear regression, but without the uncertainties (α, β, γ).

I can"t understand what do you want to ask for, the question is not clear, But I hope this will suggest something to you as we learn from examples.

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM