Immobility

-- Attaching packages --------------------------------------- tidyverse 1.3.2 --
v ggplot2 3.3.6      v dplyr   1.0.10
v tibble  3.1.8      v stringr 1.4.1 
v tidyr   1.2.1      v forcats 0.5.2 
v purrr   0.3.5      
-- Conflicts ------------------------------------------ tidyverse_conflicts() --
x dplyr::filter() masks stats::filter()
x dplyr::lag()    masks stats::lag()
Le chargement a nécessité le package : Matrix


Attachement du package : 'Matrix'


Les objets suivants sont masqués depuis 'package:tidyr':

    expand, pack, unpack


# Attaching packages: easystats 0.5.2 (red = needs update)
x insight     0.18.4   v datawizard  0.6.2 
v bayestestR  0.13.0   v performance 0.10.0
v parameters  0.19.0   v effectsize  0.8.0 
v modelbased  0.8.5    v correlation 0.8.3 
v see         0.7.3    v report      0.5.5 

Restart the R-Session and update packages in red with `easystats::easystats_update()`.


Le chargement a nécessité le package : Rcpp

Loading 'brms' package (version 2.18.0). Useful instructions
can be found by typing help('brms'). A more detailed introduction
to the package is available through vignette('brms_overview').


Attachement du package : 'brms'


L'objet suivant est masqué depuis 'package:lme4':

    ngrps


L'objet suivant est masqué depuis 'package:stats':

    ar

Immobilite sur 5 jours ouvrees

freq(itt$MOB5)
      n    % val%
0  1684  7.5  7.5
1  1677  7.5  7.5
2  2004  8.9  8.9
3  2568 11.5 11.5
4  3975 17.7 17.7
5 10498 46.9 46.9

Immobilite sur 7 jours

freq(itt$MOB7)
     n    % val%
0 1134  5.1  5.1
1 1195  5.3  5.3
2 1375  6.1  6.1
3 1668  7.4  7.4
4 2091  9.3  9.3
5 3215 14.3 14.3
6 4748 21.2 21.2
7 6980 31.2 31.2

Immobilite le lundi

freq(itt$TravelWeekDay_B01ID_1.b)
      n    % val%
0  6375 28.5 28.5
1 16031 71.5 71.5

Estimation de l’Immobilite le lundi corrige par l’ajout des short walk trips

itt$TravelWeekDay_B01ID_1.b2 <- ifelse(itt$ShWalkTrip == 1, 1, itt$TravelWeekDay_B01ID_1.b)
freq(itt$TravelWeekDay_B01ID_1.b2)
      n    % val%
0  4959 22.1 22.1
1 17447 77.9 77.9

Immobilite et vacances scolaires

rprop(table(itt$MOB5,itt$Schl_Hday.b))
          
           0     1     Total
  0         71.7  28.3 100.0
  1         69.4  30.6 100.0
  2         68.6  31.4 100.0
  3         66.3  33.7 100.0
  4         67.0  33.0 100.0
  5         74.0  26.0 100.0
  Ensemble  70.9  29.1 100.0

Immobilite et annee de l’enquete

rprop(table(itt$MOB5,itt$SurveyYear))
          
           2018  2019  Total
  0         49.5  50.5 100.0
  1         47.8  52.2 100.0
  2         50.4  49.6 100.0
  3         50.0  50.0 100.0
  4         48.6  51.4 100.0
  5         50.1  49.9 100.0
  Ensemble  49.6  50.4 100.0

Etat de sante

rprop(table(itt$MOB5[itt$SurveyYear>2016],itt$GenHeal_B01ID_rec[itt$SurveyYear>2016]))
          
           2     1     3     4     5     Total
  0         29.8  35.0  17.5  12.0   5.7 100.0
  1         31.1  33.6  19.6  10.9   4.8 100.0
  2         33.4  34.3  20.2   9.2   2.8 100.0
  3         35.8  38.5  17.7   6.3   1.8 100.0
  4         37.4  44.1  13.8   4.0   0.7 100.0
  5         36.9  52.1   8.8   1.8   0.4 100.0
  Ensemble  35.6  44.8  13.2   4.8   1.5 100.0

Difficultes de mobilite

1 1 No difficulties
2 1 Foot + Bus + Car
3 1 Foot + Bus
4 1 Car + ….
6 1 Foot only

itt %>% tbl_cross(MobDiffSum_B01ID_rec, MOB5 , percent = "row"
                  , label = c(1 ~ "Mobility difficulties" , 2 ~ "# Mobile WeekDays")
                  ) %>% add_p() %>% bold_labels()
# Mobile WeekDays Total p-value1
0 1 2 3 4 5
Mobility difficulties <0.001
    1 1,257 (6.3%) 1,279 (6.4%) 1,615 (8.1%) 2,148 (11%) 3,615 (18%) 9,949 (50%) 19,863 (100%)
    2 226 (27%) 151 (18%) 149 (18%) 107 (13%) 96 (12%) 104 (12%) 833 (100%)
    3 87 (17%) 104 (20%) 69 (13%) 92 (18%) 82 (16%) 88 (17%) 522 (100%)
    4 56 (8.3%) 86 (13%) 90 (13%) 114 (17%) 98 (14%) 233 (34%) 677 (100%)
    6 58 (11%) 57 (11%) 81 (16%) 107 (21%) 84 (16%) 124 (24%) 511 (100%)
Total 1,684 (7.5%) 1,677 (7.5%) 2,004 (8.9%) 2,568 (11%) 3,975 (18%) 10,498 (47%) 22,406 (100%)
1 Pearson's Chi-squared test

Interview

1: Face to face
2: Proxy

itt %>% tbl_cross(Interview_B01ID, MOB5 , percent = "row"
                  , label = c(1 ~ "Itw proxi" , 2 ~ "# Mobile WeekDays")
                  ) %>% add_p() %>% bold_labels()
# Mobile WeekDays Total p-value1
0 1 2 3 4 5
Itw proxi <0.001
    1 1,014 (6.3%) 1,228 (7.6%) 1,507 (9.3%) 1,998 (12%) 3,069 (19%) 7,405 (46%) 16,221 (100%)
    2 670 (11%) 449 (7.3%) 497 (8.0%) 570 (9.2%) 906 (15%) 3,093 (50%) 6,185 (100%)
Total 1,684 (7.5%) 1,677 (7.5%) 2,004 (8.9%) 2,568 (11%) 3,975 (18%) 10,498 (47%) 22,406 (100%)
1 Pearson's Chi-squared test

Immobilite du lundi sans les proxi

L’immobilité baisse de 0.5 points

freq(itt$TravelWeekDay_B01ID_1.b2[itt$Interview_B01ID == 1])
      n    % val%
0  3498 21.6 21.6
1 12723 78.4 78.4

Bank Holliday

itt %>% tbl_cross(Bank_Hday.b, MOB5 , percent = "row"
                  , label = c(1 ~ "Bank Holliday" , 2 ~ "# Mobile WeekDays")
                  ) %>% add_p() %>% bold_labels()
# Mobile WeekDays Total p-value1
0 1 2 3 4 5
Bank Holliday <0.001
    0 1,509 (7.6%) 1,456 (7.3%) 1,748 (8.8%) 2,212 (11%) 3,384 (17%) 9,663 (48%) 19,972 (100%)
    1 175 (7.2%) 221 (9.1%) 256 (11%) 356 (15%) 591 (24%) 835 (34%) 2,434 (100%)
Total 1,684 (7.5%) 1,677 (7.5%) 2,004 (8.9%) 2,568 (11%) 3,975 (18%) 10,498 (47%) 22,406 (100%)
1 Pearson's Chi-squared test

Immobilite du lundi sans les proxi et sans les vacances

freq(itt$TravelWeekDay_B01ID_1.b2[itt$Interview_B01ID == 1 & itt$Bank_Hday.b == 0 &
                                    itt$Schl_Hday.b == 0])
     n    % val%
0 2217 20.2 20.2
1 8736 79.8 79.8
#itt %>% tbl_cross(Ecos, MOB7 , percent = "row"
#                  , label = c(1 ~ "Type of activity" , 2 ~ "# Mobile #WeekDays")
#                  ) %>% add_p() %>% bold_labels()

Transformation des donnees avec une ligne par jour de mobilite

variable <- c("IndividualID"
,"TravelWeekDay_B01ID_1.b","TravelWeekDay_B01ID_2.b","TravelWeekDay_B01ID_3.b","TravelWeekDay_B01ID_4.b","TravelWeekDay_B01ID_5.b","TravelWeekDay_B01ID_6.b","TravelWeekDay_B01ID_7.b","MOB5","MOB7","MOB5f","MOB7f"
,"Bank_Hday.b","Schl_Hday.b","Interview_B01ID","MobDiffSum_B01ID_rec", "SurveyYear","GenHeal_B01ID_rec", "ShWalkTrip","EcoS","GenHeal"
,"MobDiff_rec","Age","Sex_B01ID"
,"D_purp_5.1.b","D_purp_5.2.b","D_purp_5.3.b","D_purp_5.4.b","D_purp_5.5.b","D_purp_5.6.b","D_purp_5.7.b")

dta1 <- itt %>% filter(MOB7>0 & SurveyYear>2016) %>% select(all_of(variable)) %>%
mutate(day = 1, mob = TravelWeekDay_B01ID_1.b, shop = D_purp_5.1.b)
dta2 <- itt %>% filter(MOB7>0 & SurveyYear>2016) %>% select(all_of(variable)) %>%
mutate(day = 2, mob = TravelWeekDay_B01ID_2.b, shop = D_purp_5.2.b)
dta3 <- itt %>% filter(MOB7>0 & SurveyYear>2016) %>% select(all_of(variable)) %>%
mutate(day = 3, mob = TravelWeekDay_B01ID_3.b, shop = D_purp_5.3.b)
dta4 <- itt %>% filter(MOB7>0 & SurveyYear>2016) %>% select(all_of(variable)) %>%
mutate(day = 4, mob = TravelWeekDay_B01ID_4.b, shop = D_purp_5.4.b)
dta5 <- itt %>% filter(MOB7>0 & SurveyYear>2016) %>% select(all_of(variable)) %>%
mutate(day = 5, mob = TravelWeekDay_B01ID_5.b, shop = D_purp_5.5.b)
dta6 <- itt %>% filter(MOB7>0 & SurveyYear>2016) %>% select(all_of(variable)) %>%
mutate(day = 6, mob = TravelWeekDay_B01ID_6.b, shop = D_purp_5.6.b)
dta7 <- itt %>% filter(MOB7>0 & SurveyYear>2016) %>% select(all_of(variable)) %>%
mutate(day = 7, mob = TravelWeekDay_B01ID_7.b, shop = D_purp_5.7.b)


dta <- rbind(dta1,dta2,dta3,dta4,dta5,dta6,dta7)

dta$day <- factor(dta$day)

Modele jours de mobilite

We fitted a logistic mixed model (estimated using ML and BOBYQA optimizer) to predict mob (jour avec au moins un déplacement) with day (jour de la semaine) (formula: mob ~ 0 + day * EcoS). The model included IndividualID as random effect

glmer(mob ~ 1 + (1 | MOB7)
                + day #+ EcoS #+ GenHeal + ShWalkTrip
                #+ Bank_Hday.b #+ SurveyYear + Schl_Hday.b + Interview_B01ID
                ,data = dta, family = binomial, nAGQ = 0 #, REML=F
                ,control = glmerControl(calc.derivs = FALSE)
) -> model
model_parameters(model) %>% 
  print_md(caption="Model parameters", digits = "signif2")
# Fixed Effects
Parameter Log-Odds SE 95% CI z p
(Intercept) 1.7 1.7 (-1.61, 5.06) 1 0.311
day [2] 0.083 0.028 (0.03, 0.14) 2.9 0.004
day [3] 0.12 0.028 (0.07, 0.18) 4.3 < .001
day [4] 0.19 0.029 (0.13, 0.25) 6.7 < .001
day [5] 0.27 0.029 (0.21, 0.32) 9.3 < .001
day [6] -0.24 0.028 (-0.30, -0.19) -8.7 < .001
day [7] -0.93 0.028 (-0.98, -0.87) -33 < .001
# Random Effects
Parameter Coefficient
SD (Intercept: MOB7) 4.5

Marginal means

estimate_means(model)
We selected `at = c("day")`.
Estimated Marginal Means

day | Probability |   SE |       95% CI
---------------------------------------
1   |        0.85 | 0.22 | [0.17, 0.99]
2   |        0.86 | 0.21 | [0.18, 0.99]
3   |        0.86 | 0.20 | [0.18, 0.99]
4   |        0.87 | 0.19 | [0.19, 0.99]
5   |        0.88 | 0.18 | [0.21, 1.00]
6   |        0.82 | 0.26 | [0.14, 0.99]
7   |        0.69 | 0.36 | [0.07, 0.98]

Marginal means estimated at day
estimate_grouplevel(model)
Group | Level |   Parameter | Coefficient |   SE |         95% CI
-----------------------------------------------------------------
MOB7  |     1 | (Intercept) |       -3.49 | 0.03 | [-3.55, -3.43]
MOB7  |     2 | (Intercept) |       -2.60 | 0.02 | [-2.65, -2.56]
MOB7  |     3 | (Intercept) |       -1.96 | 0.02 | [-1.99, -1.92]
MOB7  |     4 | (Intercept) |       -1.36 | 0.02 | [-1.40, -1.33]
MOB7  |     5 | (Intercept) |       -0.71 | 0.02 | [-0.74, -0.68]
MOB7  |     6 | (Intercept) |        0.19 | 0.02 | [ 0.16,  0.22]
MOB7  |     7 | (Intercept) |        9.93 | 1.33 | [ 7.33, 12.53]
#check_model(model)
model_performance(model) %>% 
  print_md(digits = "signif3", caption="Indices of model performance", layout="vertical")
Indices of model performance
Metric Value
AIC 106000
AICc 106000
BIC 106000
R2 (cond.) 0.86
R2 (marg.) 0.00615
ICC 0.859
RMSE 0.344
Sigma 1
Log_loss 0.355
Score_log -Inf
#report(model)

Modele jours de shopping

Pour les achats, la variable individuelle, l’identifiant des individus n’était pas significative

glm(shop ~ 1
                + day*EcoS #+ GenHeal + ShWalkTrip
                #+ Bank_Hday.b #+ SurveyYear + Schl_Hday.b + Interview_B01ID
                ,data = dta, family = binomial) -> model
model_parameters(model) %>% 
  print_md(caption="Model parameters", digits = "signif2")
Profiled confidence intervals may take longer time to compute.
  Use `ci_method="wald"` for faster computation of CIs.
Parameter Log-Odds SE 95% CI z p
(Intercept) -0.14 0.018 (-0.18, -0.11) -8.1 < .001
day (2) -2.3 0.038 (-2.40, -2.25) -62 < .001
day (3) -4.8 0.11 (-5.04, -4.62) -44 < .001
day (4) -2.5 0.039 (-2.54, -2.38) -63 < .001
day (5) -1.3 0.029 (-1.39, -1.27) -46 < .001
day (6) -2.1 0.035 (-2.17, -2.04) -60 < .001
day (7) -1.8 0.032 (-1.88, -1.75) -56 < .001
EcoS (Others) -4.4 0.11 (-4.57, -4.16) -41 < .001
day (2) * EcoS (Others) 1.4 0.2 (0.95, 1.74) 6.8 < .001
day (3) * EcoS (Others) 5.3 0.17 (4.94, 5.62) 31 < .001
day (4) * EcoS (Others) 3.7 0.13 (3.43, 3.92) 29 < .001
day (5) * EcoS (Others) 5.1 0.11 (4.91, 5.34) 46 < .001
day (6) * EcoS (Others) 3.9 0.12 (3.67, 4.14) 33 < .001
day (7) * EcoS (Others) 4.6 0.11 (4.42, 4.86) 41 < .001
#check_model(model)
model_performance(model) %>% 
  print_md(digits = "signif3", caption="Indices of model performance", layout="vertical")
Indices of model performance
Metric Value
AIC 89600
BIC 89800
Tjur’s R2 0.16
RMSE 0.301
Sigma 0.776
Log_loss 0.301
Score_log -Inf
Score_spherical 0.000161
PCP 0.819
#report(model)

Marginal means

Ici, il me parait que les écarts entre les journées sont beaucoup trop importants. Ce qui signifie qu’il n’y a pas assez de fréquence d’achats.

estimate_means(model)
We selected `at = c("day", "EcoS")`.
Estimated Marginal Means

day |    EcoS | Probability |       SE |       95% CI
-----------------------------------------------------
1   | Workers |        0.46 | 4.43e-03 | [0.46, 0.47]
2   | Workers |        0.08 | 2.38e-03 | [0.07, 0.08]
3   | Workers |    6.93e-03 | 7.36e-04 | [0.01, 0.01]
4   | Workers |        0.07 | 2.25e-03 | [0.06, 0.07]
5   | Workers |        0.19 | 3.46e-03 | [0.18, 0.19]
6   | Workers |        0.10 | 2.61e-03 | [0.09, 0.10]
7   | Workers |        0.12 | 2.92e-03 | [0.12, 0.13]
1   |  Others |        0.01 | 1.12e-03 | [0.01, 0.01]
2   |  Others |    4.20e-03 | 6.97e-04 | [0.00, 0.01]
3   |  Others |        0.02 | 1.40e-03 | [0.01, 0.02]
4   |  Others |        0.04 | 2.01e-03 | [0.03, 0.04]
5   |  Others |        0.33 | 5.07e-03 | [0.32, 0.34]
6   |  Others |        0.06 | 2.61e-03 | [0.06, 0.07]
7   |  Others |        0.16 | 3.92e-03 | [0.15, 0.16]

Marginal means estimated at day, EcoS