tests/polr.R

pkgs <- c("free1way.docreg", "coin", "MASS", "tram")
if (!all(sapply(pkgs, require, character.only = TRUE)))
    quit()

options(digits = 5)
set.seed(29)

N <- 25
x <- gl(2, N, labels = c("A", "B"))
y <- rlogis(length(x), location = c(0, 1)[x])
y <- cut(y, breaks = c(-Inf, -1, 0, 1, Inf), ordered_result = TRUE)

ci <- confint(m <- polr(y ~ x, method = "logistic"))
c(coef(m)["xB"], ci)
logLik(m)
summary(m)
#score_test(m, parm = "xB")

m <- Polr(y ~ x, method = "logistic")
coef(m)
logLik(m)
summary(m)
score_test(m, parm = "xB")
ft <- free1way(y = y, groups = x, B = 10000)
coef(ft)
logLik(ft)
print(ft, test = "Rao")
confint(ft, test = "Rao")
perm_test(m, parm = "xB", distribution = approximate(nresample = 10000))
print(ft, test = "Permutation")
confint(ft, test = "Permutation")

ci <- confint(m <- polr(y ~ x, method = "cloglog"))
c(coef(m)["xB"], ci)
logLik(m)
summary(m)
m <- Polr(y ~ x, method = "cloglog")
coef(m)
logLik(m)
summary(m)
score_test(m, parm = "xB")
ft <- free1way(y = y, groups = x, link = "cloglog", B = 10000)
coef(ft)
logLik(ft)
print(ft, test = "Rao")
confint(ft, test = "Rao")
perm_test(m, parm = "xB", distribution = approximate(nresample = 10000))
print(ft, test = "Permutation")
confint(ft, test = "Permutation")

ci <- confint(m <- polr(y ~ x, method = "loglog"))
c(coef(m)["xB"], ci)
logLik(m)
summary(m)
m <- Polr(y ~ x, method = "loglog")
coef(m)
logLik(m)
summary(m)
score_test(m, parm = "xB")

ft <- free1way(y = y, groups = x, link = "loglog", B = 10000)
coef(ft)
logLik(ft)
print(ft, test = "Rao")
confint(ft, test = "Rao")
perm_test(m, parm = "xB", distribution = approximate(nresample = 10000))
print(ft, test = "Permutation")
confint(ft, test = "Permutation")

ci <- confint(m <- polr(y ~ x, method = "probit"))
c(coef(m)["xB"], ci)
logLik(m)
summary(m)

m <- Polr(y ~ x, method = "probit")
coef(m)
logLik(m)
score_test(m, parm = "xB")
summary(m)
ft <- free1way(y = y, groups = x, link = "probit", B = 10000)
coef(ft)
logLik(ft)
print(ft, test = "Rao")
confint(ft, test = "Rao")
perm_test(m, parm = "xB", distribution = approximate(nresample = 10000))
print(ft, test = "Permutation")
confint(ft, test = "Permutation")

Try the free1way.docreg package in your browser

Any scripts or data that you put into this service are public.

free1way.docreg documentation built on May 12, 2026, 3 p.m.