R Under development (unstable) (2023-12-02 r85657 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(ordinal) > > ################################# > ## 1 categorical variable in nominal: > fm <- clm(rating ~ temp, nominal=~contact, data=wine) > fm$Theta contact 1|2 2|3 3|4 4|5 1 no -1.323043 1.2464435 3.550044 4.660247 2 yes -2.938103 -0.2651238 1.875288 3.609624 > fm$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -1.323043 1.246444 3.550044 4.660247 contactyes -1.615059 -1.511567 -1.674756 -1.050623 > ## Threshold effects: > fm <- clm(rating ~ temp, nominal=~contact, data=wine, + threshold="symmetric") > fm$Theta contact 1|2 2|3 3|4 4|5 1 no -1.054279 1.083892 3.383980 5.522152 2 yes -2.360683 -0.356889 1.753317 3.757111 > fm$alpha.mat central.1 central.2 spacing.1 (Intercept) 1.083892 3.383980 2.1381713 contactyes -1.440781 -1.630663 -0.1343777 > fm <- clm(rating ~ temp, nominal=~contact, data=wine, + threshold="equidistant") > fm$Theta contact 1|2 2|3 3|4 4|5 1 no -1.089140 1.1176064 3.324353 5.531099 2 yes -2.386361 -0.3365063 1.713348 3.763202 > fm$alpha.mat threshold.1 spacing (Intercept) -1.08914 2.2067465 contactyes -1.29722 -0.1568922 > ## Singular fit is still ok (with a warning, though) > fm <- clm(rating ~ contact, nominal=~temp, data=wine) Warning message: (1) Hessian is numerically singular: parameters are not uniquely determined In addition: Absolute convergence criterion was met, but relative criterion was not met > fm$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -1.265638 1.104045 3.765661 24.89643 tempwarm -21.095417 -2.153024 -2.873317 -22.55000 > fm$Theta temp 1|2 2|3 3|4 4|5 1 cold -1.265638 1.104045 3.7656606 24.896432 2 warm -22.361055 -1.048979 0.8923431 2.346436 > > ################################# > ## 1 continuous variable: > set.seed(123) > x <- rnorm(nrow(wine), sd=1) > fm <- clm(rating ~ temp, nominal=~ x, data=wine) > fm$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -1.93392115 0.4251062 2.4798775 3.9190335 x 0.09463825 0.3805713 0.4261607 0.3809099 > fm$Theta 1|2 2|3 3|4 4|5 1 -1.933921 0.4251062 2.479878 3.919034 > fm <- clm(rating ~ temp, nominal=~ poly(x, 2), data=wine) > fm$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -1.9310988 0.4469436 2.517523 4.094448 poly(x, 2)1 0.8763914 3.2908002 3.471603 4.422045 poly(x, 2)2 -0.3826811 0.2518184 -2.064209 5.810095 > fm$Theta 1|2 2|3 3|4 4|5 1 -1.931099 0.4469436 2.517523 4.094448 > > ################################# > ## 1 categorical + 1 continuous variable: > set.seed(123) > x <- rnorm(nrow(wine), sd=1) > fm <- clm(rating ~ temp, nominal=~contact + x, data=wine) > fm$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -1.279484 1.2782515 3.612766 4.7496630 contactyes -1.770377 -1.6715296 -1.647335 -0.9575417 x 0.300792 0.5330593 0.351517 0.3320371 > fm$Theta contact 1|2 2|3 3|4 4|5 1 no -1.279484 1.2782515 3.612766 4.749663 2 yes -3.049860 -0.3932781 1.965431 3.792121 > fm <- clm(rating ~ temp, nominal=~contact + x, data=wine, + threshold="symmetric") > fm$alpha.mat central.1 central.2 spacing.1 (Intercept) 1.1195535 3.4384752 2.134429723 contactyes -1.5864032 -1.5904314 -0.007568099 x 0.5069573 0.3485632 0.137951085 > fm$Theta contact 1|2 2|3 3|4 4|5 1 no -1.014876 1.1195535 3.438475 5.572905 2 yes -2.593711 -0.4668497 1.848044 3.974905 > ################################# > ### NOTE: To get the by-threshold nominal effects of continuous terms > ## use: > with(fm, t(apply(alpha.mat, 1, function(th) tJac %*% th))) [,1] [,2] [,3] [,4] (Intercept) -1.0148763 1.1195535 3.4384752 5.5729049 contactyes -1.5788351 -1.5864032 -1.5904314 -1.5979995 x 0.3690062 0.5069573 0.3485632 0.4865143 > ################################# > ## Interactions: > fm <- clm(rating ~ temp, nominal=~contact:x, data=wine) > fm$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -1.9577944 0.5997213 2.6863244 4.1510613 contactno:x 0.1127629 0.7818026 0.4423216 0.9364319 contactyes:x 0.2129232 -0.2720801 0.3848893 0.1730418 > fm$Theta 1|2 2|3 3|4 4|5 1 -1.957794 0.5997213 2.686324 4.151061 > fm <- clm(rating ~ temp, nominal=~contact+x+contact:x, data=wine) > fm$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -1.3000385 1.4056290 3.8340494 5.195521 contactyes -2.2801110 -1.5685386 -1.7308097 -1.318630 x 0.1790630 0.8754972 0.5140440 1.061857 contactyes:x 0.7541913 -0.8829449 -0.2203363 -1.055090 > fm$Theta contact 1|2 2|3 3|4 4|5 1 no -1.300039 1.4056290 3.834049 5.195521 2 yes -3.580150 -0.1629096 2.103240 3.876891 > fm <- clm(rating ~ temp, nominal=~contact*x, data=wine) > fm$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -1.3000385 1.4056290 3.8340494 5.195521 contactyes -2.2801110 -1.5685386 -1.7308097 -1.318630 x 0.1790630 0.8754972 0.5140440 1.061857 contactyes:x 0.7541913 -0.8829449 -0.2203363 -1.055090 > fm$Theta contact 1|2 2|3 3|4 4|5 1 no -1.300039 1.4056290 3.834049 5.195521 2 yes -3.580150 -0.1629096 2.103240 3.876891 > ## polynomial terms: > fm <- clm(rating ~ temp, nominal=~contact + poly(x, 2), data=wine) > fm$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -1.2704762 1.3058436 3.635351 4.984803 contactyes -1.7725959 -1.6863567 -1.668402 -1.045016 poly(x, 2)1 2.4660191 4.4257770 3.395876 4.572499 poly(x, 2)2 -0.5079931 -0.4326472 -2.815490 5.853814 > fm$Theta contact 1|2 2|3 3|4 4|5 1 no -1.270476 1.3058436 3.635351 4.984803 2 yes -3.043072 -0.3805131 1.966949 3.939787 > ## logical variables: (treated like numeric variables) > wine$Con <- as.character(wine$contact) == "yes" > fm <- clm(rating ~ temp, nominal=~Con, data=wine) > fm$Theta 1|2 2|3 3|4 4|5 1 -1.323043 1.246444 3.550044 4.660247 > fm$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -1.323043 1.246444 3.550044 4.660247 ConTRUE -1.615059 -1.511567 -1.674756 -1.050623 > wine$Con.num <- 1 * wine$Con > fm <- clm(rating ~ temp, nominal=~Con.num, data=wine) > fm$Theta 1|2 2|3 3|4 4|5 1 -1.323043 1.246444 3.550044 4.660247 > fm$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -1.323043 1.246444 3.550044 4.660247 Con.num -1.615059 -1.511567 -1.674756 -1.050623 > ################################# > ## Two continuous variables: > set.seed(321) > y <- rnorm(nrow(wine), sd=1) > fm1 <- clm(rating ~ temp, nominal=~y + x, data=wine) > fm1$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -2.0361734 0.4221202 2.4970718 3.92796873 y 0.4687950 0.1396038 0.3125431 0.08012751 x 0.1283933 0.3903469 0.4322374 0.37584062 > fm1$Theta 1|2 2|3 3|4 4|5 1 -2.036173 0.4221202 2.497072 3.927969 > ## summary(fm1) > > ################################# > ## 1 categorical + 2 continuous variables: > fm1 <- clm(rating ~ temp, nominal=~y + contact + x, data=wine) > fm1$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -1.3789903 1.2645381 3.5778844 4.76356985 y 0.4385042 0.1049073 0.2439721 -0.01655843 contactyes -1.7688345 -1.6608152 -1.5801690 -0.98076349 x 0.3414184 0.5436276 0.3683201 0.33263316 > fm1$Theta contact 1|2 2|3 3|4 4|5 1 no -1.378990 1.2645381 3.577884 4.763570 2 yes -3.147825 -0.3962771 1.997715 3.782806 > > fm1 <- clm(rating ~ temp, nominal=~contact + x + contact:x + y, + data=wine) > summary(fm1) formula: rating ~ temp nominal: ~contact + x + contact:x + y data: wine link threshold nobs logLik AIC niter max.grad cond.H logit flexible 72 -81.86 205.72 7(0) 6.30e-12 9.3e+01 Coefficients: Estimate Std. Error z value Pr(>|z|) tempwarm 2.8541 0.6159 4.634 3.58e-06 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Threshold coefficients: Estimate Std. Error z value 1|2.(Intercept) -1.40166 0.63306 -2.214 2|3.(Intercept) 1.38723 0.49672 2.793 3|4.(Intercept) 3.78725 0.71352 5.308 4|5.(Intercept) 5.19478 1.07162 4.848 1|2.contactyes -2.25974 1.68593 -1.340 2|3.contactyes -1.54343 0.62658 -2.463 3|4.contactyes -1.65472 0.68161 -2.428 4|5.contactyes -1.34417 1.10192 -1.220 1|2.x 0.21217 0.60781 0.349 2|3.x 0.88433 0.41592 2.126 3|4.x 0.47072 0.57857 0.814 4|5.x 0.98582 0.94345 1.045 1|2.y 0.41959 0.59889 0.701 2|3.y 0.08377 0.27912 0.300 3|4.y 0.27724 0.33118 0.837 4|5.y -0.03370 0.59652 -0.056 1|2.contactyes:x 0.71850 1.19479 0.601 2|3.contactyes:x -0.89167 0.68974 -1.293 3|4.contactyes:x -0.10843 0.74237 -0.146 4|5.contactyes:x -0.98243 1.06343 -0.924 > fm1$Theta contact 1|2 2|3 3|4 4|5 1 no -1.401661 1.3872281 3.787248 5.194782 2 yes -3.661402 -0.1562067 2.132530 3.850615 > fm1$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -1.4016606 1.38722808 3.7872478 5.19478152 contactyes -2.2597419 -1.54343480 -1.6547177 -1.34416691 x 0.2121750 0.88432858 0.4707237 0.98581604 y 0.4195947 0.08377343 0.2772447 -0.03369796 contactyes:x 0.7184952 -0.89166532 -0.1084271 -0.98242663 > fm1 <- clm(rating ~ temp, nominal=~contact*x + y, data=wine) > fm1$Theta contact 1|2 2|3 3|4 4|5 1 no -1.401661 1.3872281 3.787248 5.194782 2 yes -3.661402 -0.1562067 2.132530 3.850615 > fm1$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -1.4016606 1.38722808 3.7872478 5.19478152 contactyes -2.2597419 -1.54343480 -1.6547177 -1.34416691 x 0.2121750 0.88432858 0.4707237 0.98581604 y 0.4195947 0.08377343 0.2772447 -0.03369796 contactyes:x 0.7184952 -0.89166532 -0.1084271 -0.98242663 > t(fm1$alpha.mat) (Intercept) contactyes x y contactyes:x 1|2 -1.401661 -2.259742 0.2121750 0.41959467 0.7184952 2|3 1.387228 -1.543435 0.8843286 0.08377343 -0.8916653 3|4 3.787248 -1.654718 0.4707237 0.27724473 -0.1084271 4|5 5.194782 -1.344167 0.9858160 -0.03369796 -0.9824266 > fm1 formula: rating ~ temp nominal: ~contact * x + y data: wine link threshold nobs logLik AIC niter max.grad cond.H logit flexible 72 -81.86 205.72 7(0) 6.30e-12 9.3e+01 Coefficients: tempwarm 2.854 Threshold coefficients: 1|2 2|3 3|4 4|5 (Intercept) -1.40166 1.38723 3.78725 5.19478 contactyes -2.25974 -1.54343 -1.65472 -1.34417 x 0.21217 0.88433 0.47072 0.98582 y 0.41959 0.08377 0.27724 -0.03370 contactyes:x 0.71850 -0.89167 -0.10843 -0.98243 > > ################################# > ## ordered factors (behaves like numerical variables): > data(soup, package="ordinal") > fm2 <- clm(SURENESS ~ 1, nominal=~PRODID + DAY, data=soup) > fm2$Theta PRODID DAY 1|2 2|3 3|4 4|5 5|6 1 1 1 -1.541481 -0.5738506 -0.21399538 0.04222703 0.75684062 2 2 1 -2.260759 -1.5442697 -1.21890789 -0.91689299 -0.24659733 3 3 1 -2.662588 -1.8500284 -1.67612929 -1.15745279 -0.65265582 4 4 1 -2.230317 -1.3875834 -1.10527201 -0.70760465 -0.16454916 5 5 1 -2.291960 -1.8870049 -1.51852627 -1.32708454 -0.64222204 6 6 1 -2.765844 -2.1222058 -1.93080891 -1.76177831 -0.87239437 7 1 2 -1.497366 -0.2765643 0.08617449 0.27652240 0.97863135 8 2 2 -2.216645 -1.2469835 -0.91873802 -0.68259762 -0.02480661 9 3 2 -2.618473 -1.5527421 -1.37595942 -0.92315742 -0.43086509 10 4 2 -2.186203 -1.0902972 -0.80510215 -0.47330927 0.05724157 11 5 2 -2.247845 -1.5897187 -1.21835640 -1.09278917 -0.42043131 12 6 2 -2.721729 -1.8249196 -1.63063905 -1.52748294 -0.65060365 > fm2$alpha.mat 1|2 2|3 3|4 4|5 5|6 (Intercept) -1.54148084 -0.5738506 -0.2139954 0.04222703 0.7568406 PRODID2 -0.71927809 -0.9704192 -1.0049125 -0.95912001 -1.0034380 PRODID3 -1.12110698 -1.2761778 -1.4621339 -1.19967981 -1.4094964 PRODID4 -0.68883656 -0.8137329 -0.8912766 -0.74983167 -0.9213898 PRODID5 -0.75047874 -1.3131544 -1.3045309 -1.36931157 -1.3990627 PRODID6 -1.22436292 -1.5483553 -1.7168135 -1.80400534 -1.6292350 DAY2 0.04411439 0.2972862 0.3001699 0.23429537 0.2217907 > prodid <- factor(soup$PRODID, ordered=TRUE) > fm2 <- clm(SURENESS ~ 1, nominal=~prodid + DAY, data=soup) > fm2$alpha.mat 1|2 2|3 3|4 4|5 5|6 (Intercept) -2.29215806 -1.5608238 -1.2772733 -0.9714310 -0.3035963 prodid.L -0.69121817 -0.9929406 -1.0651956 -1.1714141 -1.0571728 prodid.Q 0.28234300 0.3165731 0.3424949 0.1207237 0.3905959 prodid.C -0.56889235 -0.5360906 -0.6536897 -0.5924148 -0.5462885 prodid^4 -0.08220340 0.2121409 0.0953785 0.2423256 0.1732012 prodid^5 0.20500444 0.3017272 0.3458281 0.2989342 0.3294562 DAY2 0.04411439 0.2972862 0.3001699 0.2342954 0.2217907 > fm2$Theta DAY 1|2 2|3 3|4 4|5 5|6 1 1 -2.292158 -1.560824 -1.2772733 -0.9714310 -0.30359635 2 2 -2.248044 -1.263538 -0.9771034 -0.7371357 -0.08180562 > fm2 <- clm(SURENESS ~ 1, nominal=~prodid, data=soup) > fm2$alpha.mat 1|2 2|3 3|4 4|5 5|6 (Intercept) -2.2615449 -1.4231189 -1.13844940 -0.8610163 -0.20025662 prodid.L -0.6802192 -1.0171675 -1.08713192 -1.1713363 -1.05578526 prodid.Q 0.2551357 0.3521163 0.37511177 0.1651463 0.43182970 prodid.C -0.6064464 -0.5635065 -0.68182671 -0.6050149 -0.55490977 prodid^4 -0.1115795 0.1036958 -0.01443457 0.1577696 0.09355651 prodid^5 0.2349647 0.4222560 0.46856405 0.3867234 0.41280490 > fm2$Theta 1|2 2|3 3|4 4|5 5|6 1 -2.261545 -1.423119 -1.138449 -0.8610163 -0.2002566 > ################################# > ## Aliased Coefficients: > ## > ## Example where the interaction in the nominal effects is aliased (by > ## design). Here the two Theta matrices coincide. The alpha.mat > ## matrices are similar except one has an extra row with NAs: > soup2 <- soup > levels(soup2$DAY) [1] "1" "2" > levels(soup2$GENDER) [1] "Male" "Female" > xx <- with(soup2, DAY == "2" & GENDER == "Female") > ## Model with additive nominal effects: > fm8 <- clm(SURENESS ~ PRODID, nominal= ~ DAY + GENDER, data=soup2, subset=!xx) > fm8$alpha.mat 1|2 2|3 3|4 4|5 5|6 (Intercept) -1.5296912 -0.68765358 -0.3255117394 0.03773041 0.629325973 DAY2 -0.2553049 0.08584421 0.1101987830 0.05149732 0.168514829 GENDERFemale 0.0790841 0.07464904 -0.0001589362 -0.11045608 -0.005418789 > fm8$Theta DAY GENDER 1|2 2|3 3|4 4|5 5|6 1 1 Male -1.529691 -0.6876536 -0.3255117 0.03773041 0.6293260 2 2 Male -1.784996 -0.6018094 -0.2153130 0.08922773 0.7978408 3 1 Female -1.450607 -0.6130045 -0.3256707 -0.07272568 0.6239072 4 2 Female -1.705912 -0.5271603 -0.2154719 -0.02122835 0.7924220 > ## Model with non-additive, but aliased nominal effects: > fm9 <- clm(SURENESS ~ PRODID, nominal= ~ DAY * GENDER, data=soup2, subset=!xx) > fm9$alpha.mat 1|2 2|3 3|4 4|5 5|6 (Intercept) -1.5296912 -0.68765358 -0.3255117394 0.03773041 0.629325973 DAY2 -0.2553049 0.08584421 0.1101987830 0.05149732 0.168514829 GENDERFemale 0.0790841 0.07464904 -0.0001589362 -0.11045608 -0.005418789 DAY2:GENDERFemale NA NA NA NA NA > fm9$Theta DAY GENDER 1|2 2|3 3|4 4|5 5|6 1 1 Male -1.529691 -0.6876536 -0.3255117 0.03773041 0.6293260 2 2 Male -1.784996 -0.6018094 -0.2153130 0.08922773 0.7978408 3 1 Female -1.450607 -0.6130045 -0.3256707 -0.07272568 0.6239072 4 2 Female -1.705912 -0.5271603 -0.2154719 -0.02122835 0.7924220 > > stopEqual <- function(x, y, ca=FALSE) + stopifnot(isTRUE(all.equal(x, y, check.attributes=ca))) > > stopEqual(fm8$alpha.mat, fm9$alpha.mat[1:3, ]) > stopEqual(fm8$Theta, fm9$Theta) > stopEqual(logLik(fm8), logLik(fm9)) > > ################################# > ## Weights: > set.seed(12345) > wts <- runif(nrow(soup)) > fm2 <- clm(SURENESS ~ 1, nominal=~SOUPTYPE + DAY, data=soup, weights=wts) > fm2$Theta SOUPTYPE DAY 1|2 2|3 3|4 4|5 5|6 1 Self-made 1 -1.957136 -1.2051740 -0.8829317 -0.6651699 -0.03270025 2 Canned 1 -1.665918 -0.9408556 -0.6818962 -0.4277315 0.14356406 3 Dry-mix 1 -2.180024 -1.2221288 -1.1502087 -0.8113657 -0.24840514 4 Self-made 2 -1.988269 -0.9456030 -0.5614139 -0.3852570 0.23978932 5 Canned 2 -1.697051 -0.6812846 -0.3603783 -0.1478186 0.41605363 6 Dry-mix 2 -2.211157 -0.9625577 -0.8286909 -0.5314528 0.02408443 > > ## Offset (correctly gives and error) > fm2 <- try(clm(SURENESS ~ 1, nominal=~SOUPTYPE + DAY + offset(wts), + data=soup), silent=TRUE) > stopifnot(inherits(fm2, "try-error")) > > ################################# > ### Other (misc) examples: > fm2 <- clm(SURENESS ~ 1, nominal=~SOUPTYPE + DAY, data=soup) > fm2$Theta SOUPTYPE DAY 1|2 2|3 3|4 4|5 5|6 1 Self-made 1 -2.040111 -1.2615146 -0.9302684 -0.6740629 -0.05003069 2 Canned 1 -1.816274 -1.0347697 -0.7305192 -0.4563265 0.15972072 3 Dry-mix 1 -2.313198 -1.3029029 -1.1328903 -0.8076982 -0.23529457 4 Self-made 2 -1.956698 -0.9371883 -0.5968669 -0.4131354 0.21403949 5 Canned 2 -1.732861 -0.7104435 -0.3971177 -0.1953990 0.42379090 6 Dry-mix 2 -2.229785 -0.9785767 -0.7994888 -0.5467707 0.02877561 > fm2 formula: SURENESS ~ 1 nominal: ~SOUPTYPE + DAY data: soup link threshold nobs logLik AIC niter max.grad cond.H logit flexible 1847 -2758.02 5556.03 6(2) 1.77e-11 8.7e+02 Threshold coefficients: 1|2 2|3 3|4 4|5 5|6 (Intercept) -2.04011 -1.26151 -0.93027 -0.67406 -0.05003 SOUPTYPECanned 0.22384 0.22674 0.19975 0.21774 0.20975 SOUPTYPEDry-mix -0.27309 -0.04139 -0.20262 -0.13364 -0.18526 DAY2 0.08341 0.32433 0.33340 0.26093 0.26407 > fm2 <- clm(SURENESS ~ 1, nominal=~SOUPTYPE * DAY, data=soup) > fm2$Theta SOUPTYPE DAY 1|2 2|3 3|4 4|5 5|6 1 Self-made 1 -2.062794 -1.3083328 -0.9935434 -0.7187896 -0.05107493 2 Canned 1 -1.757074 -0.9398212 -0.6286087 -0.3721287 0.15415068 3 Dry-mix 1 -2.369525 -1.3618033 -1.1700713 -0.8661663 -0.23795864 4 Self-made 2 -1.945910 -0.9005649 -0.5459555 -0.3731219 0.21392690 5 Canned 2 -1.775759 -0.7985077 -0.4924765 -0.2776317 0.43428555 6 Dry-mix 2 -2.182299 -0.9257695 -0.7649729 -0.4964369 0.02702867 > fm2 formula: SURENESS ~ 1 nominal: ~SOUPTYPE * DAY data: soup link threshold nobs logLik AIC niter max.grad cond.H logit flexible 1847 -2755.60 5571.21 6(2) 1.76e-11 4.9e+03 Threshold coefficients: 1|2 2|3 3|4 4|5 5|6 (Intercept) -2.063e+00 -1.308e+00 -9.935e-01 -7.188e-01 -5.107e-02 SOUPTYPECanned 3.057e-01 3.685e-01 3.649e-01 3.467e-01 2.052e-01 SOUPTYPEDry-mix -3.067e-01 -5.347e-02 -1.765e-01 -1.474e-01 -1.869e-01 DAY2 1.169e-01 4.078e-01 4.476e-01 3.457e-01 2.650e-01 SOUPTYPECanned:DAY2 -1.356e-01 -2.665e-01 -3.115e-01 -2.512e-01 1.513e-02 SOUPTYPEDry-mix:DAY2 7.034e-02 2.827e-02 -4.249e-02 2.406e-02 -1.452e-05 > fm2$alpha.mat 1|2 2|3 3|4 4|5 (Intercept) -2.06279431 -1.30833282 -0.99354336 -0.71878961 SOUPTYPECanned 0.30572040 0.36851159 0.36493470 0.34666092 SOUPTYPEDry-mix -0.30673027 -0.05347052 -0.17652789 -0.14737673 DAY2 0.11688416 0.40776793 0.44758789 0.34566775 SOUPTYPECanned:DAY2 -0.13556938 -0.26645440 -0.31145572 -0.25117080 SOUPTYPEDry-mix:DAY2 0.07034149 0.02826594 -0.04248955 0.02406171 5|6 (Intercept) -5.107493e-02 SOUPTYPECanned 2.052256e-01 SOUPTYPEDry-mix -1.868837e-01 DAY2 2.650018e-01 SOUPTYPECanned:DAY2 1.513304e-02 SOUPTYPEDry-mix:DAY2 -1.451666e-05 > fm2 <- clm(SURENESS ~ 1, nominal=~SOUPTYPE * DAY, data=soup, + threshold="symmetric") > fm2$Theta SOUPTYPE DAY 1|2 2|3 3|4 4|5 5|6 1 Self-made 1 -2.023473 -1.3261580 -1.0328445 -0.7395310 -0.04221610 2 Canned 1 -1.650803 -1.0121961 -0.7301243 -0.4480525 0.19055466 3 Dry-mix 1 -2.214507 -1.4643357 -1.2132431 -0.9621504 -0.21197912 4 Self-made 2 -1.757994 -1.0009894 -0.7422397 -0.4834900 0.27351461 5 Canned 2 -1.673970 -0.8581393 -0.5997040 -0.3412687 0.47456211 6 Dry-mix 2 -1.899340 -1.1167968 -0.9013722 -0.6859476 0.09659551 > fm2$alpha.mat central spacing.1 spacing.2 (Intercept) -1.03284450 0.293313471 0.99062841 SOUPTYPECanned 0.30272022 -0.011241697 -0.06994946 SOUPTYPEDry-mix -0.18039855 -0.042220836 0.01063552 DAY2 0.29060480 -0.034563797 0.02512591 SOUPTYPECanned:DAY2 -0.16018453 0.010927306 0.12846128 SOUPTYPEDry-mix:DAY2 0.02126607 -0.001104241 -0.02842214 > > ################################# > ### Check correctness of Theta matrix when intercept is removed in > ### nominal formula: > ### December 25th 2014, RHBC > fm1 <- clm(rating ~ temp, nominal=~contact-1, data=wine) Warning message: an intercept is needed and assumed in 'nominal' > fm2 <- clm(rating ~ temp, nominal=~contact, data=wine) > stopifnot(isTRUE(all.equal(fm1$Theta, fm2$Theta))) > stopifnot(isTRUE(all.equal(fm1$logLik, fm2$logLik))) > wine2 <- wine > wine2$contact <- relevel(wine2$contact, "yes") > fm3 <- clm(rating ~ temp, nominal=~contact, data=wine2) > stopifnot(isTRUE(all.equal(coef(fm1, na.rm=TRUE), coef(fm3)))) > ################################# > > > proc.time() user system elapsed 2.51 0.42 2.92