## Code

```
<- vglm(ordered(y) ~ yprev + lsp(day, 2) + age + sofa + tx,
f cumulative(reverse=TRUE, parallel=FALSE ~ lsp(day, 2)), data=d)
summary(f)
```

```
Call:
vglm(formula = ordered(y) ~ yprev + lsp(day, 2) + age + sofa +
tx, family = cumulative(reverse = TRUE, parallel = FALSE ~
lsp(day, 2)), data = d)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept):1 -5.02973 0.62819 -8.007 1.18e-15 ***
(Intercept):2 -13.19283 0.57656 -22.882 < 2e-16 ***
(Intercept):3 -19.57982 0.93523 -20.936 < 2e-16 ***
yprevIn Hospital/Facility 8.77312 0.26552 33.042 < 2e-16 ***
yprevVent/ARDS 15.13834 0.32138 47.104 < 2e-16 ***
lsp(day, 2)day:1 -1.43145 0.28423 -5.036 4.75e-07 ***
lsp(day, 2)day:2 -0.70738 0.25654 -2.757 0.00583 **
lsp(day, 2)day:3 0.13745 0.46781 0.294 0.76890
lsp(day, 2)day':1 1.48443 0.28596 5.191 2.09e-07 ***
lsp(day, 2)day':2 0.74601 0.26061 2.863 0.00420 **
lsp(day, 2)day':3 -0.11969 0.47501 -0.252 0.80105
age 0.01131 0.00274 4.126 3.68e-05 ***
sofa 0.06408 0.01233 5.199 2.01e-07 ***
tx -0.11141 0.08302 -1.342 0.17963
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Names of linear predictors: logitlink(P[Y>=2]), logitlink(P[Y>=3]),
logitlink(P[Y>=4])
Residual deviance: 4509.04 on 38962 degrees of freedom
Log-likelihood: -2254.52 on 38962 degrees of freedom
Number of Fisher scoring iterations: 11
Warning: Hauck-Donner effect detected in the following estimate(s):
'(Intercept):3'
Exponentiated coefficients:
yprevIn Hospital/Facility yprevVent/ARDS lsp(day, 2)day:1
6.458278e+03 3.754021e+06 2.389609e-01
lsp(day, 2)day:2 lsp(day, 2)day:3 lsp(day, 2)day':1
4.929322e-01 1.147340e+00 4.412427e+00
lsp(day, 2)day':2 lsp(day, 2)day':3 age
2.108581e+00 8.871914e-01 1.011371e+00
sofa tx
1.066182e+00 8.945744e-01
```

## Code

```
# Note: vglm will handle rcs() but not in getting predictions since
# it doesn't know where to find the computed knot locations
# Linear splines have knots explicitly stated at all times
<- vglm(ordered(y) ~ yprev + lsp(day, c(2, 4, 8, 15)) +
g lsp(age, c(35, 60, 75)) + lsp(sofa, c(2, 6, 10)) + tx,
cumulative(reverse=TRUE, parallel=FALSE ~ lsp(day, c(2, 4, 8, 15))),
data=d)
summary(g)
```

```
Call:
vglm(formula = ordered(y) ~ yprev + lsp(day, c(2, 4, 8, 15)) +
lsp(age, c(35, 60, 75)) + lsp(sofa, c(2, 6, 10)) + tx, family = cumulative(reverse = TRUE,
parallel = FALSE ~ lsp(day, c(2, 4, 8, 15))), data = d)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept):1 -4.540695 0.879423 -5.163 2.43e-07 ***
(Intercept):2 -12.871450 0.848677 -15.166 < 2e-16 ***
(Intercept):3 -18.852185 1.175403 -16.039 < 2e-16 ***
yprevIn Hospital/Facility 8.768798 0.268317 32.681 < 2e-16 ***
yprevVent/ARDS 15.119643 0.324509 46.592 < 2e-16 ***
lsp(day, c(2, 4, 8, 15))day:1 -1.553745 0.305250 -5.090 3.58e-07 ***
lsp(day, c(2, 4, 8, 15))day:2 -0.645513 0.300258 -2.150 0.0316 *
lsp(day, c(2, 4, 8, 15))day:3 -0.218295 0.600971 -0.363 0.7164
lsp(day, c(2, 4, 8, 15))day':1 1.722567 0.353631 4.871 1.11e-06 ***
lsp(day, c(2, 4, 8, 15))day':2 0.675690 0.395116 1.710 0.0872 .
lsp(day, c(2, 4, 8, 15))day':3 0.587743 0.810589 0.725 0.4684
lsp(day, c(2, 4, 8, 15))day'':1 -0.142458 0.140202 -1.016 0.3096
lsp(day, c(2, 4, 8, 15))day'':2 -0.011895 0.206499 -0.058 0.9541
lsp(day, c(2, 4, 8, 15))day'':3 -0.434170 0.384070 -1.130 0.2583
lsp(day, c(2, 4, 8, 15))day''':1 0.024947 0.076111 0.328 0.7431
lsp(day, c(2, 4, 8, 15))day''':2 -0.020957 0.121096 -0.173 0.8626
lsp(day, c(2, 4, 8, 15))day''':3 -0.029000 0.227663 -0.127 0.8986
lsp(day, c(2, 4, 8, 15))day'''':1 0.001783 0.051991 0.034 0.9726
lsp(day, c(2, 4, 8, 15))day'''':2 0.092686 0.080667 1.149 0.2506
lsp(day, c(2, 4, 8, 15))day'''':3 0.211000 0.168561 1.252 0.2107
lsp(age, c(35, 60, 75))age -0.003840 0.018880 -0.203 0.8388
lsp(age, c(35, 60, 75))age' 0.019171 0.023131 0.829 0.4072
lsp(age, c(35, 60, 75))age'' -0.015406 0.015790 -0.976 0.3292
lsp(age, c(35, 60, 75))age''' 0.035960 0.026210 1.372 0.1701
lsp(sofa, c(2, 6, 10))sofa 0.170889 0.094643 1.806 0.0710 .
lsp(sofa, c(2, 6, 10))sofa' -0.136896 0.120631 -1.135 0.2564
lsp(sofa, c(2, 6, 10))sofa'' 0.018298 0.067847 0.270 0.7874
lsp(sofa, c(2, 6, 10))sofa''' 0.074134 0.086665 0.855 0.3923
tx -0.122940 0.083812 -1.467 0.1424
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Names of linear predictors: logitlink(P[Y>=2]), logitlink(P[Y>=3]),
logitlink(P[Y>=4])
Residual deviance: 4497.307 on 38947 degrees of freedom
Log-likelihood: -2248.653 on 38947 degrees of freedom
Number of Fisher scoring iterations: 11
Warning: Hauck-Donner effect detected in the following estimate(s):
'(Intercept):3'
Exponentiated coefficients:
yprevIn Hospital/Facility yprevVent/ARDS
6.430436e+03 3.684490e+06
lsp(day, c(2, 4, 8, 15))day:1 lsp(day, c(2, 4, 8, 15))day:2
2.114547e-01 5.243932e-01
lsp(day, c(2, 4, 8, 15))day:3 lsp(day, c(2, 4, 8, 15))day':1
8.038880e-01 5.598882e+00
lsp(day, c(2, 4, 8, 15))day':2 lsp(day, c(2, 4, 8, 15))day':3
1.965389e+00 1.799922e+00
lsp(day, c(2, 4, 8, 15))day'':1 lsp(day, c(2, 4, 8, 15))day'':2
8.672238e-01 9.881755e-01
lsp(day, c(2, 4, 8, 15))day'':3 lsp(day, c(2, 4, 8, 15))day''':1
6.478024e-01 1.025260e+00
lsp(day, c(2, 4, 8, 15))day''':2 lsp(day, c(2, 4, 8, 15))day''':3
9.792613e-01 9.714168e-01
lsp(day, c(2, 4, 8, 15))day'''':1 lsp(day, c(2, 4, 8, 15))day'''':2
1.001785e+00 1.097117e+00
lsp(day, c(2, 4, 8, 15))day'''':3 lsp(age, c(35, 60, 75))age
1.234913e+00 9.961678e-01
lsp(age, c(35, 60, 75))age' lsp(age, c(35, 60, 75))age''
1.019356e+00 9.847118e-01
lsp(age, c(35, 60, 75))age''' lsp(sofa, c(2, 6, 10))sofa
1.036615e+00 1.186359e+00
lsp(sofa, c(2, 6, 10))sofa' lsp(sofa, c(2, 6, 10))sofa''
8.720611e-01 1.018467e+00
lsp(sofa, c(2, 6, 10))sofa''' tx
1.076951e+00 8.843170e-01
```

## Code

`lrtest(g, f)`

```
Likelihood ratio test
Model 1: ordered(y) ~ yprev + lsp(day, c(2, 4, 8, 15)) + lsp(age, c(35,
60, 75)) + lsp(sofa, c(2, 6, 10)) + tx
Model 2: ordered(y) ~ yprev + lsp(day, 2) + age + sofa + tx
#Df LogLik Df Chisq Pr(>Chisq)
1 38947 -2248.7
2 38962 -2254.5 15 11.733 0.6991
```

## Code

`AIC(f); AIC(g)`

`[1] 4537.04`

`[1] 4555.307`