Similation data

# Fixed intercept
alpha_0 <-  1 # choose a number you like, e.g. 1  



# Fixed slope
beta_0 <- 0.5 #  e.g. 0.5



# Residuals st.dev (level 1) 
sig  <-  1 #  e.g. 1



# Random intercept st.dev (level 2) 
sig_u <-  0.5 #  e.g. 0.5



# Random slope st.dev (level 2)
sig_v <-  0.25 #  e.g. 0.25



# Independent random effects
cor <- 0.5 #  e.g. 0.5

Exercise 1

 COMPLETE POOLING  NO POOLING  NO POOLING + INTERACTION  MULTILEVEL MODEL  MULTILEVEL MODEL + RANDOM SLOPES
(Intercept) 1.353*** 2.218*** 2.382*** 1.356*** 1.343***
(0.128) (0.527) (0.635) (0.160) (0.162)
first_floor 0.443*** 0.538*** 0.777 0.482*** 0.516***
(0.127) (0.130) (0.565) (0.121) (0.145)
clustercluster02 −0.329 −0.463
(0.737) (0.817)
clustercluster03 −1.910* −2.172*
(0.743) (0.858)
clustercluster04 −0.478 −0.872
(0.745) (0.832)
clustercluster05 −1.405+ −1.572+
(0.741) (0.814)
clustercluster06 −0.775 −1.069
(0.735) (1.111)
clustercluster07 0.169 −0.446
(0.747) (0.859)
clustercluster08 −0.575 −1.333
(0.734) (0.834)
clustercluster09 −0.788 −1.212
(0.735) (0.844)
clustercluster10 −1.475+ −1.682*
(0.742) (0.814)
clustercluster11 −0.370 −0.478
(0.737) (0.815)
clustercluster12 −1.760* −2.074*
(0.746) (0.825)
clustercluster13 −2.073** −2.593+
(0.758) (1.427)
clustercluster14 −1.413+ −1.770*
(0.735) (0.832)
clustercluster15 0.080 −0.061
(0.734) (0.855)
clustercluster16 −0.866 −1.115
(0.741) (0.812)
clustercluster17 −1.928* −2.526*
(0.734) (1.148)
clustercluster18 −0.873 −0.773
(0.761) (0.907)
clustercluster19 −0.121 0.180
(0.734) (1.002)
clustercluster20 −0.288 −0.341
(0.743) (0.821)
first_floor × clustercluster02 −0.100
(0.731)
first_floor × clustercluster03 0.208
(1.420)
first_floor × clustercluster04 0.496
(0.825)
first_floor × clustercluster05 −0.218
(0.926)
first_floor × clustercluster06 −0.636
(2.400)
first_floor × clustercluster07 0.935
(0.934)
first_floor × clustercluster08 −1.196+
(0.649)
first_floor × clustercluster09 −1.019
(0.909)
first_floor × clustercluster10 0.049
(0.793)
first_floor × clustercluster11 0.039
(0.721)
first_floor × clustercluster12 0.173
(0.706)
first_floor × clustercluster13 0.217
(1.612)
first_floor × clustercluster14 −0.780
(0.778)
first_floor × clustercluster15 −0.199
(0.737)
first_floor × clustercluster16 0.537
(0.704)
first_floor × clustercluster17 −0.751
(1.114)
first_floor × clustercluster18 −0.550
(0.742)
first_floor × clustercluster19 0.567
(1.167)
first_floor × clustercluster20 −0.812
(0.885)
SD (Intercept cluster) 0.490 0.523
SD (first_floor cluster) 0.369
Cor (Intercept~first_floor cluster) 0.361
SD (Observations) 1.039 0.956
Num.Obs. 80 80 80 80 80
R2 0.136 0.462 0.657
R2 Adj. 0.125 0.280 0.324
R2 Marg. 0.154 0.173
R2 Cond. 0.308 0.426
AIC 252.6 252.6 254.5 256.0 256.9
BIC 259.7 305.1 352.2 265.6 271.2
ICC 0.2 0.3
Log.Lik. −123.288 −104.323 −86.269
F 12.258 2.534 1.969
RMSE 1.13 0.89 0.71 0.97 0.85
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001

In the complete model, all data point are treated as if they come from the same population. This ignores possible variation between subgroups or clusters. In the no pooling model, they fit separate models for each subgroup or cluster independently. Now we can see differences between subgroups but not across groups The multilevel model provides shared information between groups while accommodating for group-specific differences. For this analysis the multilevel with random intercept and slope model would fit best as it models for Radon levels in homes across the country. Within this country there are clusters. So using this model we can account for differences on different levels.

The higher the complexity in the “simple models” the higher the explained variance. Meaning that the models improve. From the non-multilevel models, the NO POOLING + INTERACTION model seems to be the best as the explained variance is the highest and the RMSE (Root Mean Square Error) is the lowest. With the multilevel models, it seems, based on the R2 cond. the model including random slopes outperforms the other one, it also has a lower RMSE compared to the random intercept model. It is difficult to compare the no pooling methods with the multilevel methods based on these metrics. Nevertheless, there is a difference in BIC metrics, the multilevel models have the lowest values here. Meaning that one can say that based on this metric the multilevel models are better.

## # Comparison of Model Performance Indices
## 
## Name                   |           Model |  RMSE | Sigma | AIC weights | AICc weights | BIC weights | Performance-Score
## -----------------------------------------------------------------------------------------------------------------------
## model_random_int       | lmerModLmerTest | 0.965 | 1.039 |       0.318 |        0.462 |       0.305 |            68.07%
## model_random_int_slope | lmerModLmerTest | 0.846 | 0.956 |       0.177 |        0.189 |       0.016 |            50.27%
## model_complete         |              lm | 1.130 | 1.144 |       0.216 |        0.349 |       0.680 |            46.45%
## model_cluster_int      |              lm | 0.711 | 1.006 |       0.081 |     3.20e-21 |    5.63e-21 |            34.68%
## model_cluster          |              lm | 0.891 | 1.038 |       0.208 |     5.51e-05 |    9.76e-11 |            33.41%

Since it has proven to be difficult to equally compare all different models, especially when taking the difference in random effects into account, we ran a comparison of the Model Performances. Judging from this output, the multilevel model (without random slopes) seems to perform best.

Exercise 2

Advantages of the caterpillar plots are that you provide a clear visual representation of individual group or cluster estimates. This helps you to identify variability between the clusters and overall trend. The downside of using this plot is that it can become less easily interpretable with large number of groups. The lattice plots shows you nice relationships within and between groups and therefore more informative about the overall structure of the data compared to the caterpillar plots. The spaghetti plots are useful to visualize the variability at the individual observations. But this can become messy (spaghetti) and therefore hard to interpret.

In this caterpillar plots we can see that the confidence intervals are roughly similar between all clusters, and that the intercept of the clusters are around 0.

Exercise 3

Ground floor
(N=766)
First floor
(N=153)
Overall
(N=919)
radon
Mean (SD) 5.07 (4.54) 3.28 (3.83) 4.77 (4.48)
Median [Min, Max] 3.90 [0.100, 48.2] 2.10 [0, 25.4] 3.60 [0, 48.2]
log.radon
Mean (SD) 1.33 (0.783) 0.713 (0.999) 1.22 (0.853)
Median [Min, Max] 1.36 [-2.30, 3.88] 0.742 [-2.30, 3.23] 1.28 [-2.30, 3.88]
u
Mean (SD) -0.139 (0.366) -0.0970 (0.360) -0.132 (0.365)
Median [Min, Max] -0.0965 [-0.882, 0.528] -0.0900 [-0.882, 0.504] -0.0965 [-0.882, 0.528]

We see that when we take the log of the radon levels, it gets normal distributed. We can also take from this plot, that ground floor contains a higher dose of radon as there is a negative correlation with the first floor. Radon . There is a correlation between uranium and radon, the correlation increases moderately when we look at log(radon).

This figure represents the estimates and the standard error for each county intercepts. ## Exercise 4

Answer: The counties with fewer measurements have more variable estimates because the no-pooling model only takes into account the observations within the county. The lower number of observations leads to a larger standard error and more uncertainty around the estimate. An advantage of the no-pooling analysis compared with the multilevel model is that it more flexible, and a disadvantage is that it tends to overfit and becomes vulnerable to errors for counties with a small amount of observations. Multilevel model estimates make use of the common situation that groups are similar to each other.

Exercise 5

The black line is the no pooling model with intercept, the complete pooling is the red line and the blue line is the multilevel model with random intercept and random slope. What we can see is that the radon levels are higher on the ground floor as the slope decreases when we look at the first floor.If the random effects have a not a big influence on the model predictions then the red and the blue line will be more similar. Black looks similar to the red line if the number of observations are high. Similar results are displayed in the book.

Exercise 6

This figure represents the predicted log radon value per county at the respective uranium level. This plots suggests that a higher uranium level is associated with a higher radon level.

Exercise 7

#Complete Pooling
cp <- lm(log.radon ~ first_floor, data = radon_mn)

#No Pooling
np <- lm(log.radon ~ first_floor + county, data = radon_mn)

np_int <- lm(log.radon ~ first_floor + county + first_floor:county, data = radon_mn)


#Multilevel model (Partial Pooling)
ml_intercept <- lmer(log.radon ~ first_floor + (1|county), data = radon_mn)
#Multilevel model (Partial Pooling)
ml_real <- lmer(log.radon ~ first_floor + (first_floor|county), data = radon_mn)

summary(ml_real)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log.radon ~ first_floor + (first_floor | county)
##    Data: radon_mn
## 
## REML criterion at convergence: 2168.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.4044 -0.6224  0.0138  0.6123  3.5682 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  county   (Intercept) 0.1216   0.3487        
##           first_floor 0.1181   0.3436   -0.34
##  Residual             0.5567   0.7462        
## Number of obs: 919, groups:  county, 85
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  1.46277    0.05387 71.66151  27.155  < 2e-16 ***
## first_floor -0.68110    0.08758 39.44290  -7.777 1.75e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr)
## first_floor -0.381
obs_per_cluster <-  18
n_cluster <-  20

# Fixed intercept
alpha_0 <-  1.46277     # choose a number you like, e.g. 1  



# Fixed slope
beta_0 <- -0.68110  #  e.g. 0.5



# Residuals st.dev (level 1) 
sig  <-  0.7462      #  e.g. 1



# Random intercept st.dev (level 2) 
sig_u <-  0.3487   #  e.g. 0.5



# Random slope st.dev (level 2)
sig_v <-  0.3436    #  e.g. 0.25



# Independent random effects
cor <- -0.34 #  e.g. 0.5

As depicted in the ggpairs plot, the correlation between first_floor and log.radon levels is still negative. Eventhough our first_floor variable is no longer binary, identical trends are visible upon comparison.

Again, even though the first_floor variable is no longer binary, we see identical trends across the arranged graphs (as compared to the original data). Similarly, we see that the blue and red lines tend to approach the same direction and comparable slopes, as we’ve also previosuly observed in the original dataset.

Once more, we see that directions are highly similar as are the predicted values we’ve gotten in earlier analyses. And again, we only run into the main difference which is the lack of dichotomy in the simulated data set.

Concluding, the simulated data set is more or less identical to the actual data set in terms of comparing the various model fits. I.e. we get very similar parameter estimations to the ones we got when fitting our models to the real Radon data.