Title: | Constrained Regression Model for an Ordinal Response and Ordinal Predictors |
---|---|
Description: | Fits a constrained regression model for an ordinal response with ordinal predictors and possibly others, Espinosa and Hennig (2019) <DOI:10.1007/s11222-018-9842-2>. The parameter estimates associated with an ordinal predictor are constrained to be monotonic. If a monotonicity direction (isotonic or antitonic) is not specified for an ordinal predictor by the user, then one of the available methods will either establish it or drop the monotonicity assumption. Two monotonicity tests are also available to test the null hypothesis of monotonicity over a set of parameters associated with an ordinal predictor. |
Authors: | Javier Espinosa <[email protected]> |
Maintainer: | Javier Espinosa <[email protected]> |
License: | GPL-2 |
Version: | 0.3.0 |
Built: | 2024-11-17 06:27:48 UTC |
Source: | CRAN |
Determines whether a parameter vector is in the confidence region CCR, according to the definitions in Espinosa and Hennig (2023) <https://doi.org/10.48550/arXiv.2107.04946>.
confRegCCR( CMLE = NULL, paramVals = NULL, paramIDs = NULL, SignifLevel = 0.05, df, matY, matX )
confRegCCR( CMLE = NULL, paramVals = NULL, paramIDs = NULL, SignifLevel = 0.05, df, matY, matX )
CMLE |
A vector with the constrained maximum likelihood estimates. |
paramVals |
A vector with the parameter values for which it is needed to
assess whether it is part of the confidence region or not.
The order of the parameters must be the same as the one of |
paramIDs |
A vector indicating the positions of the parameter values of
beta_0r in |
SignifLevel |
A decimal number indicating the significant level. Usually, 0.05. |
df |
Degrees of freedom to be used. |
matY |
matY resulting from mdcp(). |
matX |
matX resulting from mdcp(). |
confRegions
: Data frame with columns:
CMLE_logLik
=log-likelihood of the constrained model,
param_logLik
=log-likelihood of the model using paramVals
,
monotonicBeta0
=logical value, TRUE
if the set of parameters
of paramVals
indicated by paramIDs
are monotonic,
df
=degrees of freedom used to calculate the critical value,
StatCCR
=value of the statistic used for CCR
,
CritValue
=critical value, chi-squared with df
and 1-SignifLevel
,
SignifLevel
=significance level used to calculate the critical value,
inCCR
=logical value, TRUE
if paramVals
belongs to the confidence region CCR
,
Espinosa, J., and Hennig, C. "Inference for the proportional odds cumulative logit model with monotonicity constraints for ordinal predictors and ordinal response." Arxiv (2023). <https://doi.org/10.48550/arXiv.2107.04946>.
confRegUCRandUCCR
,
mdcp
,
monoTestBonf
,
monoTestConfReg
,
plotCMLE
,
vlgm
.
resAux <- mdcp(QoL ~ EduLevel + Age + IncQuint + Gender + Health, data = crovData) plotCMLE(resAux) myVector <- resAux$estimates myVectorID <- 10:12 myVector[myVectorID] # non-monotonic beta_{0r} myVector[myVectorID] <- seq(0.195,0.185,length.out=3) confRegCCR(CMLE=resAux$estimates, paramVals=myVector, paramIDs=myVectorID,SignifLevel=0.05, df=3, matY= resAux$matY, matX= resAux$matX) # monotonic beta_{0r} and paramVals in CCR myVector[myVectorID] <- seq(0.048,0.049,length.out=3) confRegCCR(CMLE=resAux$estimates, paramVals=myVector, paramIDs=myVectorID,SignifLevel=0.05, df=3, matY= resAux$matY, matX= resAux$matX) # monotonic beta_{0r} and paramVals out of CCR myVector[myVectorID] <- seq(0.047,0.048,length.out=3) confRegCCR(CMLE=resAux$estimates, paramVals=myVector, paramIDs=myVectorID,SignifLevel=0.05, df=3, matY= resAux$matY, matX= resAux$matX)
resAux <- mdcp(QoL ~ EduLevel + Age + IncQuint + Gender + Health, data = crovData) plotCMLE(resAux) myVector <- resAux$estimates myVectorID <- 10:12 myVector[myVectorID] # non-monotonic beta_{0r} myVector[myVectorID] <- seq(0.195,0.185,length.out=3) confRegCCR(CMLE=resAux$estimates, paramVals=myVector, paramIDs=myVectorID,SignifLevel=0.05, df=3, matY= resAux$matY, matX= resAux$matX) # monotonic beta_{0r} and paramVals in CCR myVector[myVectorID] <- seq(0.048,0.049,length.out=3) confRegCCR(CMLE=resAux$estimates, paramVals=myVector, paramIDs=myVectorID,SignifLevel=0.05, df=3, matY= resAux$matY, matX= resAux$matX) # monotonic beta_{0r} and paramVals out of CCR myVector[myVectorID] <- seq(0.047,0.048,length.out=3) confRegCCR(CMLE=resAux$estimates, paramVals=myVector, paramIDs=myVectorID,SignifLevel=0.05, df=3, matY= resAux$matY, matX= resAux$matX)
Determines whether a parameter vector is in the confidence region UCR and/or UCCR, according to the definitions in Espinosa and Hennig (2023) <https://doi.org/10.48550/arXiv.2107.04946>.
confRegUCRandUCCR( UMLE = NULL, paramVals = NULL, paramIDs = NULL, SignifLevel = 0.05, df, matY, matX )
confRegUCRandUCCR( UMLE = NULL, paramVals = NULL, paramIDs = NULL, SignifLevel = 0.05, df, matY, matX )
UMLE |
A vector with the unconstrained maximum likelihood estimates. |
paramVals |
A vector with the parameter values for which it is needed to
assess whether it is part of one of the confidence regions or not.
The order of the parameters must be the same as the one of |
paramIDs |
A vector indicating the positions of the parameter values of
beta_0r in |
SignifLevel |
A decimal number indicating the significant level. Usually, 0.05. |
df |
Degrees of freedom to be used. |
matY |
matY resulting from mdcp(). |
matX |
matX resulting from mdcp(). |
confRegions
: Data frame with columns:
UMLE_logLik
=log-likelihood of the unconstrained model,
param_logLik
=log-likelihood of the model using paramVals
,
monotonicBeta0
=logical value, TRUE
if the set of parameters
of paramVals
indicated by paramIDs
are monotonic,
df
=degrees of freedom used to calculate the critical value,
StatUCR
=value of the statistic used for UCR
,
StatUCCR
=value of the statistic used for UCCR
,
CritValue
=critical value, chi-squared with df
and 1-SignifLevel
,
SignifLevel
=significance level used to calculate the critical value,
inUCR
=logical value, TRUE
if paramVals
belongs to the confidence region UCR
,
inUCCR
=logical value, TRUE
if paramVals
belongs to the confidence region UCCR
,
Espinosa, J., and Hennig, C. "Inference for the proportional odds cumulative logit model with monotonicity constraints for ordinal predictors and ordinal response." Arxiv (2023). <https://doi.org/10.48550/arXiv.2107.04946>.
confRegCCR
,
mdcp
,
monoTestBonf
,
monoTestConfReg
,
plotCMLE
,
vlgm
.
resAux <- mdcp(QoL ~ EduLevel + Age + IncQuint + Gender + Health, data = crovData) plotCMLE(resAux) myVector <- resAux$estimates myVectorID <- 10:12 myVector[myVectorID] # non-monotonic beta_{0r}, paramVals in UCR but not in UCCR myVector[myVectorID] <- seq(0.195,0.185,length.out=3) confRegUCRandUCCR(UMLE=resAux$UMLE, paramVals=myVector, paramIDs=myVectorID,SignifLevel=0.05, df=3, matY= resAux$matY, matX= resAux$matX) # monotonic beta_{0r}, paramVals in UCR and UCCR myVector[myVectorID] <- seq(0.073,0.074,length.out=3) confRegUCRandUCCR(UMLE=resAux$UMLE, paramVals=myVector, paramIDs=myVectorID,SignifLevel=0.05, df=3, matY= resAux$matY, matX= resAux$matX) # monotonic beta_{0r}, paramVals out of UCR and UCCR myVector[myVectorID] <- seq(0.072,0.073,length.out=3) confRegUCRandUCCR(UMLE=resAux$UMLE, paramVals=myVector, paramIDs=myVectorID,SignifLevel=0.05, df=3, matY= resAux$matY, matX= resAux$matX)
resAux <- mdcp(QoL ~ EduLevel + Age + IncQuint + Gender + Health, data = crovData) plotCMLE(resAux) myVector <- resAux$estimates myVectorID <- 10:12 myVector[myVectorID] # non-monotonic beta_{0r}, paramVals in UCR but not in UCCR myVector[myVectorID] <- seq(0.195,0.185,length.out=3) confRegUCRandUCCR(UMLE=resAux$UMLE, paramVals=myVector, paramIDs=myVectorID,SignifLevel=0.05, df=3, matY= resAux$matY, matX= resAux$matX) # monotonic beta_{0r}, paramVals in UCR and UCCR myVector[myVectorID] <- seq(0.073,0.074,length.out=3) confRegUCRandUCCR(UMLE=resAux$UMLE, paramVals=myVector, paramIDs=myVectorID,SignifLevel=0.05, df=3, matY= resAux$matY, matX= resAux$matX) # monotonic beta_{0r}, paramVals out of UCR and UCCR myVector[myVectorID] <- seq(0.072,0.073,length.out=3) confRegUCRandUCCR(UMLE=resAux$UMLE, paramVals=myVector, paramIDs=myVectorID,SignifLevel=0.05, df=3, matY= resAux$matY, matX= resAux$matX)
Uses real data
crovData
crovData
Data frame with 9 variables
Fits a constrained regression model for an ordinal response with ordinal predictors
and possibly others, Espinosa and Hennig (2019) <DOI:10.1007/s11222-018-9842-2>. The parameter estimates associated with an ordinal
predictor are constrained to be monotonic. If a monotonicity direction (isotonic or antitonic) is
not specified for an ordinal predictor (OP) by the user, then a constrained method to be indicated in the option method
establishes it or the
approach that tries all possible combinations of monotonicity directions an the chooses the one with maximum likelihood.
mdcp( formula, data = NULL, tryAllMonoDir = FALSE, monoDir = NULL, CLS1 = 0.95, TLBS2 = 0.85, TLNS2 = 0.999, StepSizeCLS2 = 1e-04, method = NULL, monoTestSignLevel = 0.05, reltol = 1e-05, mu = 1e-04, outer.eps = 1e-05 )
mdcp( formula, data = NULL, tryAllMonoDir = FALSE, monoDir = NULL, CLS1 = 0.95, TLBS2 = 0.85, TLNS2 = 0.999, StepSizeCLS2 = 1e-04, method = NULL, monoTestSignLevel = 0.05, reltol = 1e-05, mu = 1e-04, outer.eps = 1e-05 )
formula |
A |
data |
A data.frame, list or environment (or object coercible by |
tryAllMonoDir |
A logical value that indicates whether one model should be fitted for each one of the possible combinations of monotonicity
directions of the ordinal predictors' effects. Use |
monoDir |
Vector with monotonicity directions for the ordinal predictors to be used as constraints. Possible values for |
CLS1 |
Numerical value for the confidence level to be used in the first step of the MDC procedure. This parameter is active if
|
TLBS2 |
Numerical value for the tolerance level to be used in the second step of the MDC procedure over those ordinal
predictors classified as "Both" in the first step. This parameter is active if |
TLNS2 |
Numerical value for the tolerance level to be used in the second step of the MDC procedure over those ordinal
predictors classified as "None" in the first step. This parameter is active if |
StepSizeCLS2 |
Numerical value for the magnitude in which the confidence levels will be increased or decreased during the second step of
the MDC procedure. This parameter is active if |
method |
The type of constrained method to be used among |
monoTestSignLevel |
Significance level used when |
reltol |
Passed to |
mu |
Passed to |
outer.eps |
Passed to |
MDCproc
: Data frame with the monotonicity direction classification (Isotonic, Antitonic, Both, or None) used for each
ordinal predictor in each one of the steps of the MDC procedure (S1, S2 and S3), together with their individual confidence levels (CL). If
monoDir
is used, MDCproc
shows the monotonicity directions in monoDir
.
estimates
: Vector of parameter estimates of the model.
log.lik
: Value of the log-likelihood of the model.
allModels
: Data frame with monotonicity directions, log-likelihood and parameter estimates of all models involved in the third step of the MDC
procedure. If parameter monoDir
is used, allModels
shows these results from the model with monotonicity directions
used in monoDir
only. If parameter tryAllMonoDir
is used, allModels
shows these results from all the models according to all possible
combinations of monotonicity directions.
constrOptimRes
: List with the outcomes provided by the function constrOptim
.
UMLE
: Vector with the parameter estimates of the unconstrained version of the model.
UMLE_SE
: Vector with the standard errors of the unconstrained version of the model.
q_cat_OrdPred
: Vector with the number of ordinal categories for each ordinal predictor. Values are displayed in the same order as the ordinal predictors are incorporated in formula
.
Espinosa, J., and Hennig, C. "A constrained regression model for an ordinal response with ordinal predictors." Statistics and Computing 29.5 (2019): 869-890. https://doi.org/10.1007/s11222-018-9842-2.
monoTestBonf
,
monoTestConfReg
,
confRegUCRandUCCR
,
confRegCCR
,
plotCMLE
,
constrOptim
.
# Ordinal predictors: EduLevel, IncQuint and Health, mdcpExample <- mdcp(QoL ~ EduLevel + Age + IncQuint + Gender + Health, data = crovData, CLS1 = 0.95, TLBS2 = 0.90, TLNS2 = 0.99, StepSizeCLS2 = 0.0002) mdcpExample$MDCproc cbind("CMLE"=mdcpExample$estimates,"UMLE"=mdcpExample$UMLE) mdcpExample$UMLE_SE mdcpExample$log.lik mdcpExample$allModels[1:6]
# Ordinal predictors: EduLevel, IncQuint and Health, mdcpExample <- mdcp(QoL ~ EduLevel + Age + IncQuint + Gender + Health, data = crovData, CLS1 = 0.95, TLBS2 = 0.90, TLNS2 = 0.99, StepSizeCLS2 = 0.0002) mdcpExample$MDCproc cbind("CMLE"=mdcpExample$estimates,"UMLE"=mdcpExample$UMLE) mdcpExample$UMLE_SE mdcpExample$log.lik mdcpExample$allModels[1:6]
Tests the null hypothesis of monotonicity over a set of parameters associated to an ordinal predictor, according to Espinosa and Hennig (2019) <DOI:10.1007/s11222-018-9842-2>.
monoTestBonf(simultAlpha = 0.05, OP_UMLE, OP_SE)
monoTestBonf(simultAlpha = 0.05, OP_UMLE, OP_SE)
simultAlpha |
Numerical value for the simultaneous significance level. |
OP_UMLE |
Vector with the unconstrained parameter estimates of an ordinal predictor's categories represented by dummy variables
in an unconstrained model for ordinal response (see |
OP_SE |
Vector with the standard error of the parameters of an ordinal predictor's categories represented by dummy variables
in an unconstrained model for ordinal response (see |
testRes
: String value with outcomes either "Reject H_0" or "Not Reject H_0".
simultAlpha
: Numerical value with the simultaneous significance level.
indivAlphaA
: Numerical value with the individual significance level for each confidence interval.
simultPvalue
: Numerical value with the p-value associated to the simultaneous significance level.
Espinosa, J., and Hennig, C. "A constrained regression model for an ordinal response with ordinal predictors." Statistics and Computing 29.5 (2019): 869-890. https://doi.org/10.1007/s11222-018-9842-2.
mdcp
,
monoTestConfReg
,
plotCMLE
,
vlgm
.
monoTestBonf(simultAlpha=0.05, OP_UMLE = c(-0.352177095,-0.403928770, -0.290875028,-0.769834449), OP_SE = c(0.246638339,0.247723681,0.267577633,0.300951441))
monoTestBonf(simultAlpha=0.05, OP_UMLE = c(-0.352177095,-0.403928770, -0.290875028,-0.769834449), OP_SE = c(0.246638339,0.247723681,0.267577633,0.300951441))
Tests the null hypothesis of monotonicity over a set of parameters associated to an ordinal predictor. The log-likelihood ratio test is used after imposing ordinal constraints on the parameter estimates of a single ordinal predictor and comparing its results against the unconstrained MLEs.
monoTestConfReg(formula, data = NULL, monoDir = NULL, SignifLevel = 0.05)
monoTestConfReg(formula, data = NULL, monoDir = NULL, SignifLevel = 0.05)
formula |
A |
data |
A data.frame, list or environment (or object coercible by |
monoDir |
Vector with monotonicity directions for the ordinal predictors to be used as constraints. Possible values for |
SignifLevel |
Numerical value for the significance level. |
resConfRegTest
: Data frame with columns:
OPName
=Name of the ordinal predictor (OP),
Num_Cat
=Number of categories of the OP,
UMLE_logLik
=log-likelihood of the unconstrained model,
CMLE_logLik
=log-likelihood of the constrained model using mdcp
assuming monotonicity for each OP,
degreesOfFreedom
=degrees of freedom used in the hypothesis test,
Statistic
=value of the statistic,
CritValue
=critical value resulting from the statistic,
SignifLevel
=significance level used in the test,
P.Value
=p-value,
RejectMonotonicity
=TRUE if the null hypothesis of monotonicity is rejected, FALSE otherwise.
mdcp
,
monoTestBonf
,
confRegUCRandUCCR
,
confRegCCR
,
plotCMLE
,
vlgm
.
# Ordinal predictors: EduLevel, IncQuint and Health monoTestConfRegExample <- monoTestConfReg(QoL ~ EduLevel + Age + IncQuint + Gender + Health, data = crovData, monoDir=c(0,-1,-1), SignifLevel = 0.05) monoTestConfRegExample$resConfRegTest
# Ordinal predictors: EduLevel, IncQuint and Health monoTestConfRegExample <- monoTestConfReg(QoL ~ EduLevel + Age + IncQuint + Gender + Health, data = crovData, monoDir=c(0,-1,-1), SignifLevel = 0.05) monoTestConfRegExample$resConfRegTest
Uses the results of function mdcp
to produce a plot for the Maximum Likelihood Estimators of the parameters of both
the unconstrained and constrained proportional odds logit models (UMLE and CMLE
correspondingly). The UMLE includes confidence intervals. Parameter estimates of ordinal predictors
are graphically linked with segments.
plotCMLE( mdcpResult = NULL, SignifLevel = 0.05, xposLegend = NULL, yposLegend = NULL, xcex.axis = 0.8, ycex.axis = 0.8, cexLegend = 1, methodName = "Not indicated" )
plotCMLE( mdcpResult = NULL, SignifLevel = 0.05, xposLegend = NULL, yposLegend = NULL, xcex.axis = 0.8, ycex.axis = 0.8, cexLegend = 1, methodName = "Not indicated" )
mdcpResult |
An object of class |
SignifLevel |
Significance level to be used when constructing the confidence intervals for each parameter of the unconstrained proportional odds logit model. Default value 0.05. |
xposLegend |
Position of legend on the x-axis. If |
yposLegend |
Position of legend on the y-axis. If |
xcex.axis |
Size of |
ycex.axis |
Size of |
cexLegend |
Size of legend text to be assigned to |
methodName |
Method name to be used in the main title of the plot. |
Plot.
monoTestBonf
,
monoTestConfReg
,
monoTestBonf
,
constrOptim
.
# Ordinal predictors: EduLevel, IncQuint, Health, # Overcrowd, and NumChildren mdcpExample <- mdcp(QoL ~ EduLevel + Age + IncQuint + Gender + Health, data = crovData, CLS1 = 0.95, TLBS2 = 0.90, TLNS2 = 0.99, StepSizeCLS2 = 0.0002) plotCMLE(mdcpResult=mdcpExample,SignifLevel=0.05,xposLegend=14, yposLegend=4.8, cexLegend=0.8, method="MDCS3")
# Ordinal predictors: EduLevel, IncQuint, Health, # Overcrowd, and NumChildren mdcpExample <- mdcp(QoL ~ EduLevel + Age + IncQuint + Gender + Health, data = crovData, CLS1 = 0.95, TLBS2 = 0.90, TLNS2 = 0.99, StepSizeCLS2 = 0.0002) plotCMLE(mdcpResult=mdcpExample,SignifLevel=0.05,xposLegend=14, yposLegend=4.8, cexLegend=0.8, method="MDCS3")