**NB** Cette version du document est un recalcul des scripts effectués par Arnaud Legrand sur une autre machine que la sienne, afin de voir la répétabilité de ces calculs. La version originale de son document peut être trouvée [ici](https://app-learninglab.inria.fr/moocrr/gitlab/moocrr-session3/moocrr-reproducibility-study/blob/master/challenger.pdf)
# Technical information on the computer on which the analysis is run
We will be using the R language using the ggplot2 library.
```{r}
library(ggplot2)
sessionInfo()
```
Here are the available libraries
```{r}
devtools::session_info()
```
# Loading and inspecting data
Let’s start by reading data:
```{r}
data = read.csv("https://app-learninglab.inria.fr/moocrr/gitlab/moocrr-session3/moocrr-reproducibility-study/raw/842953ef22e87c45b762b4427b99876af0fa6b60/data/shuttle.csv", sep=",")
data
```
We know from our previous experience on this data set that filtering data is a really bad idea. We will therefore process it as such. Let’s visually inspect how temperature affects malfunction:
Let’s assume O-rings independently fail with the same probability which solely depends on temperature. Alogistic regression should allow us to estimate the influence of temperature.
The maximum likelyhood estimator of the intercept and of Temperature are thus Alpha = 5.0849 and bêta = −0.1156 and their standard errors are s<sub>alpha</sub> = 3.052 and s<sub>bêta</sub> = 0.04702. The Residual deviance corresponds to the Goodness of fit G2 = 18.086 with 21 degrees of freedom. I have therefore managed to replicate the results of the Dalal et al. article.
# Predicting failure probability
The temperature when launching the shuttle was 31°F. Let’s try to estimate the failure probability for such temperature using our model.:
Mmmh, I have a warning from ggplot2 indicating “non-integer #successes in a binomial glm!”. This seems fishy. Furthermore, this confidence region seems huge. . . It seems strange to me that the uncertainty grows so large for higher temperatures. And compared to my previous call to glm, I haven’t indicated the weight which accounts for the fact that each ratio Malfunction/Count corresponds to Count observations (if someone knows how to do this. . . ). There must be something wrong.
So let’s provide the “raw” data to ggplot2.
```{r}
data_flat=data.frame()
for(i in 1:nrow(data)) {
temperature = data[i,"Temperature"];
malfunction = data[i,"Malfunction"];
d = data.frame(Temperature=temperature,Malfunction=rep(0,times = data[i,"Count"]))
if(malfunction>0) {
d[1:malfunction, "Malfunction"]=1;
}
data_flat=rbind(data_flat,d)
}
dim(data_flat)
```
```{r}
str(data_flat)
```
Let’s check whether I obtain the same regression or not:
Perfect. The estimates and the standard errors are the same although the Residual deviance is difference since the distance is now measured with respect to each 0/1 measurement and not to ratios. Let’s use plot the regression for data_flat along with the ratios (data).
This confidence interval seems much more reasonable (in accordance with the data) than the previous one. Let’s check whether it corresponds to the prediction obtained when calling directly predict. Obtaining the prediction can be done directly or through the link function.
Here is the “direct” (response) version I used in my very first plot:
```{r}
pred = predict(logistic_reg_flat,list(Temperature=30),type="response",se.fit = T)
pred
```
The estimated Failure probability for 30° is thus 0.834. However, the se.f it value seems pretty hard to use as I can obviously not simply add ±2se.f it to fit to compute a confidence interval.
The 95% confidence interval for our estimation is thus [0.163,0.992]. This is what ggplot2 just plotted me.This seems coherent.
I am now rather confident that I have managed to correctly compute and plot the uncertainty
of my prediction. Let’s be honnest, it took me a while. My first attempts were plainly wrong (I didn’t know how to do this so I trusted ggplot2, which I was misusing) and did not use the correct statistical method. I also feel confident now because this has been somehow validated by other colleagues but it will be interesting that you collect other kind of plots values that you obtained, that differ and that you would probably have kept if you didn’t have a reference to compare to. Please provide us with as many versions as you can.