Modele_choix_discret_mlogit

Application au choix des consommateurs pour les marques de Yogurt

library(Ecdat)
Loading required package: Ecfun

Attaching package: 'Ecfun'
The following object is masked from 'package:base':

    sign

Attaching package: 'Ecdat'
The following object is masked from 'package:datasets':

    Orange
library(mlogit)
Loading required package: dfidx

Attaching package: 'dfidx'
The following object is masked from 'package:stats':

    filter
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks dfidx::filter(), stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(kableExtra)

Attaching package: 'kableExtra'

The following object is masked from 'package:dplyr':

    group_rows
library(ggthemes)
library(stargazer)

Please cite as: 

 Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
 R package version 5.2.3. https://CRAN.R-project.org/package=stargazer 
library(tinytex)
library(AER)
Loading required package: car
Loading required package: carData

Attaching package: 'carData'

The following object is masked from 'package:Ecdat':

    Mroz


Attaching package: 'car'

The following object is masked from 'package:dplyr':

    recode

The following object is masked from 'package:purrr':

    some

Loading required package: lmtest
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: sandwich
Loading required package: survival
library(knitr)
tinytex::install_tinytex(force=TRUE)
tlmgr option sys_bin ~/bin
tlmgr option repository 'https://ctan.mirrors.hoobly.com/systems/texlive/tlnet'
tlmgr update --list
tinytex::is_tinytex()
[1] TRUE

Chargement des données

df<- Yogurt
head(df)
  id feat.yoplait feat.dannon feat.hiland feat.weight price.yoplait
1  1            0           0           0           0          10.8
2  1            0           0           0           0          10.8
3  1            0           0           0           0          10.8
4  1            0           0           0           0          10.8
5  1            0           0           0           0          12.5
6  1            0           0           0           0          10.8
  price.dannon price.hiland price.weight choice
1          8.1          6.1          7.9 weight
2          9.8          6.4          7.5 dannon
3          9.8          6.1          8.6 dannon
4          9.8          6.1          8.6 dannon
5          9.8          4.9          7.9 dannon
6          9.2          5.0          7.9 dannon

Manipulation pour supprimer feat et price des en-têtes

names(df)<- gsub("^feat\\.","",names(df))
names(df)<- gsub("^price\\.","",names(df))
df%>%head(10)%>%knitr::kable(caption="Le tableau de données brutes Yogurt (les 10 premières lignes")%>%kable_styling()%>%add_header_above(align=c)
Le tableau de données brutes Yogurt (les 10 premières lignes
id yoplait dannon hiland weight yoplait dannon hiland weight choice
1 0 0 0 0 10.8 8.1 6.1 7.9 weight
1 0 0 0 0 10.8 9.8 6.4 7.5 dannon
1 0 0 0 0 10.8 9.8 6.1 8.6 dannon
1 0 0 0 0 10.8 9.8 6.1 8.6 dannon
1 0 0 0 0 12.5 9.8 4.9 7.9 dannon
1 0 0 0 0 10.8 9.2 5.0 7.9 dannon
1 0 0 0 0 10.3 8.1 4.9 7.9 dannon
1 0 0 0 0 10.8 8.6 5.4 7.9 weight
2 0 0 0 0 10.8 9.8 5.0 7.9 yoplait
2 0 0 0 0 10.8 9.8 5.0 7.9 yoplait