Suppose we want to predict performance anxiety based on the type of performance (large ensemble or not). Fit a model that looks at the effects of type of performance (large vs. small/solo), allowing this effect to vary by musician. ```{r} #First convert performance type to a binary variable, just to simplify things a bit initially musicians$performlarge = as.numeric(musicians$perform_type1 == "LargeEnsemble") head(musicians$performlarge) model1 = summary(model1) #install.packages("effects") library(effects) plot(allEffects(model1)) fits1 = fitted.values(model1, level =1) qplot(musicians$performlarge, fits1, group = factor(musicians$subjnum), geom=c("line")) + theme_bw() + geom_abline(intercept=fixef(model1)[1], slope = fixef(model1)[2], color="green") ``` *(f) Explain in plain language what it means for this model to have "random intercepts."*

*(g) What does* $\hat\sigma$ *represent here in this new model? What do the two Level 2 variance components represent?*

*(h) The above graph shows the fitted equations from the multilevel model for each performer. How do you think the graph will differ if we fit a separate line for each performer?*

*(i) Interpret your model output: Do the signs of the coefficients of the fixed effects make sense in context? What do you learn about the effect of large ensemble performances on anxiety? How much of the performance-to-performance variation is explained by the type of performance? How did the intercept variance change? Does this surprise you?*

*(j) Which is larger, the variation in the intercepts or in the slopes? What does that tell you in context?*

*(k) Interpret the slope/intercept correlation in this context. Are the effects "fanning in" or "fanning out"? Or do they cross over? Why does this relationship between slopes and intercepts make sense in context?*

*(l) Write out a (new) model (by level and then composite) that also uses the type of performance (large ensemble or not) with random intercepts and slopes that depend on type of instrument (orchestral or not).*

Fit the model for (l): Make a binary variable for orchestra. Include orchestra, largeperformance, and their interaction as fixed effects, and then random intercepts and random slopes for performance type). ```{r} musicians$orchtype = ifelse(musicians$instrument1 == "orchestralinstrument", 1, 0) model2 = summary(model2, corr=FALSE) plot(allEffects(model2)) fits = fitted.values(model2, level =1) ggplot(musicians, aes(y = fits, x= performlarge, group = factor(subjnum), col=factor(orchtype))) + facet_wrap(~orchtype) + geom_line()+ theme_bw() ``` *(m) Interpret the interaction between performance type and orchestra type in context.*

*(n) How much variability in the intercepts does including type of instrument explain? How much variability in the slopes?*

*How did the estimate of within group variation change?*

*(o) Summarize what you learn about the effect of type of instrument on the intercepts and the slopes.*

*(p) Maybe with the interaction between performance type and instrument type we no longer need the random slopes... Investigate this. Document how you did so (both the model equations and the R code).* ```{r} model2b = anova(model2, model2b) ```