[R-sig-ME] Ordered logistic regression with random effects (clmm2)
Daniel Lüdecke
d@|uedecke @end|ng |rom uke@de
Fri Jan 24 19:46:48 CET 2020
Hi Ron,
If you could use "clmm()" instead of "clmm2()", then you could use the
ggeffects-package to calculate predicted probabilities, and either print or
plot the results. Here's an example:
library(ggeffects)
library(ordinal)
model <- clmm(SURENESS ~ PROD * COLD + (1|RESP), data = soup)
pred <- ggpredict(model, c("PROD", "COLD"))
pred
plot(pred)
You can find a comprehensive documentation for the package here:
https://strengejacke.github.io/ggeffects/
Best
Daniel
-----Ursprüngliche Nachricht-----
Von: R-sig-mixed-models <r-sig-mixed-models-bounces using r-project.org> Im
Auftrag von Ronny Steen
Gesendet: Donnerstag, 23. Januar 2020 18:24
An: r-sig-mixed-models using r-project.org
Betreff: [R-sig-ME] Ordered logistic regression with random effects (clmm2)
Dear all,
I try to do a ordered logistic regression with random effects. I have tried
clmm2 from package 'ordinal' and manage to run the test, but can not
figure out how to get det predictions and confidence intervals.
We have a small "cafeteria experiment" to check if a bird has dietary
preferences, indicated by free-choice feeding from boxes with food of
different qualities.
More details about the setup:
We have offered Jays three choices of acorns (ordered quality) to see if
they have preferences. Unfortunately we do not have control of their
identity, but we have monitored 5 different places (which is included as
random effect). In the experiment we have video recorded behaviour and
we offered the Jays with 3 boxes with acorns (one box with 5 *intact
*acorns,
one with 5 acorns with *holes* and one with 5 *damaged* acorns). Hence
intact acorns is of highest quality, below is acorns with holes ("infected"
by insect larvae) and lowest is damaged acorns (eaten at by a rodent). Our
hypothesis is that the Jay should prefer the intact acorns since they will
last longer for storage.
The data:
> head(Jay)
State Choice Place Intact_count Hole_count Damaged_count
1 0 Damaged B1 5 5 2
2 0 Damaged B1 5 5 1
3 2 Intact B1 5 5 0
4 2 Intact B1 4 5 0
5 2 Intact B1 3 5 0
6 2 Intact B1 2 5 0
> str(Jay)
'data.frame': 318 obs. of 6 variables:
$ State : Ord.factor w/ 3 levels "0"<"1"<"2": 1 1 3 3 3 3 3 2 2 2
...
$ Choice : Factor w/ 3 levels "Damaged","Holes",..: 1 1 3 3 3 3 3 2
2 2 ...
$ Place : Factor w/ 5 levels "B1","E1","E2",..: 1 1 1 1 1 1 1 1 1 1
...
$ Intact_count : int 5 5 5 4 3 2 1 0 0 0 ...
$ Hole_count : int 5 5 5 5 5 5 5 5 4 3 ...
$ Damaged_count: int 2 1 0 0 0 0 0 0 0 0 ...
State is the ordered Choice (Damaged = 0, Hole = 1 and Intact = 2), Place
is the random effect. Intact_count, Hole_count and Damaged_count is
numeric and gives the information about how many acorns that are in each
box. At the beginning of the day it was 5 acorns in each box, and less as
the Jay collected acorns.
The best model seems to be:
fm3 <- clmm2(State~ Intact_count*Hole_count, random=Place, data=Jay,
Hess=TRUE, nAGQ=10)
> (fm3)
Cumulative Link Mixed Model fitted with the adaptive Gauss-Hermite
quadrature approximation with 10 quadrature points
Call:
clmm2(location = State ~ Intact_count * Hole_count, random = Place,
data = Jay, Hess = TRUE, nAGQ = 10)
Random effects:
Var Std.Dev
Place 9.486096e-09 9.739659e-05
Location coefficients:
Intact_count Hole_count Intact_count:Hole_count
1.6015787 0.8237153 -0.3237785
No Scale coefficients
Threshold coefficients:
0|1 1|2
1.458473 3.826715
log-likelihood: -258.4659
AIC: 528.9318
I would like to get predicted probabilities with confidence intervals. What
is the probability of choosing a intact vs. holes vs. damaged. How does
this vary with Intact_count, Hole_count (e.g. Intact_count = 1, 3 or 5,
Hole_count = 1, 3, 5)?
Best regards,
Ron
[[alternative HTML version deleted]]
_______________________________________________
R-sig-mixed-models using r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
--
_____________________________________________________________________
Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Burkhard Göke (Vorsitzender), Prof. Dr. Dr. Uwe Koch-Gromus, Joachim Prölß, Marya Verdel
_____________________________________________________________________
SAVE PAPER - THINK BEFORE PRINTING
More information about the R-sig-mixed-models
mailing list