Python函数可计算Beta矩阵

我正在寻找一种有效的功能,可以在给定变量和一组预测变量作为python中的DataFrame的情况下,为每种可能的多元回归模型自动生成beta。

例如,给定以下数据集:

enter image description here

https://i.stack.imgur.com/YuPuv.jpg
The dependent variable is 'Cases per Capita' and the columns following are the predictor variables.

在一个更简单的示例中:


  Student   Grade    Hours Slept   Hours Studied   ...  
 --------- -------- ------------- --------------- ----- 
  A             90             9               1   ...  
  B             85             7               2   ...  
  C            100             4               5   ...  
  ...          ...           ...             ...   ...  

beta矩阵输出如下所示:


  Regression   Hours Slept   Hours Studied  
 ------------ ------------- --------------- 
           1   #             N/A            
           2   N/A           #              
           3   #             #              

The table size would be [2^n - 1] where n is the number of variables, so in the case with 5 predictors and 1 dependent, there would be 31 regressions, each with a different possible combination of beta calculations.

The process is described in greater detail here and an actual solution that is written in R is posted here.

评论