R/mass-polr-tidiers.R
, R/ordinal-tidiers.R
, R/survey-tidiers.R
ordinal_tidiers.Rd
These methods tidy the coefficients of ordinal logistic regression
models generated by ordinal::clm()
or ordinal::clmm()
of the ordinal
package, MASS::polr()
of the MASS
packge, or survey::svyolr()
of the survey
package.
# S3 method for polr tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, quick = FALSE, ...) # S3 method for polr glance(x, ...) # S3 method for polr augment(x, data = stats::model.frame(x), newdata, type.predict = c("probs", "class"), ...) # S3 method for clm tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, quick = FALSE, conf.type = c("profile", "Wald"), ...) # S3 method for clmm tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, quick = FALSE, conf.type = c("profile", "Wald"), ...) # S3 method for clm glance(x, ...) # S3 method for clmm glance(x, ...) # S3 method for clm augment(x, data = stats::model.frame(x), newdata, type.predict = c("prob", "class"), ...) # S3 method for svyolr tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, quick = FALSE, ...) # S3 method for svyolr glance(x, ...)
x | a model of class |
---|---|
conf.int | whether to include a confidence interval |
conf.level | confidence level of the interval, used only if
|
exponentiate | whether to exponentiate the coefficient estimates and confidence intervals (typical for ordinal logistic regression) |
quick | whether to compute a smaller and faster version, containing only the term, estimate and coefficient_type columns |
... | extra arguments |
data | original data, defaults to the extracting it from the model |
newdata | if provided, performs predictions on the new data |
type.predict | type of prediction to compute for a CLM; passed on to
|
conf.type | the type of confidence interval
(see |
tidy.clm
, tidy.clmm
, tidy.polr
and tidy.svyolr
return one row for each coefficient at each level of the response variable,
with six columns:
term in the model
estimated coefficient
standard error
z-statistic
two-sided p-value
type of coefficient, see ordinal::clm()
the effective degrees of freedom
the data's log-likelihood under the model
the Akaike Information Criterion
the Bayesian Information Criterion
residual degrees of freedom
fitted values of model
standard errors of fitted values
if (require(ordinal)){ clm_mod <- clm(rating ~ temp * contact, data = wine) tidy(clm_mod) tidy(clm_mod, conf.int = TRUE) tidy(clm_mod, conf.int = TRUE, conf.type = "Wald", exponentiate = TRUE) glance(clm_mod) augment(clm_mod) clm_mod2 <- clm(rating ~ temp, nominal = ~ contact, data = wine) tidy(clm_mod2) clmm_mod <- clmm(rating ~ temp + contact + (1 | judge), data = wine) tidy(clmm_mod) glance(clmm_mod) }#>#> Warning: there is no package called ‘ordinal’if (require(MASS)) { polr_mod <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing) tidy(polr_mod, exponentiate = TRUE, conf.int = TRUE) glance(polr_mod) augment(polr_mod, type.predict = "class") }#> # A tibble: 72 x 6 #> Sat Infl Type Cont X.weights. .fitted #> <ord> <fct> <fct> <fct> <int> <dbl> #> 1 Low Low Tower Low 21 1 #> 2 Medium Low Tower Low 21 1 #> 3 High Low Tower Low 28 1 #> 4 Low Medium Tower Low 34 3 #> 5 Medium Medium Tower Low 22 3 #> 6 High Medium Tower Low 36 3 #> 7 Low High Tower Low 10 3 #> 8 Medium High Tower Low 11 3 #> 9 High High Tower Low 36 3 #> 10 Low Low Apartment Low 61 1 #> # … with 62 more rows