require(nnet)
d<-read.table("table_reponses_qu.csv", h=T, sep=";")
summary(d)
X Copie Note age augmenter changer_hab changer_hab_alim
Min. : 0.00 1:10 : 5 0 : 41 Min. :0.000 Min. :0.000 Min. :0.000 Min. :0.000
1st Qu.: 33.75 1:11 : 5 1,5 : 73 1st Qu.:2.000 1st Qu.:1.000 1st Qu.:4.000 1st Qu.:3.000
Median : 67.50 1:12 : 5 15 :104 Median :3.000 Median :1.000 Median :4.000 Median :4.000
Mean : 74.66 1:13 : 5 16,5: 84 Mean :2.914 Mean :1.676 Mean :4.103 Mean :3.968
3rd Qu.:113.25 1:14 : 5 18 : 28 3rd Qu.:4.000 3rd Qu.:2.000 3rd Qu.:5.000 3rd Qu.:5.000
Max. :184.00 1:16 : 5 3 : 58 Max. :6.000 Max. :6.000 Max. :6.000 Max. :6.000
(Other):378 4,5 : 20
communiquer comprendre_logo conscience_empreinte deja_renseigner diminuer env
Min. :0.000 Min. :0.000 Min. :0.000 Min. :0.000 Min. :0.00 Min. :0.000
1st Qu.:2.000 1st Qu.:1.000 1st Qu.:3.000 1st Qu.:2.000 1st Qu.:3.00 1st Qu.:2.000
Median :3.000 Median :1.000 Median :4.000 Median :3.000 Median :4.00 Median :3.000
Mean :3.145 Mean :1.172 Mean :3.642 Mean :3.282 Mean :3.98 Mean :3.265
3rd Qu.:4.000 3rd Qu.:1.000 3rd Qu.:4.000 3rd Qu.:4.000 3rd Qu.:5.00 3rd Qu.:4.000
Max. :6.000 Max. :3.000 Max. :6.000 Max. :6.000 Max. :6.00 Max. :6.000
envie favorable_affichage freq fruits_legumes futurs_logos genre
Min. :0.000 Min. :0.000 Min. :0.000 Min. :0.000 Min. : 0 Min. :0.000
1st Qu.:3.000 1st Qu.:1.000 1st Qu.:1.000 1st Qu.:1.000 1st Qu.: 100 1st Qu.:1.000
Median :4.000 Median :1.000 Median :1.000 Median :1.000 Median : 10100 Median :2.000
Mean :3.426 Mean :1.289 Mean :1.735 Mean :1.662 Mean : 45754 Mean :1.632
3rd Qu.:4.000 3rd Qu.:1.000 3rd Qu.:2.000 3rd Qu.:2.000 3rd Qu.:100110 3rd Qu.:2.000
Max. :6.000 Max. :3.000 Max. :5.000 Max. :5.000 Max. :111110 Max. :3.000
gout infos_com infos_logo mal_retrouver notion_budget_carbone
Min. :0.000 Min. : 0 Min. : 0 Min. :0.000 Min. :0.000
1st Qu.:4.000 1st Qu.: 100000 1st Qu.: 11 1st Qu.:2.000 1st Qu.:1.000
Median :4.000 Median :1000000 Median : 111 Median :3.000 Median :2.000
Mean :4.049 Mean : 556225 Mean : 29339 Mean :2.983 Mean :1.583
3rd Qu.:5.000 3rd Qu.:1000000 3rd Qu.:100000 3rd Qu.:4.000 3rd Qu.:2.000
Max. :6.000 Max. :1111111 Max. :111111 Max. :6.000 Max. :3.000
notion_empreinte_carbone nutrition origine part_chacun pas_attention poisson
Min. :0.000 Min. :0.000 Min. :0.000 Min. :0.000 Min. :0.00 Min. :0.000
1st Qu.:1.000 1st Qu.:3.000 1st Qu.:2.000 1st Qu.:4.000 1st Qu.:1.00 1st Qu.:4.000
Median :1.000 Median :4.000 Median :3.000 Median :5.000 Median :2.00 Median :4.000
Mean :1.225 Mean :3.699 Mean :3.267 Mean :4.328 Mean :1.98 Mean :4.017
3rd Qu.:1.000 3rd Qu.:5.000 3rd Qu.:4.000 3rd Qu.:5.000 3rd Qu.:2.25 3rd Qu.:5.000
Max. :3.000 Max. :6.000 Max. :6.000 Max. :6.000 Max. :6.00 Max. :6.000
prix produits_laitiers_oeuf profession regime remarquer_logos sensible_climat
Min. :0.000 Min. :0.000 Min. :0.000 Min. :0.000 Min. :0.000 Min. :0.000
1st Qu.:3.000 1st Qu.:2.000 1st Qu.:1.000 1st Qu.:2.000 1st Qu.:1.000 1st Qu.:4.000
Median :3.000 Median :2.000 Median :1.000 Median :3.000 Median :1.000 Median :5.000
Mean :3.319 Mean :2.542 Mean :1.936 Mean :3.277 Mean :1.184 Mean :4.468
3rd Qu.:4.000 3rd Qu.:3.000 3rd Qu.:2.250 3rd Qu.:5.000 3rd Qu.:1.000 3rd Qu.:5.000
Max. :6.000 Max. :6.000 Max. :5.000 Max. :6.000 Max. :2.000 Max. :6.000
temps tenir_compte_logos viande_blanche viande_rouge resto Nom
Min. :0.00 Min. :0.000 Min. :0.000 Min. :0.000 Domus:185 :223
1st Qu.:3.00 1st Qu.:1.000 1st Qu.:3.000 1st Qu.:3.000 ECL :145 ?:185
Median :4.00 Median :2.000 Median :4.000 Median :4.000 Puvis: 78
Mean :3.39 Mean :1.855 Mean :3.647 Mean :3.858
3rd Qu.:4.00 3rd Qu.:3.000 3rd Qu.:4.000 3rd Qu.:5.000
Max. :6.00 Max. :3.000 Max. :6.000 Max. :6.000
d<-d[which(d$tenir_compte_logos!=0),]
d$tenir_compte_logos <- factor(d$tenir_compte_logos, levels=sort(unique(d$tenir_compte_logos)))
d<-d[which(d$resto!=0),]
d$resto <- factor(d$resto, levels=sort(unique(d$resto)))
d<-d[which(d$sensible_climat!=0),]
d$sensible_climat <- factor(d$sensible_climat, levels=sort(unique(d$sensible_climat)))
d<-d[which(d$changer_hab_alim!=0),]
d$changer_hab_alim <- factor(d$changer_hab_alim, levels=sort(unique(d$changer_hab_alim)))
d<-d[which(d$profession!=0),]
d$profession <- factor(d$profession, levels=sort(unique(d$profession)))
d<-d[which(d$genre!=0),]
d$genre <- factor(d$genre, levels=sort(unique(d$genre)))
d<-d[which(d$age!=0),]
d$age <- factor(d$age, levels=sort(unique(d$age)))
d$tenir_compte_logos_2 <- relevel(d$tenir_compte_logos, ref = "1") #d$tenir_compte_logos
perform_multinomial_regression <- function (formule, d) {
formule2<- as.formula(formule)
tenir_compte <- multinom(formula=formule2, data=d)
tmp <- summary(tenir_compte)
print(tmp)
return(tmp$AIC)
}
### DOES NOT WORK FOR SOME REASON
formula_tenir_compte_const <- as.formula(tenir_compte_logos_2 ~ 1 )
tenir_compte_const <- summary(multinom(formula=formula_tenir_compte_const, data=d))
# weights: 6 (2 variable)
initial value 346.062871
final value 337.998183
converged
AIC_const <- tenir_compte_const$AIC
formula_tenir_compte_genre <- as.formula(tenir_compte_logos_2 ~ genre )
tenir_compte_genre <- summary(multinom(formula=formula_tenir_compte_genre, data=d))
# weights: 12 (6 variable)
initial value 346.062871
iter 10 value 334.633284
final value 334.569171
converged
AIC_genre <- tenir_compte_genre$AIC
formula_tenir_compte_resto <- as.formula(tenir_compte_logos_2 ~ resto )
tenir_compte_resto <- summary(multinom(formula=formula_tenir_compte_resto, data=d))
# weights: 12 (6 variable)
initial value 346.062871
iter 10 value 331.672383
final value 331.668634
converged
AIC_resto <- tenir_compte_resto$AIC
formula_tenir_compte_age <- as.formula(tenir_compte_logos_2 ~ age )
tenir_compte_age <- summary(multinom(formula=formula_tenir_compte_age, data=d))
# weights: 21 (12 variable)
initial value 346.062871
iter 10 value 331.178347
iter 20 value 330.885758
final value 330.884143
converged
AIC_age <- tenir_compte_age$AIC
formula_tenir_compte_profession <- as.formula(tenir_compte_logos_2 ~ profession )
tenir_compte_profession <- summary(multinom(formula=formula_tenir_compte_profession, data=d))
# weights: 18 (10 variable)
initial value 346.062871
iter 10 value 334.906188
final value 334.904657
converged
AIC_profession <- tenir_compte_profession$AIC
formula_tenir_compte_sensible_climat <- as.formula(tenir_compte_logos_2 ~ sensible_climat )
tenir_compte_sensible_climat <- summary(multinom(formula=formula_tenir_compte_sensible_climat, data=d))
# weights: 21 (12 variable)
initial value 346.062871
iter 10 value 320.483239
iter 20 value 319.983810
final value 319.981651
converged
AIC_sensible_climat <- tenir_compte_sensible_climat$AIC
formula_tenir_compte_changer_hab_alim <- as.formula(tenir_compte_logos_2 ~ changer_hab_alim )
tenir_compte_changer_hab_alim <- summary(multinom(formula=formula_tenir_compte_changer_hab_alim, data=d))
# weights: 21 (12 variable)
initial value 346.062871
iter 10 value 311.533245
iter 20 value 309.101188
final value 309.095624
converged
AIC_changer_hab_alim <- tenir_compte_changer_hab_alim$AIC
AICs_single <- c("AIC_const", "AIC_genre", "AIC_resto", "AIC_age", "AIC_profession", "AIC_sensible_climat", "AIC_changer_hab_alim")
for (i in 1:length(AICs_single)) { cat( AICs_single[i], get(AICs_single[i]), sep=" : ", fill=TRUE) }
AIC_const : 679.9964
AIC_genre : 681.1383
AIC_resto : 675.3373
AIC_age : 685.7683
AIC_profession : 689.8093
AIC_sensible_climat : 659.9633
AIC_changer_hab_alim : 642.1912
The variable which best explains whether the logo was used or not is changer_hab_alim, then it is sensible_climat, then resto. The other variables, including profession and age, do not explain whether people used the logo or not.
formula_tenir_compte_several <- as.formula(tenir_compte_logos_2 ~ changer_hab_alim + sensible_climat + resto )
tenir_compte_several <- summary(multinom(formula=formula_tenir_compte_several, data=d))
# weights: 42 (26 variable)
initial value 346.062871
iter 10 value 298.085207
iter 20 value 290.902041
iter 30 value 290.526439
final value 290.525167
converged
NaNs produced
AIC_several <- tenir_compte_several$AIC
print(AIC_several)
[1] 629.0503
The model including the variables changer_hab_alim, sensible_climat and resto is the best one in terms of AIC.
print(tenir_compte_several)
Call:
multinom(formula = formula_tenir_compte_several, data = d)
Coefficients:
(Intercept) changer_hab_alim2 changer_hab_alim3 changer_hab_alim4 changer_hab_alim5 changer_hab_alim6
2 27.436726 -2.759198 -36.736410 -38.115255 -38.894699 -12.88578
3 9.780258 39.778634 6.727016 5.950062 5.222356 31.83942
sensible_climat2 sensible_climat3 sensible_climat4 sensible_climat5 sensible_climat6 restoECL restoPuvis
2 21.39824 11.71866 13.02542 11.24025 0 -1.1497801 1.1885035
3 -15.71478 -15.82012 -13.71854 -15.18606 0 -0.4577682 0.6418063
Std. Errors:
(Intercept) changer_hab_alim2 changer_hab_alim3 changer_hab_alim4 changer_hab_alim5 changer_hab_alim6
2 51.72707 10.07722 10.06206 10.05715 10.05683 10.09059
3 51.84498 10.07722 10.10186 10.09654 10.09618 10.09059
sensible_climat2 sensible_climat3 sensible_climat4 sensible_climat5 sensible_climat6 restoECL restoPuvis
2 235.6312 61.78386 61.78018 61.77914 NaN 0.3724295 0.4912884
3 235.6312 61.94302 61.93747 61.93648 0 0.3437635 0.5187916
Residual Deviance: 581.0503
AIC: 629.0503
As the users declare that they are willing to change their food habits, we see that they are less likely to have never used the logos. Users at the Puvis restaurant are less likely to use the logo than those at ECL.
d<-read.table("table_reponses_qu.csv", h=T, sep=";")
d<-d[which(d$viande_rouge!=0),]
d$viande_rouge <- factor(d$viande_rouge, levels=sort(unique(d$viande_rouge)))
d<-d[which(d$sensible_climat!=0),]
d$sensible_climat <- factor(d$sensible_climat, levels=sort(unique(d$sensible_climat)))
d<-d[which(d$changer_hab_alim!=0),]
d$changer_hab_alim <- factor(d$changer_hab_alim, levels=sort(unique(d$changer_hab_alim)))
d<-d[which(d$resto!=0),]
d$resto <- factor(d$resto, levels=sort(unique(d$resto)))
d<-d[which(d$profession!=0),]
d$profession <- factor(d$profession, levels=sort(unique(d$profession)))
d<-d[which(d$genre!=0),]
d$genre <- factor(d$genre, levels=sort(unique(d$genre)))
d<-d[which(d$age!=0),]
d$age <- factor(d$age, levels=sort(unique(d$age)))
# d<-d[which(d$viande_blanche!=0),]
# d$viande_blanche <- factor(d$viande_blanche, levels=sort(unique(d$viande_blanche)))
# d<-d[which(d$produits_laitiers_oeuf!=0),]
# d$produits_laitiers_oeuf <- factor(d$produits_laitiers_oeuf, levels=sort(unique(d$produits_laitiers_oeuf)))
# d<-d[which(d$poisson!=0),]
# d$poisson <- factor(d$poisson, levels=sort(unique(d$poisson)))
d$viande_rouge <- relevel(d$viande_rouge, ref = "1")
The reference is “eating red meat at all meals”.
formula_tenir_compte_constant <- as.formula(viande_rouge ~ 1 )
tenir_compte_constant <- summary(multinom(formula=formula_tenir_compte_constant, data=d))
# weights: 12 (5 variable)
initial value 596.655903
iter 10 value 468.997833
final value 468.698118
converged
AIC_constant <- tenir_compte_constant$AIC
print(AIC_constant)
[1] 947.3962
formula_tenir_compte_age <- as.formula(viande_rouge ~ age )
tenir_compte_age <- summary(multinom(formula=formula_tenir_compte_age, data=d))
# weights: 42 (30 variable)
initial value 596.655903
iter 10 value 463.717558
iter 20 value 452.620490
iter 30 value 451.696034
iter 40 value 451.682402
final value 451.682342
converged
AIC_age <- tenir_compte_age$AIC
print(AIC_age)
[1] 963.3647
formula_tenir_compte_genre <- as.formula(viande_rouge ~ genre )
tenir_compte_genre <- summary(multinom(formula=formula_tenir_compte_genre, data=d))
# weights: 24 (15 variable)
initial value 596.655903
iter 10 value 462.381838
iter 20 value 460.796991
iter 30 value 460.775659
final value 460.775475
converged
AIC_genre <- tenir_compte_genre$AIC
print(AIC_genre)
[1] 951.551
formula_tenir_compte_profession <- as.formula(viande_rouge ~ profession )
tenir_compte_profession <- summary(multinom(formula=formula_tenir_compte_profession, data=d))
# weights: 36 (25 variable)
initial value 596.655903
iter 10 value 464.058501
iter 20 value 457.277260
iter 30 value 456.490542
iter 40 value 456.420038
final value 456.419545
converged
AIC_profession <- tenir_compte_profession$AIC
print(AIC_profession)
[1] 962.8391
formula_tenir_compte_resto <- as.formula(viande_rouge ~ resto )
tenir_compte_resto <- summary(multinom(formula=formula_tenir_compte_resto, data=d))
# weights: 24 (15 variable)
initial value 596.655903
iter 10 value 469.504075
iter 20 value 465.040223
final value 464.996426
converged
AIC_resto <- tenir_compte_resto$AIC
print(AIC_resto)
[1] 959.9929
formula_tenir_compte_sensible_climat <- as.formula(viande_rouge ~ sensible_climat )
tenir_compte_sensible_climat <- summary(multinom(formula=formula_tenir_compte_sensible_climat, data=d))
# weights: 42 (30 variable)
initial value 596.655903
iter 10 value 454.838216
iter 20 value 445.389019
iter 30 value 444.359666
iter 40 value 444.346883
final value 444.346791
converged
NaNs produced
AIC_sensible_climat <- tenir_compte_sensible_climat$AIC
print(AIC_sensible_climat)
[1] 938.6936
formula_tenir_compte_changer_hab_alim <- as.formula(viande_rouge ~ changer_hab_alim )
tenir_compte_changer_hab_alim <- summary(multinom(formula=formula_tenir_compte_changer_hab_alim, data=d))
# weights: 42 (30 variable)
initial value 596.655903
iter 10 value 446.213951
iter 20 value 431.584612
iter 30 value 430.558039
iter 40 value 430.526262
final value 430.526004
converged
AIC_several <- tenir_compte_changer_hab_alim$AIC
print(AIC_changer_hab_alim)
[1] 642.1912
AICs_single <- c("AIC_constant", "AIC_genre", "AIC_resto", "AIC_age", "AIC_profession", "AIC_sensible_climat", "AIC_changer_hab_alim")
for (i in 1:length(AICs_single)) { cat( AICs_single[i], get(AICs_single[i]), sep=" : ", fill=TRUE) }
AIC_constant : 947.3962
AIC_genre : 951.551
AIC_resto : 959.9929
AIC_age : 963.3647
AIC_profession : 962.8391
AIC_sensible_climat : 938.6936
AIC_changer_hab_alim : 642.1912
The variable with the best explanatory variable for the consumption of red meat is changer_hab_alim, then it is sensible_climat. The other variables do not help.
formula_tenir_compte_several <- as.formula(viande_rouge ~ changer_hab_alim + sensible_climat )
tenir_compte_several <- summary(multinom(formula=formula_tenir_compte_several, data=d))
# weights: 72 (55 variable)
initial value 596.655903
iter 10 value 440.273626
iter 20 value 420.446825
iter 30 value 415.925200
iter 40 value 414.930011
iter 50 value 414.806924
iter 60 value 414.803020
final value 414.802998
converged
NaNs produced
AIC_several <- tenir_compte_several$AIC
print(AIC_several)
[1] 929.606
The combined model is not as good as the model with just changer_hab_alim. Let’s have a look at the parameters for this latter model.
print(tenir_compte_changer_hab_alim)
Call:
multinom(formula = formula_tenir_compte_changer_hab_alim, data = d)
Coefficients:
(Intercept) changer_hab_alim2 changer_hab_alim3 changer_hab_alim4 changer_hab_alim5 changer_hab_alim6
2 13.80936 -13.80956 -12.71113 -13.810580 12.28553 -15.717679
3 14.09688 -12.71073 -11.00615 -10.919538 14.07735 15.902997
4 13.80931 -12.71089 -11.03701 -9.821037 15.68669 16.190449
5 13.40346 -12.30498 -11.61193 -10.226024 15.82689 -9.992251
6 -11.29461 -17.76082 12.39302 11.987203 39.95439 -2.553339
Std. Errors:
(Intercept) changer_hab_alim2 changer_hab_alim3 changer_hab_alim4 changer_hab_alim5 changer_hab_alim6
2 0.6741687 1.361328e+00 1.1141406 1.3520570 0.7584673 1.551454e-14
3 0.6425439 1.073178e+00 0.9728213 0.9710066 0.5307285 8.036337e-01
4 0.6741742 1.125470e+00 1.0015110 0.9819046 0.5449056 8.036337e-01
5 0.7334394 1.161934e+00 1.0853931 1.0334026 0.6190845 5.142881e-12
6 0.5151042 1.082418e-12 0.8879311 0.9307621 0.3093012 1.047816e-19
Residual Deviance: 861.052
AIC: 921.052
It seems like people who say they are “tout-à-fait d’accord” with changing their food habits tend to eat less red meat.