Prof Randi Garcia
January 12, 2021
Categorical
Numerical
We assume every observation in a similar condition is affected exactly the same. (Gets the same true score).
For example,
animals_sim <- animals %>%
mutate(benchmark = mean(calm)) %>%
group_by(animal) %>%
mutate(animal_mean = mean(calm),
aminal_effect = animal_mean - benchmark) #every "dog" observation gets the same effect
We add the effects as we go down the assembly line.
All effects are added on.
calm_sim = benchmark
+ aminal_effect
+ cue_effect
+ interaction_effect
+ student_effect
The piece of code for adding error is not dependent on which condition the observations is in. Every condition gets the same standard deviation, here 0.65.
+ rnorm(68, 0, 0.68) #rnorm(n, mean, sd = 0.65)
Takes 68 independent draws from a normal distribution.
+ rnorm(68, 0, 0.68) #rnorm function assumes independence
It's rnorm()
, and not rbinom()
or rpois()
…
+ rnorm(64, 0, 0.68)
The second argument is the mean.
+ rnorm(64, 0, 0.68) #rnorm(n, mean = 0, sd)