【问题标题】:R - lrm (logistic regression - rms package) - plot quarterly predicted and realised valuesR - lrm(逻辑回归 - rms 包) - 绘制季度预测值和实现值
【发布时间】:2020-02-13 02:57:15
【问题描述】:

我正在使用 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

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

【问题讨论】:

  • 这个问题表明对优势和优势比的定义缺乏了解。这些都不是百分比。此外,还不清楚需要什么。需要什么样的表格,需要什么样的预测?这是作业吗?如果是这样,请更全面地描述数据并展示更多您的工作,以便人们可以看到您卡在哪里。
  • 我想每季度绘制从值 0“移动”到值 1 的变量百分比。我想绘制已实现的结果与模型预测的结果。
  • 输出建议年度数据。需要更好地了解数据中的内容以及为什么只看到年度系数。
  • 数据为季度。您在输出中看到的“1 2010”表示该数据点对应于 2010 年第一季度。
  • 那么其他四分之一的系数在哪里?

标签: r logistic-regression


【解决方案1】:

MASS 包中的polr 是相同的比例赔率模型,并且对默认 S3 类具有更好定义的 predict 方法。如果指定predict(&lt;mypolrobj&gt;, type='probs'),您将获得响应级别的特定概率。

【讨论】:

    猜你喜欢
    • 2021-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-22
    • 2017-01-19
    • 2021-04-16
    相关资源
    最近更新 更多