# RMS Ordinal Logistic Regression

**URL:** <https://discourse.datamethods.org/t/rms-ordinal-logistic-regression/4815>\
**Category:** models\
**Tags:** ordinal\
**Created:** [September 17, 2021, 12:47am UTC](https://discourse.datamethods.org/t/rms-ordinal-logistic-regression/4815 "2021-09-17T00:47:28Z")\
**Posts on this page:** 7\
**Page:** 4

<div class="post-metadata">

**Author:** ![f2harrell](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/f2harrell/32/165_2.png) [@f2harrell](https://discourse.datamethods.org/u/f2harrell)\
**Post date:** [May 20, 2025, 11:11am UTC](https://discourse.datamethods.org/t/rms-ordinal-logistic-regression/4815/62 "2025-05-20T11:11:54Z")

</div>

No problem. I think it’s almost impossible to interpret a predicted probability of \geq 1 exacerbation that is masked by death, so the ordinal model would estimate the probability of \geq ex. or death.

---

<div class="post-metadata">

**Author:** ![nicksun](https://discourse.datamethods.org/letter_avatar_proxy/v4/letter/n/278dde/32.png) [@nicksun](https://discourse.datamethods.org/u/nicksun)\
**Post date:** [May 21, 2025, 10:15pm UTC](https://discourse.datamethods.org/t/rms-ordinal-logistic-regression/4815/63 "2025-05-21T22:15:32Z")

</div>

Hi Dr. Harrell, following up after the RMS 2025 course. How concerned should we be about phantom degrees of freedom when changing the model after fitting to remove ordinal, PO assumptions, etc.? One of the examples from this chapter compared a PO model to a multinomial model, which dramatically increased the df from 12 to 30. If hypothetically the multinomial model was a significantly better fit to the data (or if we moved in the opposite direction from using a multinomial to PO model), shouldn’t this also drastically impact SEs?

---

<div class="post-metadata">

**Author:** ![f2harrell](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/f2harrell/32/165_2.png) [@f2harrell](https://discourse.datamethods.org/u/f2harrell)\
**Post date:** [May 22, 2025, 6:26pm UTC](https://discourse.datamethods.org/t/rms-ordinal-logistic-regression/4815/64 "2025-05-22T18:26:35Z")

</div>

When you move from a simpler model to a more complex model where complexity is captured by it having more parameters, the standard errors will be automatically enlarged and you don’t have to worry. The process is self-penalizing.

🆕 For a model with a residual variance such as the linear model, moving to a more complex model will properly penalize everything but you can also get lucky and have the residual variance decrease enough (R^2 increase) so that confidence intervals actually get smaller for the more complex model.

---

<div class="post-metadata">

**Author:** ![FurlanLeo](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/furlanleo/32/3812_2.png) [@FurlanLeo](https://discourse.datamethods.org/u/FurlanLeo)\
**Post date:** [May 24, 2025, 2:28pm UTC](https://discourse.datamethods.org/t/rms-ordinal-logistic-regression/4815/65 "2025-05-24T14:28:46Z")

</div>

Does anyone know the reason for this error? Maybe something to do with model convergence? How can I increase the number of iterations in a `lrm()` model?

> set.seed(1234)  
> boot ← bootstraps(data, times = 500)
> 
> fit ← function(split) {  
> d ← analysis(split)  
> d$week\_4 ← factor(d$week\_4, ordered = T)  
> dd ← datadist(d)  
> options(datadist = ‘dd’)  
> lrm(week\_4 ~ rcs(week\_1, 3)\*AIS, data = d)  
> }
> 
> boot\_models ← map(boot$splits, fit)  
> Error in `map()`:  
> ℹ In index: 51.  
> Caused by error in `if (objfnew > objf + 1e-06) ...`:  
> ! valor ausente onde TRUE/FALSE necessário  
> Run `rlang::last_trace()` to see where the error occurred.

---

<div class="post-metadata">

**Author:** ![f2harrell](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/f2harrell/32/165_2.png) [@f2harrell](https://discourse.datamethods.org/u/f2harrell)\
**Post date:** [May 24, 2025, 3:06pm UTC](https://discourse.datamethods.org/t/rms-ordinal-logistic-regression/4815/66 "2025-05-24T15:06:57Z")

</div>

Don’t put `datadist` and `options` inside a look. Use `bootcov` to get efficient `lrm` refitting using `lrm.fit`. Type `?lrm.fit` to see how to use options `trace, maxit, …`. Do unit testing to debug, not looping. On that point, you can use this contruct to find out which iteration causes a failure, and next time if you are at that iteration execute `browser()`:

```auto
it <- 0
… loop …
it <<- it + 1. # <<- to update it outside look, in..Globalenv
cat(‘it=‘, it, ‘\n’)

```

---

<div class="post-metadata">

**Author:** ![FurlanLeo](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/furlanleo/32/3812_2.png) [@FurlanLeo](https://discourse.datamethods.org/u/FurlanLeo)\
**Post date:** [May 24, 2025, 7:18pm UTC](https://discourse.datamethods.org/t/rms-ordinal-logistic-regression/4815/67 "2025-05-24T19:18:46Z")

</div>

Not even `bootcov()` is working:

> m ← lrm(week\_4 ~ rcs(week\_1, 3)\*AIS, data = data, x = T, y = T)  
> b ← bootcov(m, B = 500, group = data$week\_4, maxit = 1e6)  
> Warning:  
> In bootcov(m, B = 500, group = data$week\_4, maxit = 1e+06) :  
> fit failure in 2 resamples. Might try increasing maxit

---

<div class="post-metadata">

**Author:** ![f2harrell](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/f2harrell/32/165_2.png) [@f2harrell](https://discourse.datamethods.org/u/f2harrell)\
**Post date:** [May 24, 2025, 10:49pm UTC](https://discourse.datamethods.org/t/rms-ordinal-logistic-regression/4815/68 "2025-05-24T22:49:39Z")

</div>

Don’t specify `maxit > 200`, and use `trace=1` to see if the non-convergence can be explained. But you already have 498 useful bootstrap repetitions so you don’t need to worry much.

[Previous page](https://discourse.datamethods.org/t/rms-ordinal-logistic-regression/4815.md?page=3)
