I just want to mention the very nice work of Naël Shiab, with a lovely interactive notebook created to help journalists understand math concepts often used in news stories.
Category Archives: Statistics
Alternative fixed-effects panel model using weighted asymmetric least squares regression
Our paper, Alternative fixed-effects panel model using weighted asymmetric least squares regression, with Amadou and Karim, is now published by Statistical Methods & Applications.
A fixed-effects model estimates the regressor effects on the mean of the response, which is inadequate to account for heteroscedasticity. In this paper, we adapt the asymmetric least squares (expectile) regression to the fixed-effects panel model and propose a new model: expectile regression with fixed effects (ERFE). The ERFE model applies the within transformation strategy to solve the incidental parameter problem and estimates the regressor effects on the expectiles of the response distribution. The ERFE model captures the data heteroscedasticity and eliminates any bias resulting from the correlation between the regressors and the omitted factors. We derive the asymptotic properties of the ERFE estimators and suggest robust estimators of its covariance matrix. Our simulations show that the ERFE estimator is unbiased and outperforms its competitors. Our real data analysis shows its ability to capture data heteroscedasticity
More online… doi:10.1007/s10260-023-00692-3
Talk at StatQAM on Counterfactuals and Optimal Transport
Next Thursday, I will present our recent work at the StatQAM seminar, with Emmanuel Flachaire ajd Ewen Gallic, on Optimal Transport for Counterfactual Estimation: A Method for Causal Inference
Many problems ask a question that can be formulated as a causal question: “what would have happened if…?” For example, “would the person have had surgery if he or she had been Black?” To address this kind of questions, calculating an average treatment effect (ATE) is often uninformative, because one would like to know how much impact a variable (such as skin color) has on a specific individual, characterized by certain covariates. Trying to calculate a conditional ATE (CATE) seems more appropriate. In causal inference, the propensity score approach assumes that the treatment is influenced by x, a collection of covariates. Here, we will have the dual view: doing an intervention, or changing the treatment (even just hypothetically, in a thought experiment, for example by asking what would have happened if a person had been Black) can have an impact on the values of x. We will see here that optimal transport allows us to change certain characteristics that are influenced by the variable we are trying to quantify the effect of. We propose here a mutatis mutandis version of the CATE, which will be done simply in dimension one by saying that the CATE must be computed relative to a level of probability, associated to the proportion of x (a single covariate) in the control population, and by looking for the equivalent quantile in the test population. In higher dimension, it will be necessary to go through transport, and an application will be proposed on the impact of some variables on the probability of having an unnatural birth (the fact that the mother smokes, or that the mother is Black).
Slides are now online.
Snow in Montréal (Canada)
Winter started a bit more than one month ago… but we have already experienced many snow storms… there is still a lot snow in gardens and in the streets,
I was wondering if it was that unusual, but apparently not. Compared with last year, it is (for the first months of winter, until the end of Januray), it +50%, but it is comparable with previous years
Yes, we a simple loop, we can easily extract data from official wesite https://climat.meteo.gc.ca/ (but not too far away, even 2015 contains a lot of missing observations). For this month, we use
url = "https://climat.meteo.gc.ca/climate_data/daily_data_f.html?StationID=51157&timeframe=2&StartYear=1840&EndYear=2023&Day=30&Year=2023&Month=1#" library(XML) library(stringr) download.file(url,destfile = "M.html") tables=readHTMLTable("M.html") k = which(tables[[1]]$`JOUR `=="Somme") neige = tables[[1]]$`Neige tot. Definitioncm `[k] x = as.numeric(sub(",", ".", strsplit(neige, "LegendCarer")[[1]][1], fixed = TRUE))
and then we loop, and store the number we look for in a data frame (yes, we have to convert “50,8LegendCarer^” into the appropriate numerical value (that would be here 50.8…
D = data.frame(annee = c(2023,rep(2022:2015,each=12),c(12,11,10)), mois= c(1,rep(12:1,8),12,11,10), lab = neige, snow = x) for(i in 2:nrow(D)){ y = D$annee[i] m = D$mois[i] url = paste("https://climat.meteo.gc.ca/climate_data/daily_data_f.html?StationID=51157&timeframe=2&StartYear=1840&EndYear=2023&Day=30&Year=",y,"&Month=",m,"#",sep="") download.file(url,destfile = "M.html") tables=readHTMLTable("M.html") k = which(tables[[1]]$`JOUR `=="Somme") neige = tables[[1]]$`Neige tot. Definitioncm `[k] x = as.numeric(sub(",", ".", strsplit(neige, "LegendCarer")[[1]][1], fixed = TRUE)) D[i,3] = neige D[i,4] = x }
Here are the most recent months
> head(D) annee mois lab snpw 1 2023 1 50,8LegendCarer^ 50.8 2 2022 12 63,0 63.0 3 2022 11 14,6 14.6 4 2022 10 0,0 0.0 5 2022 9 0,0 0.0 6 2022 8 0,0 0.0
Of course, we need some codes to plot, we here, I mainly wanted to keep tracks of the code used to extract meteorological data…
Optimal Transport for Counterfactual Estimation: A Method for Causal Inference
With Emmanuel Flachaire et Ewen Gallic, we recently uploaded a paper entitled Optimal Transport for Counterfactual Estimation: A Method for Causal Inference on ArXiv.
Many problems ask a question that can be formulated as a causal question: “what would have happened if…?” For example, “would the person have had surgery if he or she had been Black?” To address this kind of questions, calculating an average treatment effect (ATE) is often uninformative, because one would like to know how much impact a variable (such as skin color) has on a specific individual, characterized by certain covariates. Trying to calculate a conditional ATE (CATE) seems more appropriate. In causal inference, the propensity score approach assumes that the treatment is influenced by x, a collection of covariates. Here, we will have the dual view: doing an intervention, or changing the treatment (even just hypothetically, in a thought experiment, for example by asking what would have happened if a person had been Black) can have an impact on the values of x. We will see here that optimal transport allows us to change certain characteristics that are influenced by the variable we are trying to quantify the effect of. We propose here a mutatis mutandis version of the CATE, which will be done simply in dimension one by saying that the CATE must be computed relative to a level of probability, associated to the proportion of x (a single covariate) in the control population, and by looking for the equivalent quantile in the test population. In higher dimension, it will be necessary to go through transport, and an application will be proposed on the impact of some variables on the probability of having an unnatural birth (the fact that the mother smokes, or that the mother is Black).
Slides from a talk given last week are online.
Quantifying fairness and discrimination in predictive models
In about ten days, late in the evening (Montréal time), I will attend the 16th Annual Conference of Thailand Econometric Society (on Machine Learning for Econometrics and Related Topics), at Chiang Mai University (มหาวิทยาลัยเชียงใหม่). I will give a talk (introductionary talk, at 21:30 pm, with the jet lag) on quantifying fairness and discrimination in predictive models (the state-of-the-art paper I will present is online on arXiv) and the slides are now also available (I won’t be able to go to Chiang Mai, unfortunately, and I will be on zoom).
The analysis of discrimination has long interested economists and lawyers. In recent years, the literature in computer science and machine learning has become interested in the subject, offering an interesting re-reading of the topic. These questions are the consequences of numerous criticisms of algorithms used to translate texts or to identify people in images. With the arrival of massive data, and the use of increasingly opaque algorithms, it is not surprising to have discriminatory algorithms, because it has become easy to have a proxy of a sensitive variable, by enriching the data indefinitely. According to Kranzberg (1986), “technology is neither good nor bad, nor is it neutral”, and therefore, “machine learning won’t give you anything like gender neutrality `for free’ that you didn’t explicitely ask for”, as claimed by Kearns et a. (2019). In this article, we will come back to the general context, for predictive models in classification. We will present the main concepts of fairness, called group fairness, based on independence between the sensitive variable and the prediction, possibly conditioned on this or that information. We will finish by going further, by presenting the concepts of individual fairness. Finally, we will see how to correct a potential discrimination, in order to guarantee that a model is more ethical
Exposé sur interprétabilité et explicabilité (des modèles prédictifs)
Cet après-midi, je ferais une intervention sur l’explicabilité des modèles prédictifs. Les slides sont en ligne. Les codes utilisés pour produire les graphiques sont dans un précédant billet.
Using “home made” statistics
Since I am still at the Fields Institute in Toronto, enjoying a workshop on Impacts of Climate Change on Economics, Finance, and Insurance, I wanted to share some experience, from this summer. After three years of lockdown because of the covid situation, the family has been able to travel, and we went to France, so that our kids could see their grand-parents (the last visit was a long time ago). And it was hot, very hot. While I was chating with my dad, about the weather, and told me that he had a lot of connected devices in the house, including measures of the temperature. One of the device was in a place where nothing did not really change over time. So I thought it could be sufficient to get robust data. My goal was to see how the popular IPCC graph was on real data
When I got the data, I did plot them, and did compare the distribution back in 2012, and in 2022 (or to be honest, half 2021-half 2022). As for the IPCC graph, I assume a Gaussian distribution.
As expected, there is a clear shift to the right (that is “climate change”). But the most scary part, was actually the linear trend,
Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -637.30455 80.44650 -7.922 3.01e-15 *** x 0.32273 0.03988 8.092 7.72e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 |
with a slope of 0.322, meaning that the average temperature is increasing by 0.322 degrees per year ! That is more than 3°C over the past ten years ! Let me write it again : in a house, +3°C on average over the past ten years.
I thought there were some issues with the data. So I tried to collect some official data, and since there were no official records in their village, I did use the data from Lyon (which is 80 kilometers from their house).
The shift on the right is confirmed here, but unfortuntely, I could not get data after 2020. Now
Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -567.27953 96.26577 -5.893 4.17e-09 *** x 0.28803 0.04776 6.031 1.81e-09 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 |
And here again, I have a slope close to 0.3. So again, mainland, about +3°C over the past 10 years was observed. You might not find that scary, but I do think that it is scary !
Statistique bayésienne, data sciences et nouveaux risques
En cette rentrée, l’Institut des Actuaires lance un cycle de conférences sur le thème Statistique bayésienne, data sciences et nouveaux risques. Comme ils m’ont fait le plaisir et l’honneur d’introduire ce cycle, je ferais un exposé introductif jeudi 22 septembre, en fin d’après midi. Mes slides sont en ligne (je déconseille de les imprimer, j’ai mis des animations qui s’étalent sur plusieurs slides, je conseille plutôt cette version).
Interprétabilité et explicabilité (formalisé) des modèles prédictifs
Dans Confessiones, Saint Augustin écrivait
quid est ergo tempus? si nemo ex me quaerat, scio; si quaerenti explicare velim, nescio
que l’on traduit
Qu’est-ce-que le temps ? Si personne ne me le demande, je le sais. Si je veux l’expliquer à qui me le demande, je ne le sais plus.
Pour aller un peu plus loin (car souvent, si on nous demande d’expliquer, on a quelques idées), dans Une étude en rouge de Sir Arthur Conan Doyle, paru en 1887, on a l’échange suivant, entre Sherlock Holmes et le docteur Watson,
– Je me demande ce que cherche ce type là-bas, demandai-je,
désignant un grand individu habillé simplement qui suivait
l’autre côté de la rue, en examinant anxieusement les numéros.
Il tenait à la main une grande enveloppe bleue et, de toute
évidence, portait un message.
– Vous parlez de ce sergent d’infanterie de marine ? dit Sherlock Holmes.
puis, comme il s’avère que la personne est effectivement sergent dans la marine (tout comme un autre personnage de l’histoire, un certain Arthur Charpentier), le docteur Holmes lui demande une explication, il veut savoir comment il est arrivé à cette conclusion
« Comment diable avez-vous pu deviner cela ? demandai-je.
– Deviner quoi ? fit-il sans aménité.
– Eh bien, qu’il était un sergent de marine en retraite ?
– Je n’ai pas de temps à perdre en bagatelles ! répondit-il
avec brusquerie avant d’ajouter dans un sourire : excusez ma rudesse ! Vous avez rompu le fil de mes pensées. Mais c’est peut-être aussi bien. Ainsi donc vous ne voyiez pas que cet homme était un sergent de marine ?
– Non, certainement pas !
– Décidément, l’explication de ma méthode me coûte plus que son application ! Si l’on vous demandait de prouver que deux et deux font quatre, vous seriez peut-être embarrassé ; et cependant, vous êtes sûr qu’il en est ainsi. Malgré la largeur de la rue, j’avais pu voir une grosse ancre bleue tatouée sur le dos de la main du gaillard. Cela sentait la mer. Il avait la démarche militaire et les favoris réglementaires ; c’était, à n’en pas douter, un marin. Il avait un certain air de commandement et d’importance. Rappelez-vous son port de tête et le balancement de sa canne ! En outre, son visage annonçait un homme d’âge moyen, sérieux, respectable. Tous ces détails m’ont amené à penser qu’il était sergent.
– C’est merveilleux ! m’écriai-je.
– Peuh ! L’enfance de l’art ! dit Holmes, mais d’un air qui me
parut trahir sa satisfaction devant ma surprise et mon admiration manifestes.
(pour être honnête, c’est Liu Cixin qui en parle dans Le problème à trois corps). Pour l’anecdote, c’est la première histoire du couple Holmes-Watson, qui introduit la méthode de travail de Sherlock Holmes. Pour ceux qui sont familier avec les nouvelles, cette approche narrative sera largement reprise par la suite: Sherlock Holmes énonce un fait, le docteur Watson est étonné et demande une explication, et Sherlock Holmes explique, point par point, comment il est arrivé à cette conclusion. C’est un peu cette approche qu’on tente de mettre en place quand on va construire un modèle prédictif : sur la base des données du Titanic, si on prédit que telle personne va mourir, et que telle autre va survivre, on veut comprendre pourquoi le modèle arrive à cette conclusion.
Continue reading Interprétabilité et explicabilité (formalisé) des modèles prédictifs
Interpretability and explainability of predictive models
In 400 AD, in his Confessiones, Augustine wrote
quid est ergo tempus? si nemo ex me quaerat, scio; si quaerenti explicare velim, nescio
that can be translated as
What then is time? If no one asks me, I know what it is. If I wish to explain it to him who asks, I do not know.
To go a little further (because often, if we are asked to explain, we have some ideas), in A Study in Scarlet by Sir Arthur Conan Doyle, published in 1887, we have the following exchange, between Sherlock Holmes and Doctor Watson
– “I wonder what that fellow is looking for?” I asked, pointing to a stalwart, plainly-dressed individual who was walking slowly down the other side of the street, looking anxiously at the numbers. He had a large blue envelope in his hand, and was evidently the bearer of a message.
– “You mean the retired sergeant of Marines,” said Sherlock Holmes.
then, as it turns out that the person is indeed a sergeant in the navy (as is another character in the story, someone named Arthur Charpentier), Dr. Holmes asks him for an explanation, he wants to know how he arrived at this conclusion
– “How in the world did you deduce that?” I asked.
– “Deduce what?” said he, petulantly.
– “Why, that he was a retired sergeant of Marines.”
– “I have no time for trifles,” he answered, brusquely; then with a smile, “Excuse my rudeness. You broke the thread of my thoughts; but perhaps it is as well. So you actually were not able to see that that man was a sergeant of Marines?”
– “No, indeed.”
– “It was easier to know it than to explain why I knew it. If you were asked to prove that two and two made four, you might find some difficulty, and yet you are quite sure of the fact. Even across the street I could see a great blue anchor tattooed on the back of the fellow’s hand. That smacked of the sea. He had a military carriage, however, and regulation side whiskers. There we have the marine. He was a man with some amount of self-importance and a certain air of command. You must have observed the way in which he held his head and swung his cane. A steady, respectable, middle-aged man, too, on the face of him – all facts which led me to believe that he had been a sergeant.”
(to be honest, it is Liu Cixin who talks about it in The Three-Body Problem). For the record, this is the first story of the Holmes-Watson couple, which introduces Sherlock Holmes’ working method. For those who are familiar with the short stories, this narrative approach will be widely used thereafter: Sherlock Holmes states a fact, Dr. Watson is astonished and asks for an explanation, and Sherlock Holmes explains, point by point, how he arrived at this conclusion. This is a bit like the approach we try to implement when we build a predictive model: on the basis of the Titanic data, if we predict that such and such a person will die, and that such and such a person will survive, we want to understand why the model arrives at this conclusion.
Continue reading Interpretability and explainability of predictive models
Collaborative insurance and network structure
Congratulations Philipp, who won the third price for his poster at the Canadian Statistical Conference. Our paper is still online on arxiv, a revised version will be uploaded this summer.
Report des voix entre les deux tours aux élections présidentielles en France
Allez, on va profiter des élections présidentielles, à deux tours, en France, pour jouer un peu, maintenant que les données commencent à être disponibles. On peut avoir les données par département (une centaine) ou par commune (36000)
# département loc_dpt_1 = "https://www.data.gouv.fr/fr/datasets/r/312b99d0-27a7-429e-be8a-b930975545e9" loc_dpt_2 = "https://www.data.gouv.fr/fr/datasets/r/c7b72e78-5e78-4976-995f-30533f0a35d3" # commune loc_com_1 = "https://www.data.gouv.fr/fr/datasets/r/54782507-e795-4f9d-aa70-ed06feba22e3" loc_com_2 = "https://www.data.gouv.fr/fr/datasets/r/1601b027-48d1-42b1-96f1-b0fb49f55aa3" download.file(loc_dpt_1,"dpt1.csv") download.file(loc_dpt_2,"dpt2.csv") d1 = read.csv("dpt1.csv") d2 = read.csv("dpt2.csv") download.file(loc_com_1,"com1.csv") download.file(loc_com_2,"com2.csv") c1 = read.csv("com1.csv") c2 = read.csv("com2.csv") |
Commençons par les départements. On peut récupérer les pourcentages de voix obtenus par les différents candidats, au premier tour, et regarder les pourcentages obtenus par Marine Le Pen. Par exemple, on peut regarder, département par département, le score de Marine Le Pen au premier et au second tour, pour vérifier que le report des voix s’opère bien
D1 = d1[d1$cand_nom=="LE PEN",c("dep_code","cand_rapport_inscrits","cand_rapport_exprim")] D2 = d2[,c("CodeDépartement","LE.PEN.ins","LE.PEN.exp")] names(D1) = c("dep_code","ins1","exp1") names(D2) = c("dep_code","ins2","exp2") D = merge(D1,D2) par(mfrow=c(1,2)) plot(D$ins1,D$ins2,xlab="inscrits (%), premier tour",ylab="inscrits (%), second tour",col=colr2[1]) plot(D$exp1,D$exp2,xlab="exprimés (%), premier tour",ylab="exprimés (%), second tour",col=colr2[2],main="Le Pen / Le Pen",cex.main=1.1) |
Comme on pouvait s’y attendre, on a une belle droite de régression, avec les nombres de voix obtenus, relativement aux inscrits, en bleu, et aux exprimés, à droite. Pour Emmanuel Macron au premier et Marine Le Pen au second tour, on a une belle corrélation négative, mais moins prononcée qu’auparavant. Autrement dit, un département qui votait peu Macron au premier tour a beaucoup voté Le Pen au second
Mais là, on parlait des deux candidats qui se sont maintenus. Si on regarde l’autre candidat de l’extrême droite, les reports sont assez étranges… après, les taux étaient “relativement” faibles au premier tour pour Erik Zemmour.
Pour le candidat en tête à gauche, on a une corrélation négative, mais sur les votes exprimées, on observera des outliers en haut à droite, avec manifestement un vote d’opposition au président sortant dans certains départements
Pour le candidat écologiste, la corrélation est elle encore plus clair
autrement dit, quand on a voté écologiste au premier tour, on avait peu tendance à voter Le Pen (ou disons les départements où on votait fortement écologiste n’ont pas voté Le Pen au second #ecologicalfallacy, etc).
Mais on peut faire le même exercice par commune. Mon seul soucis a été que les codes communes dans les deux bases étaient différents, donc j’ai utilisé les noms des communes, ce que je n’aime pas faire (avec les accents, les tirets, etc, la fusion peut être assez mauvaises… mais là ça marche bien). Je me suis ensuite limité aux grosses communes, de plus de 10000 inscrits,
C1 = c1[c1$cand_nom=="LE PEN",c("commune_name","cand_rapport_inscrits","cand_rapport_exprim","votants_nb")] C2 = c2[,c("Commune","LE.PEN.ins","LE.PEN.exp")] names(C1) = c("com_code","ins1","exp1","taille") names(C2) = c("com_code","ins2","exp2") D = merge(C1,C2) D = D[D$taille>5000,] par(mfrow=c(1,2)) plot(D$ins1,D$ins2,xlab="inscrits (%), premier tour",ylab="inscrits (%), second tour",col=colr2[1]) plot(D$exp1,D$exp2,xlab="exprimés (%), premier tour",ylab="exprimés (%), second tour",col=colr2[2],main="Le Pen / Le Pen",cex.main=1.1) |
On peut alors faire le même exercice, avec Le Pen au premier et second tour
ou Macron au premier, Le Pen au second
On observe des beaux nuages, sur la gauche, respectivement en haut et en bas… Beaucoup de communes qui avaient peu voté pour Le Pen semblent avoir eu peur, et on massivement voté au second pour elle. Alors que ce n’est pas trop le cas pour celles où Le Pen avait obtenu beaucoup de voix. Et pour Macron, c’est en bas à gauche, autrement dit, beaucoup de communes qui n’ont pas voté Macron au premier tour n’ont pas pour autant voté Le Pen au second. Pour ceux que ça amuse, les codes sont disponibles pour regarder qui sont ces communes dans les coins.
Pour Zemmour, c’est assez confus, j’avoue, le personnage est déroutant (ou dégoutant ? comme le suggérait le correcteur automatique)
ou alors Jean Luc Mélanchon
ou la relativement franche corrélation des écologistes, qui semblent résolument aller en sens inverse avec le vote d’extrême droite…
Du “Fichier des Victimes Indemnisées” à DataJust (et inversement)
Alors que je préparais un exposé sur la décision d’aller ou pas au tribunal, dans le cas d’accident de la route (pour une victime), j’ai voulu faire une digression autour de DataJust, en lien avec ce que j’ai pu voir en travaillant sur notre article, sur la base des données du Fichier des Victimes Indemnisées, mis en place dans le cadre de la loi Badinter, en 1985, car ça permet d’avoir une perspective intéressante, il me semble.
En commençant par la fin, DataJust, née du le décret nº 2020-
356 du 27 mars 2020 portant création d’un traitement automatisé de données à caractère personnel a été publié au Journal officiel du 29 mars 2020. L’article 1er du décret du 27 mars 2020 énonce que le ministre de la Justice « est autorisé à mettre en œuvre, pour
une durée de deux ans, un traitement automatisé de données à caractère personnel, dénommé « DataJust », ayant pour finalité le
développement d’un algorithme ». Un « algorithme »… le (gros) mot est lâché. Car autant être clair: comme le rappellent Eugénie Petitprez, et Rodolphe Bigot (dans standard humain ou standardisation
algorithmique de l’évaluation du dommage corporel ?) « la Justice n’a pas la culture de la donnée, ni les réels moyens des ambitions qui lui sont prêtées. S’il n’y a pas de culture de la donnée, c’est parce que depuis toujours la Justice fonctionne fondamentalement à l’encontre de la donnée ». On ne pourrait être difficilement plus clair. Mais les deux premiers articles donnaient des informations intéressantes. Le premier article revient sur les finalités de cet « algorithme » qui sera créé : il doit « servir à : 1 º La réalisation d’évaluations rétrospectives et prospectives des politiques publiques en matière de responsabilité civile ou administrative ; 2º L’élaboration d’un référentiel indicatif d’indemnisation des préjudices corporels (…) ». Mais cet « algorithme » n’est pas tout, car un « algorithme » n’est rien sans données pour apprendre (dans la version moderne de l’apprentissage). Et le second article évoque les données utilisées. Plus précisément, dans les données, figureront « 2º les éléments d’identification des personnes physiques suivants : la date de naissance, le genre, le lien de parenté avec les victimes et le lieu de résidence ; 3º Les données et informations relatives aux préjudices subis, notamment : – la nature et l’ampleur des atteintes à l’intégrité, à la dignité et à l’intimité subies, en particulier la description et la localisation des lésions, les durées d’hospitalisation, les préjudices d’agrément, esthétique, d’établissement, d’impréparation ou sexuel, les souffrances physiques et morales endurées, le déficit fonctionnel, ainsi que le préjudice d’accompagnement et d’affection des proches de la victime directe ; – les différents types de dépenses de santé (notamment frais médicaux, paramédicaux, pharmaceutiques et d’hospitalisation) et d’aménagement (notamment frais de logement, d’équipement et de véhicule adaptés) ; – le coût et la durée d’intervention des personnes amenées à remplacer ou suppléer les victimes dans leurs activités professionnelles ou parentales durant leur période d’incapacité ; – les types et l’ampleur des besoins de la victime en assistance par tierce personne ; – les préjudices scolaires, universitaires ou de formation subis par la victime directe ; – l’état antérieur de la victime, ses prédispositions pathologiques et autres antécédents médicaux ; 4 º Les données relatives à la vie professionnelle et à la situation financière, notamment la profession, le statut, les perspectives d’évolution et droits à la retraite, le montant des gains et pertes de gains professionnels des victimes, ainsi que des responsables ou personnes tenues à réparation ; 5º Les avis des médecins et experts ayant examiné la victime et le montant de leurs honoraires ; 6º Les données relatives à des infractions et condamnations pénales ; 7º Les données relatives à des fautes civiles ; 8º Le numéro des décisions de justice. (….) ». Je vais m’arrêter là mais il y a beaucoup d’information.
En lisant un peu des articles de presse, de juristes (on pourra lire Le raisonnement par algorithme : le fantasme du juge-robot, par exemple de Frédéric Rouvière, ou Le droit isométrique : un nouveau paradigme juridique né de la justice prédictive, de Louis Larret-Chahine) il y a beaucoup de fantasmes autour de de l’intelligence artificielle, des « algorithmes », etc. Ce qui me frappe le plus, c’est que dans un cas très particulier ces données existent (plus ou moins) : c’est le cas des dommages corporels subits par les victimes d’accident de la circulation lors d’accidents automobiles
Il existait auparavant des banques de données des décisions des différentes juridictions, mais rien sur les règlements contractuels, c’est à dire, pour faire simple, lorsque l’assureur offre une indemnité à la victime (et que cette dernière l’accepte). Pour rendre comparables les montants, la loi (qui date de plus de 35 ans) a créé le “fichier national des personnes indemnisées“, où doivent figurer les montants d’indemnités résultant tant des décisions de justices que des transactions avec les assureurs. Cette obligation d’information a été inscrite dans la lettre de la loi. L’article 26 de la loi du 5 juillet 1985 (c’est la petite phrase de l’article L.211-23 du Code des Assurances), « sous le contrôle de l’autorité publique, une publication périodique rend compte des indemnités fixées par les jugements et les transactions ». Et depuis 1989, cette base est accessible (à l’époque, par…. Minitel – 3615 AGRIA). Comme le montre l’extrait que j’indique, il ne s’agit aucunement de garantir un niveau d’indemnisation à la victime, mais seulement de lui assurer la disponibilité de l’information, afin qu’elle puisse juger par elle-même de la valeur des règlements qui lui sont proposés. Je renvoie vers l’accident corporel de la circulation, entre transactionnel et juridictionnel de Evelyne Serverin, Boris Bertin, Simy Elbaz et Sophie Julliot pour un survol passionnant (le rapport date de 1997) !
Dans l’exposé que je donnerai lundi midi, on reviendra sur l’utilisation de ces données, car elles sont riches. Mais complexes à analyser. Un point intéressant, c’est qu’il y a un enregistrement par victime (et non pas par accident). Et pour chaque victime, on a le montant de l’indemnité perçue. Pour un règlement contractuel, c’est le montant offert par l’assureur, et pour un jugement, c’est le montant ordonné par le juge (le montant proposé par l’assureur est alors inconnu). Pour un économètre, c’est un joli problème, quand on essaye de comprendre qui décide d’aller au tribunal. Mais les conclusions de notre étude ont surtout souligné l’incroyable variabilité des indemnités perçues par les victimes. Y compris ceteris paribus sic stantibus. Et compte tenu du nombre d’information à disposition, cela signifie que l’on peut regarder à âge de la victime donné, à genre donné, à lieu de résidence donné, à gravité de l’accident donné (niveau d’IPP, nombre de jours d’hospitalisation, etc). Si cet « algorithme » est simplement un barème, une grille indicative d’indemnisation, j’imagine que l’idée est louable. Si notre modélisation donne des niveaux obtenus au tribunal et après négociation avec l’assureur très proches, la variabilité quand on compare aux montants réellement observés est colossale ! Dans notre étude, on observe une personne qui aurait eu un accident en 1996, dans la région d’Aix-en-Provence, passager, d’un peu plus de 50 ans, qui a passé un peu moins de 2 ans à l’hôpital. Alors que nos modèles prédisent un dommage corporel de l’ordre de 65,000 euros, elle a touché presque 100,000 euros (au tribunal). Un homme dans la région de Rennes, un peu moins de 50 ans, qui a passé moins de 2 ans à l’hôpital aurait du toucher selon nos modèles de l’ordre de 130,000 euros, et il a accepté les 100,000 euros proposés par l’assureur. Et ce ne sont que deux exemples pris au hasard.
La variabilité observé pour des victimes « semblables » (le fameux ceteris paribus sic stantibus) rend mal à l’aise, et laisse à penser qu’un barême national serait bénéfique à tous et à toutes (je ne parlerais pas ici des différences entre les hommes et les femmes que nous observons, là encore des victimes « semblables » … ou de la différence entre les lieux des accidents, en particulier entre Aix-Marseille et Rennes). Avoir des données pour mieux comprendre comment sont indemnisées les victimes d’accidents corporels est essentiel pour avoir un minimum de justice. Et DataJust n’apporte finalement rien de plus que ce que proposait la loi Badinter (tant que l’« algorithme » reste un modèle de régression – même si ici, on est dans cas de données dépendantes limitées pour reprendre la terminologie de Madalla (1983), qui restent des modèles classiques d’économétrie, mais qui pourraient ressembler à de la magie noire de l’intelligence artificielle à un juriste éloigné des techniques statistiques de base).
Bref, j’étais étonné de voir autant de plumes s’élever contre DataJust, surtout quand on voit que des choses très proches existent depuis 35 ans, avec des finalités louables
En l’occurrence, notre étude montre que les cours donnent des indemnités très différentes, et c’est problématique. La culture de la donnée, et des modèles, est indispensable si on veut un minimum de transparence et d’équité. C’est qu’évoque le retrait de DataJust, ou la fausse défaite des barèmes de Vincent Rivollier, Manon Viglino et Christophe Quézel-Ambrunaz.
Mais cela suppose d’avoir des historiques de données importants (dans notre cas, avec seulement 20 ans de données, on a du mal à avoir des estimations robustes, en grande partie à cause de la très grande variabilité des montants), et des données fiables, et bien renseignées. Car ensuite l’interprétation devient complexe: lorsque nous avions présenté nos résultats il y a quelques années, on nous avait fait remarqué que si les montants ne sont pas « semblables » alors que les victimes le sont, c’est peut-être qu’elles ne sont pas aussi « semblables » qu’elles semblent l’être. En particulier, les informations relativement subjectives (que je dirais sorties d’un « algorithme » si je voulais être taquin) comme le niveau d’I.P.P. – Incapacité Permanente Partielle – n’est peut être pas attribué de la même manière à tout le monde. Au lieu de monter sur ses grands chevaux quand on parle d’ « algorithme », il serait intéressant d’écouter les personnes qui font de l’économie de la justice, ou de statistique de la justice. Et je suis content, parce que je vais les rencontrer cette semaine lors de mon passage à Paris ! À suivre donc…
Could there be incentives to cycle through a red light?
This is of course a rhetorical question! Because cyclists must stop when the light is red! … But … there is always that moment, on a bicycle, when you stop, and then you say to yourself
the worst part is that the lights are badly regulated, and I know that the next one will also be red once I will reach it … whereas if I had passed, I would have had the next one, and who knows, maybe a green wave afterwards?
Not having wanted to try the experiment with my bike, I wanted to try using simulations, on my computer.
Let us assume that in my city, there are red lights every 250 m, and they go from red to green in 1 minute, and similarly from green to red. Then, I can use a simple loop, where I compute the time from home, each time I pass a light: either the light is green, I go through, and I do not wait; or the light is red, then I wait, until the end of the minute. Here is the code. First, I define the constant parameter, with lights every 250 m, light turning either red or green every 1 minute, and I assume a constant speed here, of 15/60 km per min (or 15km per hour).
v = 15/60 d = .250 t = 1 |
Suppose that the office is at 10 km from home. The code to compute the time is simply (I do add a random noise on the time it takes to reach the next light, I will get back to that later on)
Dist = seq(0,10,by=.25) Time1=rep(NA,length(D)) Time1[1]==0 for(k in 2:length(Dist)){ noise=rnorm(1,sd=.05) Time1[k]=Time1[k-1]+d/v+noise if((floor(Time1[k])%%2==0)&(k<length(Dist))) Time1[k]=ceiling(Time1[k]) } |
I can now visualize myself on my bike
T=seq(0,60,by=1/60) colr = c("red","green") plot(T,T*v,col="white") for(k in 1:40){ points(T,rep(d*k,length(T)),cex=.3,pch=15,col=colr[rep(1:2,each=t*60)]) } points(Time1,Dist,pch=19,cex=.5) |
Here, it took me about 51 min to reach the office. And each time I have a red light, I stop and wait. Here is the distribution of the time it will take, as a function of my speed
simul = function(v=.250,sd=.05){ Dist = seq(0,10,by=.25) Time1=Time2=rep(NA,length(D)) Time1[1]=Time2[1]=0 for(k in 2:length(Dist)){ noise=rnorm(1,sd=sd) Time1[k]=Time1[k-1]+d/v+noise if((floor(Time1[k])%%2==0)&(k<length(Dist))) Time1[k]=ceiling(Time1[k]) } max(Time1) } S=function(v=.250,sd=.05,n=1000){ Vectorize(function(x) simul(v=x,sd=sd))(rep(v,n)) } vit = seq(.2,.3,length=101) MS = Vectorize(function(x) S(v=x,sd=.05))(vit) qMSsup = apply(MS,2,function(x) quantile(x,.95)) qMSinf = apply(MS,2,function(x) quantile(x,.05)) MSmed = apply(MS,2,function(x) quantile(x,.5)) MSmean = apply(MS,2,mean) par(mfrow = c(1,1)) plot(vit,MSmed,type="l") polygon(c(vit,rev(vit)),c(qMSinf,rev(qMSsup)),col="light blue",border=NA) lines(vit,MSmed,lwd=2) |
Obviously, on average, the faster I cycle, the shorter the ride will be. Of course, 40 min is not a (real) lower bound : if I go much faster, it can be a rather quick ride
Now, consider a simple rhetorical alternative. What if I decide to go through a red light (after checking that there is no danger), say, with 1 chance of out 20 ?
simul_random = function(v=.250,sd=.05){ Dist = seq(0,10,by=.25) Time1=rep(NA,length(D)) Time1[1]=0 for(k in 2:length(Dist)){ noise=rnorm(1,sd=sd) Time1[k]=Time1[k-1]+d/v+noise red = sample(c(0,1),size=1,prob = c(.95,.05)) if((floor(Time1[k])%%2==0)&(k<length(Dist))&(red == 0)) Time1[k]=ceiling(Time1[k]) } max(Time1) } |
Here, 1 chance out of 20 could mean that on a 10 km ride, I wil always stop : first, I need a red light, and then 95% of the time, I stop. Here is the average distribution, with confidence bands
S_random=function(v=.250,sd=.05,n=1000){ Vectorize(function(x) simul_random(v=x,sd=sd))(rep(v,n)) } MS3 = Vectorize(function(x) S_random(v=x,sd=.05))(vit) qMSsup3 = apply(MS3,2,function(x) quantile(x,.95)) qMSinf3 = apply(MS3,2,function(x) quantile(x,.05)) MSmed3 = apply(MS3,2,function(x) quantile(x,.5)) |
It is possible to compare the two actually (on average times)
plot(MSmed,MSmed3,type="l") abline(a=0,b=1,col="red",lty=2) plot(MSmed,(MSmed-MSmed3)/MSmed*100,type="l") |
which means that, somehow I can save some time, maybe from 3% to 5% if I do not cycle to fast, otherwise probably less than 2%. I would not claim, here, that it is worth it.
Consider another rhetorical alternative. What if I decide to go through the red light only if it is during the very first second ?
simul_1sec = function(v=.250,sd=.05){ Dist = seq(0,10,by=.25) Time1=rep(NA,length(D)) Time1[1]=0 for(k in 2:length(Dist)){ noise=rnorm(1,sd=sd) Time1[k]=Time1[k-1]+d/v+noise if((floor(Time1[k])%%2==0)&(k<length(Dist))&(Time1[k]-floor(Time1[k])>1/60)) Time1[k]=ceiling(Time1[k]) } max(Time1) } |
Here is the time it takes to go to the office
and here is the potential gain
We can now clearly see the impact of those nonlinearities : with my average 15 km per hour speed, I can save 8% of the time if I go through red during the very first second. Of course, I will never do such a think, but mathematically speaking, it is stricking. Here is the gain for the first 2 seconds (out of a full minute)
so the gain can be about 12%. And now, what if we remove the noise – or more precisely, what if the standard deviation become 0.001 instead of 0.05. Here is the first distribution of the time (when I stop at each red light, and wait)
If I do not go fast enough, I will stop at almost each light, and wait until the end of the minute: going at 20 km per hour or 24 km per hour is exactly the same. But if I can go slightly faster than 25km per hour, that is awesome, and I have my green wave. Now, her is the graph I get when I cycle through the red light only in the very first second
This is now the gain
I can save up to 40% of the time, and more realistically, my 55 min ride could now be a 40 min ride. Which is substantial.
But on that one, observe that another strategy is also possible : what if I do not cycle through red light, but I simply cycle +1% faster ?
simul_faster = function(v=.250,sd=.05){ Dist = seq(0,10,by=.25) Time1=rep(NA,length(D)) Time1[1]=0 for(k in 2:length(Dist)){ noise=rnorm(1,sd=sd) Time1[k]=Time1[k-1]+d/(v*1.01)+noise if((floor(Time1[k])%%2==0)&(k<length(Dist))&(Time1[k]-floor(Time1[k])>1/60)) Time1[k]=ceiling(Time1[k]) } max(Time1) } |
We have a similar result here, since riding 1% faster can actually help me save up to 50% of my time ! and (more realistically) if I ride 1% faster with a large random noise in the time between two light, I get almost the same as previously (when passing through the red light)
Again, my point here is not that we should cycle through a red light, of course not. But there may be accumulation of (small) nonlinear effects that might have a major impact at the end. And I believe that the best way to avoid this is to offer a green wave to cyclists, assuming that they ride at a reasonnable speed…