15  Regression Models for Continuous \(Y\) and Case Study in Ordinal Regression

This chapter concerns univariate continuous \(Y\). There are many multivariable models for predicting such response variables.

A

Semiparametric models that treat \(Y\) as ordinal but not interval-scaled have many advantages including robustness and freedom of distributional assumptions for \(Y\) conditional on any given set of predictors. Advantages are demonstrated in a case study of a cumulative probability ordinal model. Some of the results are compared to quantile regression and OLS. Many of the methods used in the case study also apply to ordinary linear models.

B

15.1 Dataset and Descriptive Statistics

  • Diabetes Mellitus (DM) type II (adult onset diabetes) is strongly associated with obesity
  • Primary laboratory test for diabetes: glycosylated hemoglobin (\(\text{HbA}_{1c}\)), also called glycated hemoglobin, glycohemoglobin, or hemoglobin \(A_{1c}\).
  • \(\text{HbA}_{1c}\) reflects average blood glucose for the preceding 60 to 90 days
  • \(\text{HbA}_{1c}\) \(> 7.0\) usually taken as a positive diagnosis of diabetes
  • Goal of analysis:
    • better understand effects of body size measurements on risk of DM
    • enhance screening for DM
  • Best way to develop a model for DM screening is not to fit binary logistic model with \(\text{HbA}_{1c}\) > 7 as the response variable
    • All cutpoints are arbitrary; no justification for any putative cut
    • \(\text{HbA}_{1c}\) 2=6.9, 7.1=10
    • Larger standard errors of \(\hat{\beta}\), lower power, wider confidence bands
    • Better: predict continuous \(\text{HbA}_{1c}\) using continuous response model, then convert to probability \(\text{HbA}_{1c}\) exceeds any cutoff or estimate 0.9 quantile of \(\text{HbA}_{1c}\)
  • Data: U.S. National Health and Nutrition Examination Survey (NHANES) from National Center for Health Statistics/CDC: www.cdc.gov/nchs/nhanes.htm (Centers for Disease Control and Prevention CDC. National Center for Health Statistics NCHS, 2010)
  • age \(\geq 80\) coded as 80 by CDC
  • Subset with age \(\geq 21\), neither diagnosed nor treated for DM
CDE
Code
require(rms)
options(prType='html')   # for print, summary, anova
getHdata(nhgh)
w <- subset(nhgh, age >= 21 & dx==0 & tx==0, select=-c(dx,tx))
html(describe(w))
w Descriptives
w

18 Variables   4629 Observations

seqn: Respondent sequence number
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
462904629156902350152136526335428456930594956107961641
lowest : 51624 51629 51630 51645 51647 , highest: 62152 62153 62155 62157 62158
sex
nmissingdistinct
462902
 Value        male female
 Frequency    2259   2370
 Proportion  0.488  0.512
 

age: Age years
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
46290703148.5719.8523.3326.0833.9246.8361.8374.8380.00
lowest : 21.00000 21.08333 21.16667 21.25000 21.33333 , highest: 79.66667 79.75000 79.83333 79.91667 80.00000
re: Race/Ethnicity
image
nmissingdistinct
462905
lowest :Mexican American Other Hispanic Non-Hispanic White Non-Hispanic Black Other Race Including Multi-Racial
highest:Mexican American Other Hispanic Non-Hispanic White Non-Hispanic Black Other Race Including Multi-Racial
Mexican American (832, 0.180), Other Hispanic (474, 0.102), Non-Hispanic White (2318, 0.501), Non-Hispanic Black (756, 0.163), Other Race Including Multi-Racial (249, 0.054)
income: Family Income
image
nmissingdistinct
438924014
lowest :[0,5000) [5000,10000) [10000,15000) [15000,20000) [20000,25000)
highest:[65000,75000) > 20000 < 20000 [75000,100000)>= 100000
[0,5000) (162, 0.037), [5000,10000) (216, 0.049), [10000,15000) (371, 0.085), [15000,20000) (300, 0.068), [20000,25000) (374, 0.085), [25000,35000) (535, 0.122), [35000,45000) (421, 0.096), [45000,55000) (346, 0.079), [55000,65000) (257, 0.059), [65000,75000) (188, 0.043), > 20000 (149, 0.034), < 20000 (52, 0.012), [75000,100000) (399, 0.091), >= 100000 (619, 0.141)
wt: Weight kg
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
46290890180.4922.34 52.44 57.18 66.10 77.70 91.40106.52118.00
lowest : 33.2 36.1 37.9 38.5 38.7 , highest: 184.3 186.9 195.3 196.6 203.0
ht: Standing Height cm
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
462905121167.511.71151.1154.4160.1167.2175.0181.0184.8
lowest : 123.3 135.4 137.5 139.4 139.8 , highest: 199.2 199.3 199.6 201.7 202.7
bmi: Body Mass Index kg/m2
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
462901994128.596.96520.0221.3524.1227.6031.8836.7540.68
lowest : 13.18 14.59 15.02 15.40 15.49 , highest: 61.20 62.81 65.62 71.30 84.87
leg: Upper Leg Length cm
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
4474155216138.394.30132.033.536.038.441.043.344.6
lowest : 20.4 24.9 25.0 25.1 26.4 , highest: 49.0 49.5 49.8 50.0 50.3
arml: Upper Arm Length cm
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
4502127156137.013.11632.633.535.037.039.040.641.7
lowest : 24.8 27.0 27.5 29.2 29.5 , highest: 45.2 45.5 45.6 46.0 47.0
armc: Arm Circumference cm
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
4499130290132.875.47525.426.929.532.535.839.141.4
lowest : 17.9 19.0 19.3 19.5 19.9 , highest: 54.2 54.9 55.3 56.0 61.0
waist: Waist Circumference cm
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
4465164716197.6217.18 74.8 78.6 86.9 96.3107.0117.8125.0
lowest : 59.7 60.0 61.5 62.0 62.4 , highest: 160.0 160.6 162.2 162.7 168.7
tri: Triceps Skinfold mm
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
4295334342118.949.463 7.2 8.812.018.025.231.033.8
lowest : 2.6 3.1 3.2 3.3 3.4 , highest: 39.6 39.8 40.0 40.2 40.6
sub: Subscapular Skinfold mm
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
3974655329120.89.124 8.6010.3014.4020.3026.5832.0035.00
lowest : 3.8 4.2 4.6 4.8 4.9 , highest: 40.0 40.1 40.2 40.3 40.4
gh: Glycohemoglobin %
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
46290630.9945.5330.54114.85.05.25.55.86.06.3
lowest : 4.0 4.1 4.2 4.3 4.4 , highest: 11.9 12.0 12.1 12.3 14.5
albumin: Albumin g/dL
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
457653260.994.2610.35283.73.94.14.34.54.74.8
lowest : 2.6 2.7 3.0 3.1 3.2 , highest: 4.9 5.0 5.1 5.2 5.3
bun: Blood urea nitrogen mg/dL
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
457653500.99513.035.309 7 81012151922
lowest : 1 2 3 4 5 , highest: 49 53 55 56 63
SCr: Creatinine mg/dL
image
nmissingdistinctInfoMeanGmd.05.10.25.50.75.90.95
45765316710.88870.26970.580.620.720.840.991.141.25
lowest : 0.34 0.38 0.39 0.40 0.41 , highest: 5.98 6.34 9.13 10.98 15.66
Code
dd <- datadist(w); options(datadist='dd')

15.2 The Linear Model

The most popular multivariable model for analyzing a univariate continuous \(Y\) is the the linear model \[ E(Y | X) = X \beta, \] where \(\beta\) is estimated using ordinary least squares, that is, by solving for \(\hat{\beta}\) to minimize \(\sum (Y_{i} - X \hat{\beta})^{2}\).

  • To compute \(P\)-values and confidence limits using parametric methods (and for least squares estimates to coincide with maximum likelihood estimates) we would have to assume that \(Y | X\) is normal with mean \(X \beta\) and constant variance \(\sigma^2\) 1
F
  • 1 The latter assumption may be dispensed with if we use a robust Huber-White or bootstrap covariance matrix estimate. Normality may sometimes be dispensed with by using bootstrap confidence intervals, but this would not fix inefficiency problems with OLS when residuals are non-normal.

  • 15.2.1 Checking Assumptions of OLS and Other Models

    • First see if gh would make a Gaussian residuals model fit
    • Use ordinary regression on 4 key variables to collapse into one variable (predicted mean from OLS model)
    • Stratify predicted mean into 6 quantile groups
    • Apply the normal inverse ECDF of gh to these strata and check for normality and constant \(\sigma^2\)
    • ECDF is for \(\Pr[Y \leq y | X]\) but for ordinal modeling we want to state models in terms of \(\Pr[Y \ge y | X]\) so take 1 - ECDF before inverse transforming
    G
    Code
    f <- ols(gh ~ rcs(age,5) + sex + re + rcs(bmi, 3), data=w)
    pgh <- fitted(f)
    p <- function(fun, row, col) {
      f <- substitute(fun); g <- function(F) eval(f)
      z <- Ecdf(~ gh, groups=cut2(pgh, g=6),
                fun=function(F) g(1 - F),
                ylab=as.expression(f), xlim=c(4.5, 7.75), data=w,
                label.curve=FALSE)
      print(z, split=c(col, row, 2, 2), more=row < 2 | col < 2)
    }
    p(log(F/(1-F)),   1, 1)
    p(qnorm(F),       1, 2)
    p(-log(-log(F)),  2, 1)
    p(log(-log(1-F)), 2, 2)
    # Get slopes of pgh for some cutoffs of Y
    # Use glm complementary log-log link on Prob(Y < cutoff) to
    # get log-log link on Prob(Y >= cutoff)
    r <- NULL
    for(link in c('logit','probit','cloglog'))
      for(k in c(5, 5.5, 6)) {
        co <- coef(glm(gh < k ~ pgh, data=w, family=binomial(link)))
        r <- rbind(r, data.frame(link=link, cutoff=k,
                                 slope=round(co[2],2)))
    }
    print(r, row.names=FALSE)
        link cutoff slope
       logit    5.0 -3.39
       logit    5.5 -4.33
       logit    6.0 -5.62
      probit    5.0 -1.69
      probit    5.5 -2.61
      probit    6.0 -3.07
     cloglog    5.0 -3.18
     cloglog    5.5 -2.97
     cloglog    6.0 -2.51

    Figure 15.1: Examination of normality and constant variance assumption, and assumptions for various ordinal models

    • Upper right curves are not linear, implying that a normal conditional distribution cannot work for gh2
    • There is non-parallelism for the logit model
    • Other graphs will be used to guide selection of an ordinal model below
    H
  • 2 They are not parallel either.

  • 15.3 Quantile Regression

    • Ruled out OLS and semiparametric proportional odds model
    • Quantile regression (Roger Koenker, 2005; R. Koenker & Bassett, 1978) is a different approach to modeling \(Y\)
    • No distributional assumptions other than continuity of \(Y\)
    • All the usual right hand side assumptions
    • When there is a single predictor that is categorical, quantile regression coincides with ordinary sample quantiles stratified by that predictor
    • Is transformation invariant - pre-transforming \(Y\) not important
    I

    Let \(\rho_{\tau}(y) = y(\tau - [y < 0])\). The \(\tau^{\mathrm th}\) sample quantile is the minimizer \(q\) of \(\sum_{i-1}^{n}\rho_{\tau}(y_{i}-q)\). For a conditional \(\tau^{\mathrm th}\) quantile of \(Y | X\) the corresponding quantile regression estimator \(\hat{\beta}_{\tau}\) minimizes \(\sum_{i=1}^{n}\rho_{\tau}(Y_{i}-X\beta)\). Quantile regression is not as efficient at estimating quantiles as is ordinary least squares at estimating the mean, if the latter’s assumptions hold. Koenker’s quantreg package in R (Roger Koenker, 2009) implements quantile regression, and the rms package’s Rq function provides a front-end that gives rise to various graphics and inference tools. If we model the median gh as a function of covariates, only the \(X\beta\) structure need be correct. Other quantiles (e.g., \(90^\text{th}\) percentile) can be directly modeled but standard errors will be much larger as it is more difficult to precisely estimate outer quantiles.

    J

    15.4 Ordinal Regression Models for Continuous \(Y\)

    • Advantages of semiparametric models (e.g., quantile regression and cumulative probability ordinal models
    • For ordinal cumulative probability models, there is no distributional assumption for \(Y\) given a setting of \(X\)
    • Assume only a connection between distributions of \(Y\) for different \(X\)
    • Applying an increasing 1–1 transformation to \(Y\) results in no change to regression coefficient estimates3
    • Regression coefficient estimates are completely robust to extreme \(Y\) values4
    • Estimates of quantiles of \(Y\) are exactly transformation-preserving, e.g., estimate of median of \(\log Y\) is exactly the log of the estimate of median \(Y\)
    • Manuguerra & Heller (2010) developed an ordinal model for continuous \(Y\) which they incorrectly labeled semi-parametric and is actually a lower-dimensional flexible parametric model that instead of having intercepts has a spline function of \(y\).
    K
  • 3 For symmetric distributions applying a decreasing transformation will negate the coefficients. For asymmetric distributions (e.g., Gumbel), reversing the order of \(Y\) will do more than change signs.

  • 4 Only an estimate of mean \(Y\) from these \(\hat{\beta}\)s is non-robust.


  • For a general continuous distribution function \(F(y)\), an ordinal regression model based on cumulative probabilities may be stated as follows5. Let the ordered unique values of \(Y\) be denoted by \(y_{1}, y_{2}, \dots, y_{k}\) and let the intercepts associated with \(y_{1}, \dots, y_{k}\) be \(\alpha_{1}, \alpha_{2}, \dots, \alpha_{k}\), where \(\alpha_{1} = \infty\) because \(\Pr[Y \geq y_{1}] = 1\). Let \(\alpha_{y} = \alpha_{i}, i:y_{i}=y\). Then \[ \Pr[Y \geq y_{i} | X] = F(\alpha_{i} + X\beta) = F(\alpha_{y_{i}} + X\beta) \] For the OLS fully parametric case, the model may be restated

    L
  • 5 It is more traditional to state the model in terms of \(\Pr[Y \leq y | X]\) but we use \(\Pr[Y \geq y | X]\) so that higher predicted values are associated with higher \(Y\).

  • \[\begin{array}{c} \Pr[Y \geq y | X] = \Pr[\frac{Y-X\beta}{\sigma} \geq \frac{y-X\beta}{\sigma}]\\ = 1-\Phi(\frac{y-X\beta}{\sigma}) = \Phi(\frac{-y}{\sigma}+\frac{X\beta}{\sigma}) \end{array}\]

    so that to within an additive constant ^[\(\hat{\alpha_{y}}\) are unchanged if a constant is added to all \(y\).} \(\alpha_{y} = \frac{-y}{\sigma}\) (intercepts \(\alpha\) are linear in \(y\) whereas they are arbitrarily descending in the ordinal model), and \(\sigma\) is absorbed in \(\beta\) to put the OLS model into the new notation. The general ordinal regression model assumes that for fixed \(X_{1}, X_{2}\),

    \[\begin{array}{c} F^{-1}(\Pr[Y \geq y | X_{2}]) - F^{-1}(\Pr[Y \geq y | X_{1}])\\ = (X_{2} - X_{1})\beta \end{array}\]

    independent of the \(\alpha\)s (parallelism assumption). If \(F = [1 + \exp(-y)]^{-1}\), this is the proportional odds assumption.

    Common choices of \(F\), implemented in the rms orm function, are shown in Table Table 15.1.

    M
    Table 15.1: Distribution families used in ordinal cumulative probability models. \(\Phi\) denotes the Gaussian cumulative distribution function. For the Connection column, \(P_{1}=\Pr[Y \geq y | X_{1}], P_{2}=\Pr[Y \geq y | X_{2}], \Delta=(X_{2}-X_{1})\beta\). The connection specifies the only distributional assumption if the model is fitted semiparametrically, i.e, contains an intercept for every unique \(Y\) value less one. For parametric models, \(P_{1}\) must be specified absolutely instead of just requiring a relationship between \(P_{1}\) and \(P_{2}\). For example, the traditional Gaussian parametric model specifies that \(\Pr[Y \geq y | X] = 1 - \Phi(\frac{y - X\beta}{\sigma}) = \Phi(\frac{-y + X\beta}{\sigma})\).
    Distribution \(F\) Inverse (Link Function) Link Name Connection
    Logistic \([1 + \exp(-y)]^{-1}\) \(\log(\frac{y}{1-y})\) logit \(\frac{P_{2}}{1-P_{2}} = \frac{P_{1}}{1-P_{1}} \exp(\Delta)\)
    Gaussian \(\Phi(y)\) \(\Phi^{-1}(y)\) probit \(P_{2}=\Phi(\Phi^{-1}(P_{1})+\Delta)\)
    Gumbel maximum value \(\exp(-\exp(-y))\) \(\log(-\log(y))\) \(\log-\log\) \(P_{2}=P_{1}^{\exp(\Delta)}\)
    Gumbel minimum value \(1 - \exp(-\exp(y))\) \(\log(-\log(1 - y))\) complementary \(\log-\log\) \(1-P_{2}=(1-P_{1})^{\exp(\Delta)}\)
    Cauchy \(\frac{1}{\pi}\tan^{-1}(y) + \frac{1}{2}\) \(\tan[\pi(y - \frac{1}{2})]\) cauchit

    The Gumbel maximum value distribution is also called the extreme value type I distribution. This distribution (\(\log-\log\) link) also represents a continuous time proportional hazards model. The hazard ratio when \(X\) changes from \(X_{1}\) to \(X_{2}\) is \(\exp(-(X_{2} - X_{1}) \beta)\). The mean of \(Y | X\) is easily estimated by computing \[ \sum_{i=1}^{k} y_{i} \hat{\Pr}[Y = y_{i} | X] \] and the \(q^\text{th}\) quantile of \(Y | X\) is \(y\) such that
    \(F^{-1}(1 - q) - X\hat{\beta} = \hat{\alpha}_{y}\).6 The orm function in the rms package takes advantage of the information matrix being of a sparse tri-band diagonal form for the intercept parameters. This makes the computations efficient even for hundreds of intercepts (i.e., unique values of \(Y\)). orm is made to handle continuous \(Y\). Ordinal regression has nice properties in addition to those listed above, allowing for

    N
  • 6 The intercepts have to be shifted to the left one position in solving this equation because the quantile is such that \(\Pr[Y \leq y] = q\) whereas the model is stated in terms of \(\Pr[Y \geq y]\).

    • estimation of quantiles as efficiently as quantile regression if the parallel slopes assumptions hold
    • efficient estimation of mean \(Y\)
    • direct estimation of \(\Pr[Y\geq y | X]\)
    • arbitrary clumping of values of \(Y\), while still estimating \(\beta\) and mean \(Y\) efficiently7
    • solutions for \(\hat{\beta}\) using ordinary Newton-Raphson or other popular optimization techniques
    • being based on a standard likelihood function, penalized estimation can be straightforward
    • Wald, score, and likelihood ratio \(\chi^2\) tests that are more powerful than tests from quantile regression
    O
  • 7 But it is not sensible to estimate quantiles of \(Y\) when there are heavy ties in \(Y\) in the area containing the quantile.

  • To summarize how assumptions of parametric models compare to assumptions of semiparametric models, consider the ordinary linear model or its special case the equal variance two-sample \(t\)-test, vs. the probit or logit (proportional odds) ordinal model or their special cases the Van der Waerden (normal-scores) two-sample test or the Wilcoxon test. All the assumptions of the linear model other than independence of residuals are captured in the following (written in traditional \(Y\leq y\) form):

    P
    \[\begin{array}{c} F(y|X) = \Pr[Y \leq y|X] = \Phi(\frac{y-X\beta}{\sigma})\\ \Phi^{-1}(F(y|X)) = \frac{y-X\beta}{\sigma} \end{array}\]
    Code
    spar(mfrow=c(1,2), left=2)
    pinv <- expression(paste(Phi^{-1},  '(F(y', '|', 'X))'))
    plot(0, 0, xlim=c(0, 1), ylim=c(-2, 2), type='n', axes=FALSE,
         xlab=expression(y), ylab='')
    mtext(pinv, side=2, line=1)
    axis(1, labels=FALSE, lwd.ticks=0)
    axis(2, labels=FALSE, lwd.ticks=0)
    abline(a=-1.5, b=1)
    abline(a=0, b=1)
    arrows(.5, -1.5+.5, .5, 0+.5, code=3, length=.1)
    text(.525, .5*(-1.5+.5+.5), expression(-Delta*X*beta/sigma), adj=0)
    g <- function(x) -2.2606955+11.125231*x-37.772783*x^2+56.776436*x^3-
      26.861103*x^4
    x <- seq(0, .9, length=150)
    pinv <- expression(atop(paste(Phi^{-1},  '(F(y', '|', 'X))'),
        paste(logit, '(F(y', '|', 'X))')))
    plot(0, 0, xlim=c(0, 1), ylim=c(-2, 2), type='n', axes=FALSE,
         xlab=expression(y), ylab='')
    mtext(pinv, side=2, line=1)
    axis(1, labels=FALSE, lwd.ticks=FALSE)
    axis(2, labels=FALSE, lwd.ticks=FALSE)
    lines(x, g(x))
    lines(x, g(x)+1.5)
    arrows(.5, g(.5), .5, g(.5)+1.5, code=3, length=.1)
    text(.525, .5*(g(.55) + g(.55)+1.5), expression(-Delta*X*beta), adj=0)

    Figure 15.2: Assumptions of the linear model (left panel) and semiparametric ordinal probit or logit (proportional odds) models (right panel). Ordinal models do not assume any shape for the distribution of \(Y\) for a given \(X\); they only assume parallelism.

    On the other hand, ordinal models assume the following: \[ \Pr[Y \leq y|X] = F(g(y)-X\beta), \] where \(g\) is unknown and may be discontinuous. From this point we revert back to \(Y\geq y\) notation so that \(Y\) increases as \(X\beta\) increases.

    Global Modeling Implications

    • Ordinal regression invariant to choice of transformation of \(Y\)
    • \(Y\) needs to be ordinal
    • Difference in two ordinal variables is not necessarily ordinal
    • \(\rightarrow\) Never analyze differences in regression
    • \(Y\)=final value, adjust for baseline values as covariates
    Q

    15.5 Ordinal Regression Applied to \(\text{HbA}_{1c}\)

    • In Figure 15.1, logit inverse curves are not parallel so proportional odds assumption does not hold
    • log-log link yields highest degree of parallelism and most constant regression coefficients across cutoffs of gh so use this link in an ordinal regression model (linearity of the curves is not required)
    R

    15.5.1 Checking Fit for Various Models Using Age

    S

    Another way to examine model fit is to flexibly fit the single most important predictor (age) using a variety of methods, and comparing predictions to sample quantiles and means based on overlapping subsets on age, each subset being subjects having age \(< 5\) years away from the point being predicted by the models. Here we predict the 0.5, 0.75, and 0.9 quantiles and the mean. For quantiles we can compare to quantile regression(discussed below) and for means we compare to OLS.

    Code
    require(data.table)
    estimands  <- .q(q2, q3, p90, mean)
    links      <- .q(logistic, probit, loglog, cloglog)
    estimators <- c(.q(empirical, ols, QR), links)
    ages       <- 25 : 75
    nage       <- length(ages)
    yhat       <- numeric(length(ages))
    fmt <- function(x) format(round(x, 3), nsmall=3)
    
    r   <- expand.grid(estimand=estimands, estimator=estimators, age=ages, 
                       y=NA_real_, stringsAsFactors=FALSE)
    setDT(r)
    # Discard irrelevant methods for estimands
    r   <- r[! (estimand == 'mean' & estimator == 'QR') &
             ! (estimand %in% .q(q2, q3, p90) & estimator == 'ols'), ]
    # Find all used combinations
    rc  <- r[age == 25]
    rc[, age := NULL]
    
    mod  <- gh ~ rcs(age,6)
    
    # Compute estimates for all relevant combinations of estimands & estimators
    
    for(eor in rc[, unique(estimator)]) {
      if(eor == 'empirical') {
        emp <- matrix(NA, nrow=nage, ncol=4,
                      dimnames=list(NULL, .q(mean, q2, q3, p90)))
        for(j in 1 : length(ages)) {
        s <- which(abs(w$age - ages[j]) < 5)
        y <- w$gh[s]
        a <- quantile(y, probs=c(0.5, 0.75, 0.90))
        emp[j, ] <- c(mean(y), a)
        }
      }
      else if(eor == 'ols')   fit <- ols(mod, data=w)
      else if(eor %in% links) fit <- orm(mod, data=w, family=eor)
      
      for(eand in rc[estimator == eor, unique(estimand)]) {
        qa <- switch(eand, q2=0.5, q3=0.75, p90=0.90)
        yhat <- if(eor == 'ols') Predict(fit, age=ages, conf.int=FALSE)$yhat
        else if(eor == 'empirical') emp[, eand] 
        else if(eor == 'QR') {
          fit <- Rq(mod, data=w, tau=qa)
          Predict(fit, age=ages, conf.int=FALSE)$yhat
          }
        else {
          fun <- switch(eand,
                        mean = Mean(fit),
                        Quantile(fit))
          fu <- if(eand == 'mean') fun
          else function(x) fun(qa, x) 
          Predict(fit, age=ages, fun=fu, conf.int=FALSE)$yhat
        }
       r[estimand == eand & estimator == eor, y := yhat]
      }
    }
    
    # Compute age-specific differences between estimates and empirical
    # estimates, then compute mean absolute differences across all ages
    
    dif <- r[estimator != 'empirical']
    
    for(eor in rc[, setdiff(unique(estimator), 'empirical')]) 
      for(eand in rc[estimator == eor, unique(estimand)])
        dif[estimator == eor         & estimand == eand]$y <-
          r[estimator == eor         & estimand == eand]$y -
          r[estimator == 'empirical' & estimand == eand]$y
    mad  <- dif[, .(ad = mean(abs(y))), by=.(estimand, estimator)] 
    mad2 <- mad[, .(value = paste(fmt(ad), collapse='\n'),
                    label = paste(estimator, collapse='\n'),
                    x     = if(estimand == 'p90') 60  else 25,
                    y     = if(estimand == 'p90') 5.5 else 6.2),
                by=.(estimand)]
    
    ggplot() + geom_line(aes(x=age, y=y, col=estimator),
                         data=r[estimator != 'empirical']) + 
      geom_point(aes(x=age, y=y, alpha=I(0.35)),
                 data=r[estimator == 'empirical']) +
      facet_wrap(~ estimand) +
      geom_text(aes(x=x,    y=y, label=label, hjust='left', size=I(3)), data=mad2) +
      geom_text(aes(x=x+10, y=y, label=value, hjust='left', size=I(3)), data=mad2) +
      guides(color=guide_legend(title='')) +
      theme(legend.position='bottom')

    Figure 15.3: Three estimated quantiles and estimated mean using 6 methods, compared against caliper-matched sample quantiles/means (circles). Numbers are mean absolute differences between predicted and sample quantities using overlapping intervals of age and caliper matching. QR:quantile regression.

    T

    It can be seen in Figure 15.3 that models dedicated to a specific task (quantile regression for quantiles and OLS for means) were best for those tasks. Although the log-log ordinal cumulative probability model did not estimate the median as accurately as some other methods, it does well for the 0.75 and 0.9 quantiles and is the best compromise overall because of its ability to also directly predict the mean as well as quantities such as \(\Pr[\text{HbA}_{1c} > 7 | X]\). For here on we focus on the log-log ordinal model. Going back to the bottom left of Figure 15.1, let’s look at quantile groups of predicted \(\text{HbA}_{1c}\) by OLS and plot predicted distributions of actual \(\text{HbA}_{1c}\) against empirical distributions.

    U
    Code
    w$pghg <- cut2(pgh, g=6)
    f  <- orm(gh ~ pghg, family=loglog, data=w)
    lp <- predict(f, newdata=data.frame(pghg=levels(w$pghg)))
    ep <- ExProb(f)  # Exceedance prob. functn. generator in rms
    z  <- ep(lp)
    j  <- order(w$pghg)  # puts in order of lp (levels of pghg)
    plot(z, xlim=c(4, 7.5), data=w[j,c('pghg', 'gh')]) 

    Figure 15.4: Observed (dashed lines, open circles) and predicted (solid lines, closed circles) exceedance probability distributions from a model using 6-tiles of OLS-predicted \(\text{HbA}_{1c}\). Key shows quantile group intervals of predicted mean \(\text{HbA}_{1c}\).

    Agreement between predicted and observed exceedance probability distributions is excellent in Figure 15.4. To return to the initial look at a linear model with assumed Gaussian residuals, fit a probit ordinal model and compare the estimated intercepts to the linear relationship with gh that is assumed by the normal distribution.

    V
    Code
    spar(bty='l')
    f <- orm(gh ~ rcs(age,6), family=probit, data=w)
    g <- ols(gh ~ rcs(age,6), data=w)
    s <- g$stats['Sigma']
    yu <- f$yunique[-1]
    r <- quantile(w$gh, c(.005, .995))
    alphas <- coef(f)[1:num.intercepts(f)]
    plot(-yu / s, alphas, type='l', xlim=rev(- r / s), 
         xlab=expression(-y/hat(sigma)), ylab=expression(alpha[y]))

    Figure 15.5: Estimated intercepts from probit model

    Figure 15.5 depicts a significant departure from that implied by Gaussian residuals.

    15.5.2 Examination of BMI

    Using the log-log model, we first check the adequacy of BMI as a summary of height and weight for estimating median gh.

    • Adjust for age (without assuming linearity) in every case
    • Look at ratio of coefficients of log height and log weight
    • Use AIC to judge whether BMI is an adequate summary of height and weight
    W
    Code
    f <- orm(gh ~ rcs(age,5) + log(ht) + log(wt),
             family=loglog, data=w)
    f

    -log-log Ordinal Regression Model

     orm(formula = gh ~ rcs(age, 5) + log(ht) + log(wt), data = w, 
         family = loglog)
     
    Model Likelihood
    Ratio Test
    Discrimination
    Indexes
    Rank Discrim.
    Indexes
    Obs 4629 LR χ2 1126.94 R2 0.217 ρ 0.486
    Distinct Y 63 d.f. 6 R26,4629 0.215
    Y0.5 5.5 Pr(>χ2) <0.0001 R26,4602.2 0.216
    max |∂log L/∂β| 1×10-6 Score χ2 1262.81 |Pr(Y ≥ median)-½| 0.153
    Pr(>χ2) <0.0001
    β S.E. Wald Z Pr(>|Z|)
    age   0.0398  0.0055 7.29 <0.0001
    age’  -0.0158  0.0275 -0.57 0.5657
    age’’  -0.0072  0.0866 -0.08 0.9333
    age’’’   0.0309  0.1135 0.27 0.7853
    ht  -3.0680  0.2789 -11.00 <0.0001
    wt   1.2748  0.0704 18.10 <0.0001
    Code
    aic <- NULL
    for(mod in list(gh ~ rcs(age,5) + rcs(log(bmi),5),
                    gh ~ rcs(age,5) + rcs(log(ht),5) + rcs(log(wt),5),
                    gh ~ rcs(age,5) + rcs(log(ht),4) * rcs(log(wt),4)))
      aic <- c(aic, AIC(orm(mod, family=loglog, data=w)))
    print(aic)
    [1] 25910.77 25910.17 25906.03

    The ratio of the coefficient of log height to the coefficient of log weight is -2.4, which is between what BMI uses and the more dimensionally reasonable weight / height\(^{3}\). By AIC, a spline interaction surface between height and weight does slightly better than BMI in predicting \(\text{HbA}_{1c}\), but a nonlinear function of BMI is barely worse. It will require other body size measures to displace BMI as a predictor. As an aside, compare this model fit to that from the Cox proportional hazards model. The Cox model uses a conditioning argument to obtain a partial likelihood free of the intercepts \(\alpha\) (and requires a second step to estimate these log discrete hazard components) whereas we are using a full marginal likelihood of the ranks of \(Y\) (Kalbfleisch & Prentice, 1973).

    X
    Code
    print(cph(Surv(gh) ~ rcs(age,5) + log(ht) + log(wt), data=w))
    Cox Proportional Hazards Model
     cph(formula = Surv(gh) ~ rcs(age, 5) + log(ht) + log(wt), data = w)
     
    Model Tests Discrimination
    Indexes
    Obs 4629 LR χ2 1120.20 R2 0.215
    Events 4629 d.f. 6 R26,4629 0.214
    Center 8.3792 Pr(>χ2) 0.0000 Dxy 0.359
    Score χ2 1258.07
    Pr(>χ2) 0.0000
    β S.E. Wald Z Pr(>|Z|)
    age  -0.0392  0.0054 -7.24 <0.0001
    age'   0.0148  0.0274 0.54 0.5888
    age''   0.0093  0.0862 0.11 0.9144
    age'''  -0.0321  0.1131 -0.28 0.7767
    ht   3.0477  0.2779 10.97 <0.0001
    wt  -1.2653  0.0701 -18.04 <0.0001

    Back up and look at all body size measures, and examine their redundancies.

    Y
    Code
    v <- varclus(~ wt + ht + bmi + leg + arml + armc + waist +
                 tri + sub + age + sex + re, data=w)
    plot(v)   
    # Omit wt so it won't be removed before bmi
    redun(~ ht + bmi + leg + arml + armc + waist + tri + sub,
          data=w, r2=.75)
    
    Redundancy Analysis
    
    redun(formula = ~ht + bmi + leg + arml + armc + waist + tri + 
        sub, data = w, r2 = 0.75)
    
    n: 3853     p: 8    nk: 3 
    
    Number of NAs:   776 
    Frequencies of Missing Values Due to Each Variable
       ht   bmi   leg  arml  armc waist   tri   sub 
        0     0   155   127   130   164   334   655 
    
    
    Transformation of target variables forced to be linear
    
    R-squared cutoff: 0.75  Type: ordinary 
    
    R^2 with which each variable can be predicted from all other variables:
    
       ht   bmi   leg  arml  armc waist   tri   sub 
    0.829 0.924 0.682 0.748 0.843 0.864 0.531 0.594 
    
    Rendundant variables:
    
    bmi ht
    
    Predicted from variables:
    
    leg arml armc waist tri sub 
    
      Variable Deleted   R^2 R^2 after later deletions
    1              bmi 0.924                     0.909
    2               ht 0.792                          

    Figure 15.6: Variable clustering for all potential predictors

    Six size measures adequately capture the entire set. Height and BMI are removed. An advantage of removing height is that it is age-dependent in the elderly:

    Z
    Code
    f <- orm(ht ~ rcs(age,4)*sex, data=w)  # Prop. odds model
    qu <- Quantile(f); med <- function(x) qu(.5, x)
    ggplot(Predict(f, age, sex, fun=med, conf.int=FALSE),
           ylab='Predicted Median Height, cm')

    Figure 15.7: Estimated median height as a smooth function of age, allowing age to interact with sex, from a proportional odds model

    But also see a change in leg length:

    Code
    f <- orm(leg ~ rcs(age,4)*sex, data=w)
    qu <- Quantile(f); med <- function(x) qu(.5, x)
    ggplot(Predict(f, age, sex, fun=med, conf.int=FALSE),
           ylab='Predicted Median Upper Leg Length, cm')

    Figure 15.8: Estimated median upper leg length as a smooth function of age, allowing age to interact with sex, from a proportional odds model

    Next allocate d.f. according to generalized Spearman
    \(\rho^{2}\) 8.

    A
  • 8 Competition between collinear size measures hurts interpretation of partial tests of association in a saturated additive model.

  • Code
    spar(top=1, ps=9)
    s <- spearman2(gh ~ age + sex + re + wt + leg + arml + armc +
                   waist + tri + sub, data=w, p=2)
    plot(s)

    Figure 15.9: Generalized squared rank correlations

    Parameters will be allocated in descending order of \(\rho^2\). But note that subscapular skinfold has a large number of NAs and other predictors also have NAs. Suboptimal casewise deletion will be used until the final model is fitted. Because there are many competing body measures, we use backwards stepdown to arrive at a set of predictors. The bootstrap will be used to penalize predictive ability for variable selection. First the full model is fit using casewise deletion, then we do a composite test to assess whether any of the frequently-missing predictors is important.

    B
    Code
    f <- orm(gh ~ rcs(age,5) + sex + re + rcs(wt,3) + rcs(leg,3) + arml +
             rcs(armc,3) + rcs(waist,4) + tri + rcs(sub,3),
             family=loglog, data=w, x=TRUE, y=TRUE)
    print(f, coefs=FALSE)
    -log-log Ordinal Regression Model
     orm(formula = gh ~ rcs(age, 5) + sex + re + rcs(wt, 3) + rcs(leg, 
         3) + arml + rcs(armc, 3) + rcs(waist, 4) + tri + rcs(sub, 
         3), data = w, x = TRUE, y = TRUE, family = loglog)
     

    Frequencies of Missing Values Due to Each Variable
    Model Likelihood
    Ratio Test
    Discrimination
    Indexes
    Rank Discrim.
    Indexes
    Obs 3853 LR χ2 1180.13 R2 0.265 ρ 0.520
    Distinct Y 60 d.f. 22 R222,3853 0.260
    Y0.5 5.5 Pr(>χ2) <0.0001 R222,3829.2 0.261
    max |∂log L/∂β| 3×10-5 Score χ2 1298.88 |Pr(Y ≥ median)-½| 0.172
    Pr(>χ2) <0.0001
    Code
    ## Composite test:
    anova(f, leg, arml, armc, waist, tri, sub)
    Wald Statistics for gh
    χ2 d.f. P
    leg 8.30 2 0.0158
    Nonlinear 3.32 1 0.0685
    arml 0.16 1 0.6924
    armc 6.66 2 0.0358
    Nonlinear 3.29 1 0.0695
    waist 29.40 3 <0.0001
    Nonlinear 4.29 2 0.1171
    tri 16.62 1 <0.0001
    sub 40.75 2 <0.0001
    Nonlinear 4.50 1 0.0340
    TOTAL NONLINEAR 14.95 5 0.0106
    TOTAL 128.29 11 <0.0001

    The model yields Spearman \(\rho=0.52\), the rank correlation between predicted and observed \(\text{HbA}_{1c}\). Show predicted mean and median \(\text{HbA}_{1c}\) as a function of age, adjusting other variables to median/mode. Compare the estimate of the median with that from quantile regression (discussed below).

    C
    Code
    M      <- Mean(f)
    qu     <- Quantile(f)
    med    <- function(x) qu(.5, x)
    p90    <- function(x) qu(.9, x)
    fq     <- Rq(formula(f), data=w)
    fq90   <- Rq(formula(f), data=w, tau=.9)
    pmean  <- Predict(f,    age, fun=M,   conf.int=FALSE)
    pmed   <- Predict(f,    age, fun=med, conf.int=FALSE)
    p90    <- Predict(f,    age, fun=p90, conf.int=FALSE)
    pmedqr <- Predict(fq,   age, conf.int=FALSE)
    p90qr  <- Predict(fq90, age, conf.int=FALSE)
    z <- rbind('orm mean'=pmean, 'orm median'=pmed, 'orm P90'=p90,
               'QR median'=pmedqr, 'QR P90'=p90qr)
    ggplot(z, groups='.set.',
           adj.subtitle=FALSE, legend.label=FALSE)

    Figure 15.10: Estimated mean and 0.5 and 0.9 quantiles from the log-log ordinal model using casewise deletion, along with predictions of 0.5 and 0.9 quantiles from quantile regression (QR). Age is varied and other predictors are held constant to medians/modes.

    Next do fast backward step-down in an attempt to get a model without so much competition among variables. The stepwise selection will be penalized for in the model validation.

    D
    Code
    print(fastbw(f, rule='p'), estimates=FALSE)
    
     Deleted Chi-Sq d.f. P      Residual d.f. P      AIC  
     arml    0.16   1    0.6924 0.16     1    0.6924 -1.84
     sex     0.45   1    0.5019 0.61     2    0.7381 -3.39
     wt      5.72   2    0.0572 6.33     4    0.1759 -1.67
     armc    3.32   2    0.1897 9.65     6    0.1400 -2.35
    
    Factors in Final Model
    
    [1] age   re    leg   waist tri   sub  

    Validate the model, properly penalizing for variable selection

    E
    Code
    g <- function() {
      set.seed(13)  # so can reproduce results
      validate(f, B=100, bw=TRUE, estimates=FALSE, rule='p')
    }
    v <- runifChanged(g)
    Code
    # Show number of variables selected in first 30 boots
    html(v)
    Index Original
    Sample
    Training
    Sample
    Test
    Sample
    Optimism Corrected
    Index
    \(n\)
    \(\rho\) 0.5225 0.5279 0.5204 0.0076 0.5149 100
    \(R^{2}\) 0.2712 0.2778 0.2689 0.0089 0.2623 100
    Slope 1 1 0.979 0.021 0.979 100
    \(g\) 1.2276 1.2483 1.2196 0.0287 1.1989 100
    \(|\overline{\Pr(Y\geq Y_{0.5})-\frac{1}{2}}|\) 0.2007 0.2058 0.1988 0.007 0.1937 100
    Factors Retained in Backwards Elimination
    age sex re wt leg arml armc waist tri sub
    Frequencies of Numbers of Factors Retained
    5 6 7 8 9
    2 20 30 45 3

    Next fit the reduced model. Use multiple imputation to impute missing predictors. Do an ANOVA for the reduced model, taking imputation into account.

    FG
    Code
    h <- function() {
      a <- aregImpute(~ gh + wt + ht + bmi + leg + arml + armc + waist +
                      tri + sub + age +re, data=w, n.impute=5, pr=FALSE)
      fit.mult.impute(gh ~ rcs(age,5) + re + rcs(leg,3) +
                           rcs(waist,4) + tri + rcs(sub,4),
                      orm, a, family=loglog, data=w, pr=FALSE)
    }
    g <- runifChanged(h)
    g

    -log-log Ordinal Regression Model

     fit.mult.impute(formula = gh ~ rcs(age, 5) + re + rcs(leg, 3) + 
         rcs(waist, 4) + tri + rcs(sub, 4), fitter = orm, xtrans = a, 
         data = w, pr = FALSE, family = loglog)
     
    Model Likelihood
    Ratio Test
    Discrimination
    Indexes
    Rank Discrim.
    Indexes
    Obs 4629 LR χ2 1445.98 R2 0.269 ρ 0.512
    Distinct Y 63 d.f. 17 R217,4629 0.266
    Y0.5 5.5 Pr(>χ2) <0.0001 R217,4602.2 0.267
    max |∂log L/∂β| 1×10-5 Score χ2 1566.91 |Pr(Y ≥ median)-½| 0.173
    Pr(>χ2) <0.0001
    β S.E. Wald Z Pr(>|Z|)
    age   0.0404  0.0055 7.33 <0.0001
    age’  -0.0231  0.0277 -0.83 0.4055
    age’’   0.0138  0.0873 0.16 0.8747
    age’’’   0.0403  0.1146 0.35 0.7250
    re=Other Hispanic  -0.0781  0.0591 -1.32 0.1861
    re=Non-Hispanic White  -0.4124  0.0450 -9.16 <0.0001
    re=Non-Hispanic Black   0.0646  0.0562 1.15 0.2501
    re=Other Race Including Multi-Racial  -0.0532  0.0755 -0.71 0.4806
    leg  -0.0336  0.0092 -3.66 0.0003
    leg’   0.0149  0.0106 1.40 0.1625
    waist   0.0065  0.0050 1.30 0.1935
    waist’   0.0334  0.0163 2.05 0.0401
    waist’’  -0.0984  0.0523 -1.88 0.0600
    tri  -0.0161  0.0029 -5.52 <0.0001
    sub  -0.0011  0.0099 -0.11 0.9123
    sub’   0.0642  0.0319 2.01 0.0442
    sub’’  -0.1820  0.1042 -1.75 0.0806
    Code
    an <- anova(g)
    print(an, caption='ANOVA for reduced model after multiple imputation, with addition of a combined effect for four size variables')
    ANOVA for reduced model after multiple imputation, with addition of a combined effect for four size variables
    χ2 d.f. P
    age 702.58 4 <0.0001
    Nonlinear 28.61 3 <0.0001
    re 167.70 4 <0.0001
    leg 24.08 2 <0.0001
    Nonlinear 1.95 1 0.1625
    waist 144.63 3 <0.0001
    Nonlinear 4.80 2 0.0906
    tri 30.44 1 <0.0001
    sub 38.52 3 <0.0001
    Nonlinear 5.58 2 0.0613
    TOTAL NONLINEAR 45.40 8 <0.0001
    TOTAL 1450.51 17 <0.0001
    Code
    b  <- anova(g, leg, waist, tri, sub)
    # Add new lines to the plot with combined effect of 4 size var.
    s <- rbind(an, size=b['TOTAL', ])
    class(s) <- 'anova.rms'
    Code
    spar(top=1)
    plot(s)

    Figure 15.11: ANOVA for reduced model after multiple imputation

    H

    Code
    ggplot(Predict(g), abbrev=TRUE, ylab=NULL)   

    Figure 15.12: Partial effects (log hazard or log-log cumulative probability scale) of all predictors in reduced model, after multiple imputation

    I
    Code
    M <- Mean(g)
    ggplot(Predict(g, fun=M), abbrev=TRUE, ylab=NULL)   

    Figure 15.13: Partial effects (mean scale) of all predictors in reduced model, after multiple imputation

    Compare the estimated age partial effects and confidence intervals with those from a model using casewise deletion, and with bootstrap nonparametric confidence intervals (also with casewise deletion).

    J
    Code
    h <- function() {
      gc <- orm(gh ~ rcs(age,5) + re + rcs(leg,3) +
                rcs(waist,4) + tri + rcs(sub,4),
                family=loglog, data=w, x=TRUE, y=TRUE)
      gb <- bootcov(gc, B=300)
      list(gc=gc, gb=gb)
    }
    gbc <- runifChanged(h)
    gc  <- gbc$gc
    gb  <- gbc$gb
    Code
    pgc     <- Predict(gc, age)
    bootclb <- Predict(gb, age, boot.type='basic')
    bootclp <- Predict(gb, age, boot.type='percentile')
    multimp <- Predict(g,  age)
    p <- rbind('casewise deletion'    = pgc,
               'basic bootstrap'      = bootclb,
               'percentile bootstrap' = bootclp,
               'multiple imputation'  = multimp)[, .q(age, yhat, lower, upper, .set.)]
    m <- melt(p, id.vars=c('age', '.set.'))
    
    ggplot(m, aes(x=age, y=value, color=.set.,
                  group=paste(variable, .set.))) + geom_line() +
      guides(color=guide_legend(title='')) +
      theme(legend.position='bottom') +
      ylab(expression(X * hat(beta)))

    Figure 15.14: Partial effect for age from multiple imputation and casewise deletion (center lines with the green line depicting all non-multiple-imputation methods) with symmetric Wald 0.95 confidence bands using casewise deletion, basic bootstrap confidence bands using casewise deletion, percentile bootstrap confidence bands using casewise deletion, and symmetric Wald confidence bands accounting for multiple imputation.

    In OLS the mean equals the median and both are linearly related to any other quantiles. Semiparametric models are not this restrictive:

    K

    Code
    M  <- Mean(g)
    qu <- Quantile(g)
    med <- function(lp) qu(.5, lp)
    q90 <- function(lp) qu(.9, lp)
    lp  <- predict(g)
    lpr <- quantile(predict(g), c(.002, .998), na.rm=TRUE)
    lps <- seq(lpr[1], lpr[2], length=200)
    pmn <- M(lps)
    pme <- med(lps)
    p90 <- q90(lps)
    plot(pmn, pme,   
         xlab=expression(paste('Predicted Mean ',  HbA["1c"])),
         ylab='Median and 0.9 Quantile', type='l',
         xlim=c(4.75, 8.0), ylim=c(4.75, 8.0), bty='n')
    box(col=gray(.8))
    lines(pmn, p90, col='blue')
    abline(a=0, b=1, col=gray(.8))
    text(6.5, 5.5, 'Median')
    text(5.5, 6.3, '0.9', col='blue')
    nint <- 350
    scat1d(M(lp),   nint=nint)
    scat1d(med(lp), side=2, nint=nint)
    scat1d(q90(lp), side=4, col='blue', nint=nint)

    Figure 15.15: Predicted mean r hba vs. predicted median and 0.9 quantile along with their marginal distributions

    Draw a nomogram to compute 7 different predicted values for each subject.

    L
    Code
    spar(ps=9)
    g      <- Newlevels(g, list(re=abbreviate(levels(w$re))))
    exprob <- ExProb(g)
    nom <-
      nomogram(g, fun=list(Mean=M,
                    'Median Glycohemoglobin' = med,
                    '0.9 Quantile'           = q90,
                    'Prob(HbA1c >= 6.5)'=
                         function(x) exprob(x, y=6.5),
                    'Prob(HbA1c >= 7.0)'=
                         function(x) exprob(x, y=7),
                    'Prob(HbA1c >= 7.5)'=
                         function(x) exprob(x, y=7.5)),
               fun.at=list(seq(5, 8, by=.5),
                 c(5,5.25,5.5,5.75,6,6.25),
                 c(5.5,6,6.5,7,8,10,12,14),
                 c(.01,.05,.1,.2,.3,.4),
                 c(.01,.05,.1,.2,.3,.4),
                 c(.01,.05,.1,.2,.3,.4)))
    plot(nom, lmgp=.28)   

    Figure 15.16: Nomogram for predicting median, mean, and 0.9 quantile of glycohemoglobin, along with the estimated probability that \(\text{HbA}_{1c} \ge 6.5, 7\), or \(7.5\), all from the log-log ordinal model