Question: Help programming in R Employees started the program at different times throughout the year, but everyone in the data set started the program sometime in
Help programming in R
Employees started the program at different times throughout the year, but everyone in the data set started the program sometime in 2013. Each employees baseline stress level was measured at the beginning of 2013, and again at three random points over the course of 2013. The variables in this dataset are:employee.ID employee ID (Level-2 indicator variable);month time (# of months) since the company began recruiting for the exercise program; exercise Whether the employee had started the program (1) or not (0) by that month; stress Stress level at the time (month) of measurement (0100 scale)
1. Run an ordinary regression model by predicting stress with exercise (and an intercept), use the summary function in R to get the results and interpret the slope and the intercept.
Now look at the data again, do you think this data set violate the independency assumption? Why or why not? What is the format of the data? (long format or wide format)
Download the file MLM.employ.exercise.dat and import it into R: dat <- read.table("MLM.employ.exercise.dat", header = TRUE)
MLM.employ.exercise.dat:
employee.ID month exercise stress 1 0 0 85 1 1 0 79 1 7 1 68 1 9 1 73 2 0 0 50 2 1 1 64 2 8 1 39 2 9 1 32 3 0 0 90 3 2 0 72 3 6 1 58 3 9 1 63 4 0 0 86 4 4 0 87 4 5 0 85 4 11 1 46 5 0 0 75 5 3 0 60 5 5 1 60 5 11 1 55 6 0 0 63 6 1 1 67 6 7 1 48 6 12 1 45 7 0 0 69 7 2 1 65 7 7 1 65 7 9 1 58 8 0 0 83 8 2 0 67 8 6 1 62 8 11 1 56 9 0 0 81 9 4 0 68 9 7 0 60 9 9 1 64 10 0 0 75 10 3 0 74 10 5 0 65 10 9 1 59 11 0 0 82 11 3 0 58 11 8 0 64 11 11 1 51 12 0 0 69 12 4 1 67 12 5 1 63 12 12 1 39 13 0 0 73 13 4 1 77 13 5 1 67 13 10 1 62 14 0 0 81 14 3 0 71 14 7 0 74 14 10 1 61 15 0 0 61 15 4 1 56 15 5 1 68 15 9 1 41 16 0 0 61 16 1 1 64 16 6 1 53 16 12 1 40 17 0 0 63 17 1 0 75 17 5 0 73 17 12 1 56 18 0 0 77 18 2 0 71 18 8 0 51 18 12 1 53 19 0 0 87 19 2 0 88 19 5 1 78 19 11 1 46 20 0 0 88 20 2 0 82 20 8 0 84 20 10 1 54 21 0 0 75 21 4 1 73 21 8 1 56 21 9 1 55 22 0 0 68 22 2 0 74 22 6 1 49 22 12 1 48 23 0 0 77 23 3 0 80 23 5 1 62 23 11 1 67 24 0 0 66 24 4 0 56 24 5 1 35 24 10 1 57 25 0 0 82 25 4 0 82 25 8 1 49 25 10 1 60 26 0 0 64 26 4 0 89 26 8 1 58 26 10 1 60 27 0 0 91 27 1 1 80 27 6 1 61 27 11 1 58 28 0 0 90 28 3 1 53 28 7 1 43 28 9 1 57 29 0 0 65 29 3 1 77 29 6 1 58 29 10 1 41 30 0 0 72 30 3 1 62 30 7 1 65 30 10 1 70 31 0 0 85 31 1 0 96 31 6 1 57 31 10 1 75 32 0 0 89 32 2 0 78 32 7 0 70 32 9 1 68 33 0 0 71 33 2 0 61 33 8 1 71 33 12 1 54 34 0 0 78 34 3 0 70 34 5 1 64 34 11 1 55 35 0 0 66 35 3 0 74 35 8 0 62 35 11 1 42 36 0 0 80 36 3 1 67 36 7 1 61 36 9 1 46 37 0 0 74 37 1 1 58 37 6 1 59 37 11 1 36 38 0 0 62 38 1 0 52 38 7 0 51 38 12 1 57 39 0 0 75 39 2 0 69 39 8 0 92 39 11 1 35 40 0 0 63 40 4 0 68 40 5 1 52 40 11 1 30 41 0 0 77 41 3 1 54 41 5 1 59 41 11 1 55 42 0 0 93 42 1 0 88 42 7 0 94 42 10 1 62 43 0 0 85 43 2 1 67 43 6 1 58 43 10 1 76 44 0 0 86 44 4 0 99 44 5 1 77 44 9 1 51 45 0 0 60 45 4 0 73 45 7 0 57 45 12 1 57 46 0 0 73 46 2 1 64 46 6 1 72 46 10 1 57 47 0 0 79 47 2 0 67 47 8 0 67 47 10 1 47 48 0 0 83 48 4 0 88 48 7 1 84 48 11 1 81 49 0 0 63 49 1 1 57 49 5 1 63 49 11 1 49 50 0 0 73 50 2 0 81 50 5 1 61 50 12 1 48
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
