Dateianhang 'exercicesmm.r'
Herunterladen 1 ################################### 1 #####################################
2 ## load the data neighborhood.tab using the read.table() command
3
4
5
6
7
8
9
10
11
12
13
14 ## Estimate a linear model on attainment (attain) without
15 ## covariates (null-model), parameter estimates and standard
16 ## errors; interpret the parameter estimates
17
18
19
20
21
22 ## Define a second model, allow for the school random effect (schid).
23 require(lme4)
24
25
26
27
28
29
30 ## What does the output mean? How do you get the corresponding
31 ## parameter to the estimate from the model without random effect?
32 ## Do they differ? Why or why not?
33
34
35 ## visualize the attainment score in different scores using
36 ## an appropriate plot.
37
38 require(ggplot2)
39
40
41
42
43
44
45 ## Add the observed student specific effects
46 ## (gender, verbal reasoning quotient, reading ability).
47 ## How does the magnitude of the school random effect change?
48
49 ## recoding male
50
51
52
53
54
55
56
57
58 ## use neighid instaed of schid and repeat the analysis
59 ## add also the deprivation as covariate.
60
61
62
63
64
65
66 ## What do the results of using e schid or the neighid
67 ## random effects tell you about what effects are needed in the
68 ## modelling of attainment with this data set? ()
69
70
71 ############################# 2 ############################################
72 ## load the data
73
74
75
76 ## how many observations?
77
78
79 ## how many persons?
80
81
82 ## How many rows per person?
83
84
85 ## what is the percentage of black?
86
87
88 ## what the percentage of Hispanic?
89
90
91 ## what is the percentage of married?
92
93
94
95 ## Estimate a logit (binary) model using glm() for trade union
96 ## membership (union), without covariates, obtain parameter
97 ## estimates and standard errors.
98
99
100
101 invlogit <- function(x){ exp(x)/(exp(x) + 1)}
102 invlogit(coef(m2.1))
103
104
105 ## now use the glmer() function (which is the generalized form
106 ## of the lmer() and add the person identifier as random effect.
107 ## How does the estimate change? Is this random effect
108 ## significant? (use confint())
109
110
111
112
113
114
115
116 ## add lwage as a covariate. interpret the coefficients.
117
Gespeicherte Dateianhänge
Um Dateianhänge in eine Seite einzufügen sollte unbedingt eine Angabe wie attachment:dateiname benutzt werden, wie sie auch in der folgenden Liste der Dateien erscheint. Es sollte niemals die URL des Verweises ("laden") kopiert werden, da sich diese jederzeit ändern kann und damit der Verweis auf die Datei brechen würde.Sie dürfen keine Anhänge an diese Seite anhängen!