Question: Consider the model Y_ij = mu + b_i + e_ij, where b_i ~ N(0, var1) and e_ij ~N(0,var2). Where i index Z clusters (group/collection of

Consider the model Y_ij = mu + b_i + e_ij, where b_i ~ N(0, var1) and e_ij ~N(0,var2). Where i index Z clusters (group/collection of individuals/units)and the individual measurements made on objects in each cluster indexed by j = 1, . . . n_i.

a) Treat the b_i as a fixed effect (tau_i) and obtain estimates for all mu+tau_i, where i=15

b) provide a graphical summary of the residuals, as well as the between cluster variation observed in the simulated data

c) estimate var1 and var2 using the estimates obtained in a).

Do not use the (summary(lm(....) and lmer(...) functions in R. You will need to be mindful (regardless of whether you do this in R or SAS) about the fixed effect estimates returned by both are for a design matrix coded for control vs. treatment model by default (you can change this). For the lm() function, R chooses the first level to drop (SAS drops the last).

#YOU CAN USE THIS R CODE TO START. Generates balanced data for Z clusters with n observations in each cluster from the provided parameters. Set seed for the data and use the following info: Z=15, n_i = 8, mu = 20, var1 = 3 and var2 = 0.75

dgen<- function(Z, n , var2, var1, mu){errors<- rnorm( Z*n, 0 , var2) bis<- rep(rnorm(Z, 0, var1), each=10) cluster<- rep(paste( "b",1:Z, sep=""), each=n) bilong<- rep(bis, each=n) y<- mu + bis + errors

return(data.frame(cluster,order=1:(Z*n), y) ) }

Please provide solution with all the Rcodes used.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!