load("jouet2.Rdata")
summary(jouet2)
## x1 x2 y
## Min. :-3.5011 Min. :0.0140 Min. :-2.9514
## 1st Qu.:-1.6569 1st Qu.:0.2485 1st Qu.:-0.8356
## Median :-0.8041 Median :0.5127 Median : 0.1708
## Mean :-0.8420 Mean :0.5131 Mean : 0.3207
## 3rd Qu.:-0.1245 3rd Qu.:0.7802 3rd Qu.: 1.4039
## Max. : 1.9076 Max. :0.9963 Max. : 4.3604
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.5.3
ggplot(jouet2) + geom_point(aes(x = x2, y = y))
ggplot(jouet2) + geom_point(aes(x = x1, y = y))
reg <- lm(y ~ x1 + x2, data=jouet2)
summary(reg)
##
## Call:
## lm(formula = y ~ x1 + x2, data = jouet2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.13860 -0.68004 0.07635 0.63161 2.34730
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.78690 0.20580 -8.683 9.32e-14 ***
## x1 -0.90288 0.09107 -9.914 < 2e-16 ***
## x2 2.62564 0.32531 8.071 1.89e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9668 on 97 degrees of freedom
## Multiple R-squared: 0.6342, Adjusted R-squared: 0.6267
## F-statistic: 84.09 on 2 and 97 DF, p-value: < 2.2e-16
data2 <- jouet2
data2$yc <- predict(reg)
data2$ec <- data2$y - data2$yc
ggplot(data2) + geom_point(aes(x = yc, y = ec))
Réponse : pas de structure particulière. Le modèle semble réaliste en terme de moyenne.