##Mixed Models
When we have correlated data structures we want to create random variables, usually denoted μ.
A potential model would look like:
ÿ = β0 + β1χ +… + μ1 + μ2
Where μ are random effects μ ~ N(0,var)
2 main types of random effects: i) crossed random effects ii) nested random effects
example of nested random effects: Each student has 1 teacher, Each teacher has several students, each school has several teachers. y = test scores Students are “nested” with their teacher because we can expect students to test similarly with the same teachers. So, each student will have there own random effect. If μ > 0, we can expect the student to test higher than average.
Crossed Effect example: Salamander example: Two types of salamanders Whiteback and Roughbacks, both males and females and are testing mating.
##Fixed vs Random Effects
There wasn’t much code to write down but a few concepts I want to remember.
Fixed effects are the things you are directly manipulating. Random effects are used if you have multiple measurements on one variable then it should likely be a random variable.
Example: We want to survey 150 dorm rooms at St. Thomas to see how many drinks they have per week. We are testing to see the difference in drinks between upper and under classman. So, our model may look something like this:
Fixed Effects: Upper or underclassman Random effects: Dorm room (we can assume that roomates will have similar drinking patterns)
drinks(hat) = β0 + β1(Upper) + μ(Dorm)
Where, β0 is