-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnested_fully-crossed_cross-classified_models.R
More file actions
33 lines (22 loc) · 1.13 KB
/
Copy pathnested_fully-crossed_cross-classified_models.R
File metadata and controls
33 lines (22 loc) · 1.13 KB
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
# Nested and Crossed Random Effects Models ----
# Say we have a model with a dependent variable "DV", independent variable "IV"
# and groups as random effects ("Cluster", "Subject"). The "IV" varies accross
# "Cluster" and "Subject".
#
# Is this a nested, fully crossed or cross-classified design?
#
# Nested design ----
#
# The key distinction is whether each "Subject" receives a completely
# different "Cluster" set. If this is the case the design is nested,
# which simply means: not crossed.
lmer(DV ~ IV + (1 + IV | Cluster / Subject), data = ...)
# which expands to...
lmer(DV ~ IV + (1 + IV | Cluster ) + (1 + IV | Cluster:Subject), data = ...)
# Fully-crossed or cross-classified models ----
# If each "Subject" receives the same "Cluster", it is a fully crossed
# random factors design. If there is some mixture it is cross-classified.
# The appropriate model notation for a crossed design would be:
lmer(DV ~ IV + (1 + IV | Cluster) + (1 + IV | Subject), data = ...)
# related post: https://www.researchgate.net/post/Multilevel_modelling_in_R
# see also: https://stats.stackexchange.com/a/228814/54740