Description Usage Arguments Value Note References Examples
A generic function to simulate surrogate residuals for cumulative link regression models using the latent method described in Liu and Zhang (2017).
It also support the sign-based residuals (Li and Shepherd, 2010), generalized residuals (Franses and Paap, 2001), and deviance residuals for cumulative link regression models.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | ## S3 method for class 'clm'
residuals(
object,
type = c("surrogate", "sign", "general", "deviance"),
jitter = c("latent", "uniform"),
jitter.uniform.scale = c("probability", "response"),
nsim = 1L,
...
)
## S3 method for class 'lrm'
residuals(
object,
type = c("surrogate", "sign", "general", "deviance"),
jitter = c("latent", "uniform"),
jitter.uniform.scale = c("probability", "response"),
nsim = 1L,
...
)
## S3 method for class 'orm'
residuals(
object,
type = c("surrogate", "sign", "general", "deviance"),
jitter = c("latent", "uniform"),
jitter.uniform.scale = c("probability", "response"),
nsim = 1L,
...
)
## S3 method for class 'polr'
residuals(
object,
type = c("surrogate", "sign", "general", "deviance"),
jitter = c("latent", "uniform"),
jitter.uniform.scale = c("probability", "response"),
nsim = 1L,
...
)
## S4 method for signature 'vglm'
residuals(
object,
type = c("surrogate", "sign", "general", "deviance"),
jitter = c("latent", "uniform"),
jitter.uniform.scale = c("probability", "response"),
nsim = 1L,
...
)
## S4 method for signature 'vgam'
residuals(
object,
type = c("surrogate", "sign", "general", "deviance"),
jitter = c("latent", "uniform"),
jitter.uniform.scale = c("probability", "response"),
nsim = 1L,
...
)
## S3 method for class 'ord'
residuals(
object,
type = c("surrogate", "sign", "general", "deviance", "pearson", "working",
"response", "partial"),
jitter = c("latent", "uniform"),
jitter.uniform.scale = c("probability", "response"),
nsim = 1L,
...
)
## S3 method for class 'PAsso'
residuals(object, draw_id = 1, ...)
|
object |
An object of class |
type |
The type of residuals which should be returned. The alternatives are: "surrogate" (default), "sign", "general", and "deviance". Can be abbreviated.
|
jitter |
When the
|
jitter.uniform.scale |
When the |
nsim |
An integer specifying the number of replicates to use.
Default is |
... |
Additional optional arguments. |
draw_id |
A number refers to the i-th draw of residuals. |
A numeric vector of class c("numeric", "resids")
containing
the simulated surrogate residuals. Additionally, if nsim
> 1,
then the result will contain the attributes:
draws
A matrix with nsim
columns, one for each
is a replicate of the surrogate residuals. Note, they correspond
to the original ordering of the data;
draws_id
A matrix with nsim
columns. Each column
contains the observation number each surrogate residuals corresponds to in
draws
. (This is used for plotting purposes.)
A matrix of class c("matrix", "resids")
containing
the simulated surrogate residuals used for the partial association
analysis in PAsso
. Additionally, if rep_num
> 1 in PAsso
,
then the result will contain the attributes:
draws
An array contains all draws of residuals.
Surrogate response values require sampling from a continuous distribution;
consequently, the result will be different with every call to
surrogate
. The internal functions used for sampling from truncated
distributions are based on modified versions of
rtrunc
and qtrunc
.
For "glm"
objects, only the binomial()
family is supported.
Liu, D., Li, S., Yu, Y., & Moustaki, I. (2020). Assessing partial association between ordinal variables: quantification, visualization, and hypothesis testing. Journal of the American Statistical Association, 1-14. doi: 10.1080/01621459.2020.1796394
Liu, D., & Zhang, H. (2018). Residuals and diagnostics for ordinal regression models: A surrogate approach. Journal of the American Statistical Association, 113(522), 845-854. doi: 10.1080/01621459.2017.1292915
Li, C., & Shepherd, B. E. (2010). Test of association between two ordinal variables while adjusting for covariates. Journal of the American Statistical Association, 105(490), 612-620. doi: 10.1198/jasa.2010.tm09386
Franses, P. H., & Paap, R. (2001). Quantitative models in marketing research. Cambridge University Press. doi: 10.1017/CBO9780511753794
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # Generate data from a quadratic probit model
set.seed(101)
n <- 2000
x <- runif(n, min = -3, max = 6)
z <- 10 + 3 * x - 1 * x^2 + rnorm(n)
y <- ifelse(z <= 0, yes = 0, no = 1)
# Scatterplot matrix
pairs(~ x + y + z)
# Misspecified mean structure
fm1 <- glm(y ~ x, family = binomial(link = "probit"))
diagnostic.plot(fm1)
# Correctly specified mean structure
fm2 <- glm(y ~ x + I(x ^ 2), family = binomial(link = "probit"))
diagnostic.plot(fm2)
# Load data
data("ANES2016")
PAsso_1 <- PAsso(responses = c("PreVote.num", "PID"),
adjustments = c("income.num", "age", "edu.year"),
data = ANES2016)
# Compute residuals
res1 <- residuals(PAsso_1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.