1
$\begingroup$

I am trying to examine "homophily" in school students. That is, I am examining whether pairwise similarity in various traits correlates with closeness in social networks.

Each row of my spreadsheet contains data for following columns: child_1_id, child_2_id, social closeness of child_1_id and child_2_id, pairwise similarity in trait of interest of child_1_id and child_2_id. This repeats for all pairwise combinations of children. The simplest form of my model is therefore the following:

trait similarity ~ social closeness + (1 | child_1_id) + (1 | child_2_id)

However, multiple classrooms were included in the study. I would therefore like to nest within classrooms. Importantly, trait similarity and social closeness were only calculated for children in the same classroom as each other, and therefore child_1 and child_2 are always from the same classroom.

How do I go about nesting the crossed random effects for child id within a term for classroom?

$\endgroup$
0

1 Answer 1

1
$\begingroup$

I think you can just add a random effect (1|classroom) to your model, provided your IDs for children are uniquely coded (i.e. your children are coded 1 .. n_children rather than 1 ... n_1, 1 ... n_2, 1 ... n_3, ... where n_i is the number of children in the ith classroom)

If children were not uniquely coded you could use a random effect of the form (1|classroom) + (1|family:child_1_id) + (1|family:child_2_d)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.