Type: | Package |
Title: | Fit Rank-Ordered Logit (RO-Logit) Model |
Version: | 0.1.3 |
Description: | Implements the rank-ordered logit (RO-logit) model for stratified analysis of continuous outcomes introduced by Tan et al. (2017) <doi:10.1177/0962280217747309>. Model diagnostics based on the heuristic residuals and estimates in linear scales are available from the package, and outcomes with ties are supported. |
Depends: | R (≥ 3.1.0) |
Imports: | survival (≥ 2.41-3), evd (≥ 2.3-2) |
License: | LGPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-04-17 06:42:44 UTC; yilinning |
Repository: | CRAN |
Date/Publication: | 2025-04-17 07:00:02 UTC |
Author: | Chuen Seng Tan [aut], Yilin Ning [aut, cre] |
Maintainer: | Yilin Ning <ningyilinnyl@gmail.com> |
Obtain the heuristic residuals.
Description
Obtain the heuristic residuals.
Usage
hresid(y, svar, design.mat, o, initial.res.par = c(0, 0), ...)
Arguments
y |
vector of numeric. The outcomes. |
svar |
vector of numeric. The strata variable. |
design.mat |
matrix. The design matrix including intercept term. |
o |
matrix. Contains the estimated coefficients of the RO-logit and their SEs. |
initial.res.par |
The initial values of the intercept and log(scale), to
be passed to the |
... |
Other parameters to be passed to the |
Value
Returns a list containing the estimated intercept and
log(scale)
, the covariance matrix of these two parameters,
convergence status from optim
, and the heuristic residuals.
Inpatient blood glucose data for 2487 patients
Description
A simulated dataset containing inpatient point-of-care blood glucose (BG) measurements from 2487 non-critical care adult patients above 40 years old. Data was simulated based on real data.
Usage
inpat_bg
Format
A data frame with 2487 rows and 13 variables:
- bg_mean
Mean BG readings within each episode, in mmol/L.
- bg_sd
Standard deviation of BG readings within each episode.
- sex
Gender of patients.
- ward
Whether each patient is in the medical ward (
ward = 0
) or surgical ward (ward = 1
).- age_group
Patient group defined based on the median age.
- los_group
Patient group defined based on the median of duration of monitoring episode.
- bg_freq_group
Patient group defined based on the median of daily BG monitoring frequency.
- age
Patients' age.
- los
Patients' duration of monitoring episode.
- bg_freq
Patients' daily BG monitoring frequency.
References
Tan CS, Støer NC, Chen Y, Andersson M, Ning Y, Wee HL, Khoo EY, Tai ES, Kao SL, Reilly M. A stratification approach using logit-based models for confounder adjustment in the study of continuous outcomes. Statistical methods in medical research. 2017 Jan 1:0962280217747309.
The negative log likelihood function for obtaining heuristic residuals
Description
Compute the negative log-likelihood for obtaining heuristic residuals.
Usage
loglikhresid(par, y, x, par1)
Arguments
par |
vector of numeric. Contain the intercept, first entry, and coefficient of log(sigma), second entry. |
y |
vector of numeric. Centered outcomes within each stratum. |
x |
matrix. The design matrix including intercept term. |
par1 |
vector of numeric. The estimated coefficients from RO-logit model. |
Make Q-Q plot for residual diagnostics.
Description
Make Q-Q plot for residual diagnostics.
Usage
qqplot.EVT1(hresid, scale)
Arguments
hresid |
vector of numeric. The heuristic residuals. |
scale |
numeric. The scale parameter. |
Examples
## Not run:
hresid <- evd::rgumbel(n = 100, loc = 0, scale = 3)
qqplot.EVT1(hresid = hresid, scale = 3)
## End(Not run)
Fit RO-logit model and obtain heuristic residuals
Description
Fit RO-logit model and obtain heuristic residuals
Usage
rologit(
yvar,
evar,
cfdr = NULL,
emod = NULL,
svar,
dat,
method = "efron",
initial.res.par = c(0, 0),
plot = TRUE,
...
)
Arguments
yvar |
string. Name of outcome variable. |
evar |
string (or vector of strings). Name of exposure(s). |
cfdr |
string (or vector of strings). Names of confounder(s). Default is
|
emod |
string (or vector of strings). Name of effect modifier(s).
Default is |
svar |
string. Name of stratum variable. Use |
dat |
|
method |
string. Use Efron ( |
initial.res.par |
The initial values of the intercept and log(scale), to
be passed to the |
plot |
logic. To plot the Q-Q plot for the heuristic residuals. Default
is |
... |
Other parameters to be passed to the |
Value
Returns a list containing obj
(the RO-Logit model fitted using
coxph
), hresid
(the vector of heuristic residuals),
logscale
(log of scale parameter of the heuristic residuals), and
coefficients
(a data.frame with estimated coefficients before and
after scaling).
References
Allison PD, Christakis NA. Logit-models for sets of ranked items. Sociological Methodology 1994, Vol 24. 1994;24:199-228.
Beggs S, Cardell S, Hausman J. Assessing the Potential Demand for Electric Cars. J Econometrics. 1981;17:1-19.
Tan CS, Støer NC, Chen Y, Andersson M, Ning Y, Wee HL, Khoo EY, Tai ES, Kao SL, Reilly M. A stratification approach using logit-based models for confounder adjustment in the study of continuous outcomes. Statistical methods in medical research. 2017 Jan 1:0962280217747309.
Therneau TM, Grambsch PM. Modeling Survival Data: Extending the Cox Model: Springer New York; 2000.
Examples
# Fit an RO-logit model to determine whether the glycaemic control of
# patients differs between medical and surgical wards.
data(inpat_bg)
# Divide patients into strata based on age, gender, duration of monitoring
# episodes, and frequency of daily BG measurements.
inpat_bg$group <- paste(inpat_bg$age_group, inpat_bg$sex, inpat_bg$los_group,
inpat_bg$bg_freq_group, sep = "|")
# Fit an RO-logit model with mean BG reading as the outcome and ward as the
# exposure:
obj <- rologit(yvar = "bg_mean", evar = "ward", svar = "group",
dat = inpat_bg, initial.res.par = c(2, 2))
summary(obj)
Fit RO-logit model using Cox-PH
Description
Fit RO-logit model using Cox-PH
Usage
rologit.coxph(design.mat, y, svar = NULL, method = "efron")
Arguments
design.mat |
The design matrix without intercept term. |
y |
vector of numeric. The outcomes. |
svar |
vector of numeric. The strata variable. |
method |
string. Use Efron ( |
Value
Returns the model fitted using coxph
.
Summarise RO-Logit Model
Description
Prints the estimated coefficients of an RO-Logit model.
Usage
## S3 method for class 'rologit'
summary(object, ...)
Arguments
object |
Model object fitted using |
... |
Additional arguments affecting the summary produced. |