R-lrm(逻辑回归-rms软件包)-绘制季度预测值和已实现值

时间:2019-10-16 10:42:30

标签: r logistic-regression

我正在使用rms的lrm软件包进行逻辑回归。

mod1b <- lrm(dependent_variable ~ InterestRate + quarterYear, data = my_data)
print(mod1b)

我得到以下输出:

> mod1b <- lrm(dependent_variable ~ InterestRate + quarterYear, data = my_data)
> print(mod1b)
Logistic Regression Model

 lrm(formula = dependent_variable ~ InterestRate + quarterYear, 
     data = my_data)

                       Model Likelihood     Discrimination    Rank Discrim.    
                          Ratio Test           Indexes           Indexes       
 Obs         19209    LR chi2    2976.40    R2       0.229    C       0.764    
  0          15465    d.f.            39    g        1.027    Dxy     0.528    
  1           3744    Pr(> chi2) <0.0001    gr       2.792    gamma   0.528    
 max |deriv| 7e-10                          gp       0.161    tau-a   0.166    
                                            Brier    0.130                     

                    Coef    S.E.   Wald Z Pr(>|Z|)
 Intercept          -1.1097 0.1956  -5.67 <0.0001 
 InterestRate       -5.9861 0.4951 -12.09 <0.0001 
 quarterYear=1 2010  1.8184 0.2197   8.28 <0.0001 
 quarterYear=1 2011  1.9568 0.2262   8.65 <0.0001 
 quarterYear=1 2012  0.9345 0.2321   4.03 <0.0001 
 quarterYear=1 2013 -0.3628 0.2544  -1.43 0.1537  
 quarterYear=1 2014 -0.2646 0.2250  -1.18 0.2396  
 quarterYear=1 2015 -0.2819 0.2228  -1.27 0.2057  
 quarterYear=1 2016 -0.3884 0.2233  -1.74 0.0820  
 quarterYear=1 2017 -0.8144 0.2308  -3.53 0.0004  
 quarterYear=2 2008  0.1082 0.2515   0.43 0.6670  
 quarterYear=2 2009 -0.0525 0.2673  -0.20 0.8444  
 quarterYear=2 2010  1.8369 0.2186   8.40 <0.0001 
 quarterYear=2 2011  1.8234 0.2207   8.26 <0.0001 
 quarterYear=2 2012  0.8353 0.2305   3.62 0.0003  
 quarterYear=2 2013 -0.3520 0.2532  -1.39 0.1645  
 quarterYear=2 2014 -0.1610 0.2242  -0.72 0.4726  
 quarterYear=2 2015 -0.6490 0.2304  -2.82 0.0048  
 quarterYear=2 2016 -0.5415 0.2258  -2.40 0.0165  
 quarterYear=2 2017 -1.0205 0.2395  -4.26 <0.0001 
 quarterYear=3 2008  0.0669 0.2479   0.27 0.7873  
 quarterYear=3 2009 -0.2095 0.2756  -0.76 0.4471  
 quarterYear=3 2010  1.6706 0.2198   7.60 <0.0001 
 quarterYear=3 2011  1.7254 0.2180   7.91 <0.0001 
 quarterYear=3 2012  0.6138 0.2380   2.58 0.0099  
 quarterYear=3 2013 -0.1977 0.2432  -0.81 0.4164  
 quarterYear=3 2014 -0.2383 0.2251  -1.06 0.2898  
 quarterYear=3 2015 -0.5890 0.2283  -2.58 0.0099  
 quarterYear=3 2016 -1.1334 0.2453  -4.62 <0.0001 
 quarterYear=3 2017 -0.7910 0.2309  -3.43 0.0006  
 quarterYear=4 2008  0.2528 0.2338   1.08 0.2796  
 quarterYear=4 2009 -0.1349 0.2744  -0.49 0.6229  
 quarterYear=4 2010  1.7066 0.2158   7.91 <0.0001 
 quarterYear=4 2011  1.7735 0.2223   7.98 <0.0001 
 quarterYear=4 2012  0.3225 0.2504   1.29 0.1977  
 quarterYear=4 2013  0.1738 0.2196   0.79 0.4288  
 quarterYear=4 2014 -0.4699 0.2306  -2.04 0.0416  
 quarterYear=4 2015 -0.4956 0.2252  -2.20 0.0277  
 quarterYear=4 2016 -0.8298 0.2335  -3.55 0.0004  
 quarterYear=4 2017 -0.7182 0.2363  -3.04 0.0024

如何绘制每季度数据中零或一的预测百分比和实现百分比?

1 个答案:

答案 0 :(得分:0)

polr包中的

MASS是相同的比例赔率模型,并且为默认的S3类定义了更好的predict方法。如果指定predict(<mypolrobj>, type='probs'),您将获得响应级别的特定概率。