Street Safety dataset includes a sample of 100 streets, and on each street, a random sample of 10 persons is asked how often they feel unsafe while walking that street.

1. List all the variables at level 1 and level 2

Table 1 presents the descriptive information of variables include in the analysis. In this analysis, persons, who represent micro-units (level 1), are nested in street or macro-units (level 2).

Variables include in level 1 are:

Variables for level 2 are:

Table 1 Descriptive statistics Street Safety

Variable Stats / Values Freqs (% of Valid) Graph Missing
sex [factor]
1. 0
2. 1
481(48.1%)
519(51.9%)
0 (0.0%)
age [numeric]
Mean (sd) : 47.2 (14.9)
min ≤ med ≤ max:
20 ≤ 48 ≤ 72
Q1 - Q3 : 35 - 60
53 distinct values 0 (0.0%)
economic [numeric]
Mean (sd) : 0 (1)
min ≤ med ≤ max:
-2.5 ≤ 0.1 ≤ 2.2
Q1 - Q3 : -0.8 - 0.7
90 distinct values 0 (0.0%)
crowded [numeric]
Mean (sd) : 4 (1.8)
min ≤ med ≤ max:
1 ≤ 4 ≤ 7
Q1 - Q3 : 2 - 6
1:50(5.0%)
2:220(22.0%)
3:190(19.0%)
4:140(14.0%)
5:130(13.0%)
6:200(20.0%)
7:70(7.0%)
0 (0.0%)
unsafe [numeric]
Mean (sd) : 1.7 (0.8)
min ≤ med ≤ max:
1 ≤ 1 ≤ 3
Q1 - Q3 : 1 - 2
1:505(50.5%)
2:306(30.6%)
3:189(18.9%)
0 (0.0%)

Generated by summarytools 1.0.0 (R version 4.1.2)
2021-11-16

2. Hierachical Linear Models

2.1 Null model (model4.0)

First, we estimate the empty or null model that did not contain any explanatory variable and where the independent variable (unsafe) is the sum of a general mean (\(\gamma_{00}\)), a random effect at the group level (street) (\(U_{0j}\)), and a random effect at the individual level, (\(R_{ij}\)):

Level 1 \[ \begin{aligned} Y_{ij} = \beta_{0} + R_{ij} \end{aligned} \] Level 2 \[ \begin{aligned} \beta_{0} = \gamma_{00} + U_{0j} \end{aligned} \]

Full Model \[ \begin{aligned} Y_{ij} = \gamma_{00} + U_{0j} + R_{ij} \end{aligned} \] Random effect \(U_{0j}\) and \(R_{ij}\) are assumed to be independent, and to have mean 0 and variances var(\(R_{ij}\)) = \(\sigma^2\) and var(\(U_{ij}\)) = \(\tau_{0}^2\). Then, the total variance of \(Y\) can be decomposed as the sum of group and individual variances:

\[ \begin{aligned} var(Y_{ij}) = var(U_{0j}) + var(R_{ij}) = \sigma^2 + \tau_{0}^2 \end{aligned} \] Table 2 presents the results of the null model. According to results,17.98% of population variance in the individual’ feeling of safety is explained by the street characteristics (level 2 or macro-level). Furthermore, the standard deviation of random effect falls into the 95% confidence interval of (0.265 - 0.399), which does not include the value \(0\) so that the random intercept between street is statistically significant (Table 3).

Table 2. Null Model. Student Popularity
  Null Model
Predictors Estimates std.Error p-value
Intercept 1.68 *** 0.04 <0.001
Random Effects
σ2 0.49
τ00 street 0.11
ICC 0.18
N street 100
Observations 1000
Marginal R2 / Conditional R2 0.000 / 0.180
  • p<0.05   ** p<0.01   *** p<0.001
Table 3. Confidence Interval for Null Model (Model 4.0)
2.5 % 97.5 %
.sig01 0.2650816 0.3992783
.sigma 0.6670436 0.7316272
(Intercept) 1.6059524 1.7620476

2.2 Random intercept model plus level 1 fixed effect (model 4.1)

A second random intercept model (model 4.1) for estimating the perception of unsafety was ran, where respondent are nested in streets, whereas age and sex were included as explanatory variables. This model can be also expressed in two separates level as:

Level 1 \[ \begin{aligned} Y_{ij} = \beta_{0} + \beta_{1}age+\beta_{2}sex + R_{ij} \end{aligned} \]

\[ \begin{aligned} \beta_{1} = \gamma_{10} \end{aligned} \]

\[ \begin{aligned} \beta_{2} = \gamma_{20} \end{aligned} \]

Level 2 \[ \begin{aligned} \beta_{0} = \gamma_{00} + U_{0j} \end{aligned} \]

Full Model \[ \begin{aligned} Y_{ij} = \gamma_{00} + \gamma_{10}age_{i} + \gamma_{20}sex_{i} + U_{0j} + R_{ij} \end{aligned} \]

Table 4 presents the estimation of the random intercept model (model 4.1). Additionally, Table 5 shows the estimation of confidence intervals. Results indicate that both random and fixed effects are statistically significant.

Table 4. Comparison Null Model (4.0) vs. Random Effect Model (4.1)
  Null Mode (4.0) Random Effect (4.1)
Predictors Estimates std.Error p-value Estimates std.Error p-value
Intercept 1.68 *** 0.04 <0.001 0.91 *** 0.08 <0.001
Age 0.01 *** 0.00 <0.001
Gender (1=Female) 0.34 *** 0.04 <0.001
Random Effects
σ2 0.49 0.42
τ00 0.11 street 0.11 street
ICC 0.18 0.21
N 100 street 100 street
Observations 1000 1000
Marginal R2 / Conditional R2 0.000 / 0.180 0.107 / 0.293
  • p<0.05   ** p<0.01   *** p<0.001
Table 5. Confidence Interval for Random effects and fixed effect (Model 4.1)
2.5 % 97.5 %
.sig01 0.2740477 0.4037073
.sigma 0.6203027 0.6803727
(Intercept) 0.7488611 1.0664661
age 0.0099690 0.0155714
sex1 0.2520633 0.4194927

a. What is \(\tau_{00}^{2}\), the variance of the random intercept? And what is \(\sigma^{2}\), the variance of the residual?

The variance of the random intercept (\(\tau_{00}^{2}\) = \(0.11\)) represent the variability in the perception of unsafety between streets. This random effect is statistically significant, suggesting that intercepts by streets are different.

The variance of the residual (\(\sigma^{2}\) = \(0.49\)) or variability within streets showed decreased respect null model (\(1.492\) to \(0.42\)), which means that gender and age of respondents explain the variability of safety perception within streets.

b. Based on the sex (male vs female), explain the effect of gender on the perception of unsafety.

According to results, sex is a statistically significant predictor of perception of unsafety \((p-value < 0.001)\). Thus, being a female increases the perception of unsafety in street by \(0.34\) points.

2.2 Random intercept model plus level 1 and 2 fixed effect (model4.2)

Model 4.2 that added fixed effect to level 2 (economic and crowded) following the form:

Level 1 \[ \begin{aligned} Y_{ij} = \beta_{0} + \beta_{1}age+\beta_{2}sex + R_{ij} \end{aligned} \] \[ \begin{aligned} \beta_{1} = \gamma_{10} \end{aligned} \]

\[ \begin{aligned} \beta_{2} = \gamma_{20} \end{aligned} \]

Level 2 \[ \begin{aligned} \beta_{0} = \gamma_{00} + \gamma_{02}economics + \gamma_{03}crowded + U_{0j} \end{aligned} \]

Full Model \[ \begin{aligned} Y_{ij} = \gamma_{00} + \gamma_{10}age_{i} + \gamma_{20}sex_{i} + \gamma_{02}economics + \gamma_{03}crowded + U_{0j} + R_{ij} \end{aligned} \]

Table 6 presents the estimation of random intercept model (model 4.2) that includes explanatory variables for both level 1 (individual) and level 2 (street). Furthermore, Tabled 7 shows the estimation of confidence intervals for all effects. Results indicates that confidence intervals does not include the \(0\), so that both random and fixed effects for level 1 and 2 are statistically significant.

Table 6. Comparison Null Model (4.0) vs. Random Models (4.1 and 4.2)
  Null Model 4.0 Model 4.1 Model 4.2
Predictors Estimates std.Error p-value Estimates std.Error p-value Estimates std.Error p-value
Intercept 1.68 *** 0.04 <0.001 0.91 *** 0.08 <0.001 1.43 *** 0.09 <0.001
Gender (1=Female) 0.01 *** 0.00 <0.001 0.01 *** 0.00 <0.001
Age 0.34 *** 0.04 <0.001 0.35 *** 0.04 <0.001
Economic Index -0.21 *** 0.03 <0.001
Street crowdedness -0.13 *** 0.01 <0.001
Random Effects
σ2 0.49 0.42 0.42
τ00 0.11 street 0.11 street 0.02 street
ICC 0.18 0.21 0.05
N 100 street 100 street 100 street
Observations 1000 1000 1000
Marginal R2 / Conditional R2 0.000 / 0.180 0.107 / 0.293 0.254 / 0.290
  • p<0.05   ** p<0.01   *** p<0.001
Table 7. Confidence Interval for Random effects and fixed effect for level 1 and 2 (Model 4.2)
2.5 % 97.5 %
.sig01 0.0777458 0.2079173
.sigma 0.6202659 0.6803243
(Intercept) 1.2462801 1.6150789
age 0.0100627 0.0155722
sex1 0.2696290 0.4340010
economic -0.2648199 -0.1641746
crowded -0.1633972 -0.1059705

a. What is \(\tau_{00}^{2}\) from model4.2? How much improvement from model 4.1?

The variance of the random intercept (\(\tau_{00}^{2}\) = \(0.02\)) represents the variability between streets, which showed a decreased respect to both Null Model and Model 3.1 (\(0.11\)) after included economic index and indicator of street crowdedness as an explanatory variables for level 2 (macro-level or group).

The variance between (\(\tau_{00}^{2}\)) groups decreased by \(81.82\%\) after including explanatory variables for level 2. Also, adding these variables ICC drops by \(72.22\%\) in comparison to Null Model.

b. What’s the effect of crowdedness on the perception of unsafety? Does crowdedness make the streets feel safe or unsafe?

Effect of crowdedness on the perception of unsafety is negative and statistically significant \((p-value <0.001)\). Thus, an increase in one unit in the streets crowdedness indicator reduce the perception of unsafety by \(0.13\) points so that crowdedness make that individual feel more safe in streets

2.3 Random intercept model plus cross-level interaction (model4.2)

Model 4.3 added a cross-level interaction term between sex and crowdedness to model 4.2, this model following the form:

Level 1 \[ \begin{aligned} Y_{ij} = \beta_{0} + \beta_{1}age+\beta_{2}sex +R_{ij} \end{aligned} \] \[ \begin{aligned} \beta_{1} = \gamma_{10} \end{aligned} \]

\[ \begin{aligned} \beta_{2} = \gamma_{20} + \gamma_{21}crowded \end{aligned} \]

Level 2 \[ \begin{aligned} \beta_{0} = \gamma_{00} + \gamma_{02}economics + \gamma_{03}crowded + U_{0j} \end{aligned} \]

Full Model \[ \begin{aligned} Y_{ij} = \gamma_{00} + \gamma_{10}age_{i} + (\gamma_{20} + \gamma_{21}crowded)sex_{i} + \gamma_{02}economics_{j} + \gamma_{03}crowded_{j} + U_{0j} + R_{ij} \end{aligned} \]

\[ \begin{aligned} Y_{ij} = \gamma_{00} + \gamma_{10}age_{i} + \gamma_{20}sex_{i} + \gamma_{21}crowded*sex_{i} + \gamma_{02}economics_{j} + \gamma_{03}crowded_{j} + U_{0j} + R_{ij} \end{aligned} \]

Table 8 displays the estimation of random intercept model that includes explanatory variables for both level 1 (individual) and level 2 (street) and a cross effect of . Furthermore, Tabled 9 shows the estimation of confidence intervals for all effects. Results indicates that both random and fixed effects are statistically significant.

Table 8. Comparison Hierarchical Models
  Model 4.1 Model 4.2 Model 4.3
Predictors Estimates std.Error p-value Estimates std.Error p-value Estimates std.Error p-value
Intercept 0.91 *** 0.08 <0.001 1.43 *** 0.09 <0.001 1.27 *** 0.10 <0.001
Gender (1=Female) 0.01 *** 0.00 <0.001 0.01 *** 0.00 <0.001 0.01 *** 0.00 <0.001
Age 0.34 *** 0.04 <0.001 0.35 *** 0.04 <0.001 0.69 *** 0.10 <0.001
Economic Index -0.21 *** 0.03 <0.001 -0.21 *** 0.03 <0.001
Street crowdedness -0.13 *** 0.01 <0.001 -0.09 *** 0.02 <0.001
Gender * Crowded -0.09 *** 0.02 <0.001
Random Effects
σ2 0.42 0.42 0.41
τ00 0.11 street 0.02 street 0.02 street
N 100 street 100 street 100 street
Observations 1000 1000 1000
Marginal R2 / Conditional R2 0.107 / 0.293 0.254 / 0.290 0.263 / 0.302
  • p<0.05   ** p<0.01   *** p<0.001
Table 9. Confidence Interval for Model 4.3
2.5 % 97.5 %
.sig01 0.0859440 0.2122739
.sigma 0.6153584 0.6749474
(Intercept) 1.0617785 1.4710422
age 0.0100419 0.0155122
sex1 0.4889399 0.8912065
economic -0.2645804 -0.1632508
crowded -0.1284071 -0.0539425
sex1:crowded -0.1320826 -0.0390682

a. Is the cross-level interaction term significant? What’s the p-value? (1 Point)?

The crossed-level interaction between gender and crowdedness street indicator is negative and statistically significant \((p-value < 0.001)\). Furthermore, cross-level interaction effect falls into the 95% confidence interval (-0.132 - -0.039), which not includes the \(0\) so that the this coefficient is statistically significant.

b. How would you explain the interaction effect? (1 Point)

Crossed-level is negative and statistically significant (\(\gamma_{21} = -0.09\)) so that an increased in one unit of street crowdedness indicator increased the perception of unsafety for female respondents in \(0.09\) points. Thus, even thought the effect of being females increase the perception of unsafety, more crowded street help to reduce the perception of unsafety for female participants.

2.4 Random intercept intercept model plus cross-level interaction (model4.2)

Model 4.4 added a slope intercept (\(U_{2j}*sex\)). This model can be defined using the following form:

Level 1 \[ \begin{aligned} Y_{ij} = \beta_{0} + \beta_{1}age+\beta_{2}sex +R_{ij} \end{aligned} \]

\[ \begin{aligned} \beta_{1} = \gamma_{10} \end{aligned} \]

\[ \begin{aligned} \beta_{2} = \gamma_{20} + \gamma_{21}crowded + U_{2j} \end{aligned} \]

Level 2 \[ \begin{aligned} \beta_{0} = \gamma_{00} + \gamma_{02}economics + \gamma_{03}crowded + U_{0j} \end{aligned} \]

Full Model \[ \begin{aligned} Y_{ij} = \gamma_{00} + \gamma_{10}age_{i} + (\gamma_{20} + \gamma_{21}crowded + U_{2j})sex_{i} + \gamma_{02}economics_{j} + \gamma_{03}crowded_{j} + U_{0j} + R_{ij} \end{aligned} \]

\[ \begin{aligned} Y_{ij} = \gamma_{00} + \gamma_{10}age_{i} + \gamma_{20}sex_{i} + \gamma_{21}crowded*sex_{i} + \gamma_{02}economics_{j} + \gamma_{03}crowded_{j} + U_{2j}*sex + U_{0j} + R_{ij} \end{aligned} \]

Table 10 presents the results for random intercept and random slope model that includes explanatory variables for both level 1 (individual) and level 2 (street) and a cross effect of gender and crowdedness indicator.

Table 10. Comparison Hierarchical Models
  Model 4.1 Model 4.2 Model 4.3 Model 4.4
Predictors Estimates std.Error p-value Estimates std.Error p-value Estimates std.Error p-value Estimates std.Error p-value
Intercept 0.91 *** 0.08 <0.001 1.43 *** 0.09 <0.001 1.27 *** 0.10 <0.001 1.27 *** 0.10 <0.001
Gender (1=Female) 0.01 *** 0.00 <0.001 0.01 *** 0.00 <0.001 0.01 *** 0.00 <0.001 0.01 *** 0.00 <0.001
Age 0.34 *** 0.04 <0.001 0.35 *** 0.04 <0.001 0.69 *** 0.10 <0.001 0.69 *** 0.10 <0.001
Economic Index -0.21 *** 0.03 <0.001 -0.21 *** 0.03 <0.001 -0.22 *** 0.03 <0.001
Street crowdedness -0.13 *** 0.01 <0.001 -0.09 *** 0.02 <0.001 -0.09 *** 0.02 <0.001
Gender * Crowded -0.09 *** 0.02 <0.001 -0.09 *** 0.02 <0.001
Random Effects
σ2 0.4214 0.4214 0.4147 0.4126
τ00 0.1111 street 0.0215 street 0.0230 street 0.0140 street
τ11       0.0089 street.sex1
ρ01       0.5684 street
N 100 street 100 street 100 street 100 street
Observations 1000 1000 1000 1000
Marginal R2 / Conditional R2 0.107 / 0.293 0.254 / 0.290 0.263 / 0.302 0.264 / 0.306
  • p<0.05   ** p<0.01   *** p<0.001

a. What is the variance for the random slope effect?

The variance for the random slope (\(\tau_{11}\)) is equal to \(0.0089\).

b. Test if the random slope effect is significant? Report the p-value.

Tabled 11 shows the estimation of confidence intervals for all effects including the standard deviation for the random slope effect (\(.sig03\)). Random slope effect falls into the 95% confidence interval of (0 - 0.267), which does include the \(0\) value so that we conclude that random slope for gender is not a statistically significant effect.

Table 11. Confidence Interval for Model 4.4
2.5 % 97.5 %
.sig01 0.0223010 0.2186641
.sig02 -1.0000000 1.0000000
.sig03 0.0000000 0.2665655
.sigma 0.6123085 0.6737680
(Intercept) 1.0709085 1.4696205
age 0.0099865 0.0154601
sex1 0.4831451 0.8984740
economic -0.2655155 -0.1642719
crowded -0.1274123 -0.0559065
sex1:crowded -0.1335742 -0.0375878