Nous allons prédire la variable prix en fonction de surface par un modèle linéaire simple:
\[ \left(\mathcal{M}_1\right): \quad prix_i=\beta_0+\beta_1 \text { surface }_i+\varepsilon_i, \quad i=1, \ldots, 24 \]
##
## Call:
## lm(formula = prix ~ surface)
##
## Residuals:
## Min 1Q Median 3Q Max
## -78.845 -23.259 5.293 26.546 80.453
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 30.0921 16.6455 1.808 0.0843 .
## surface 3.9844 0.2003 19.896 1.49e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 43.84 on 22 degrees of freedom
## Multiple R-squared: 0.9474, Adjusted R-squared: 0.945
## F-statistic: 395.9 on 1 and 22 DF, p-value: 1.485e-15
a.)
\[ \hat{\beta}_{0_{\mathcal{M}_{1}}}=30.0921 \]
\[ \hat{\beta}_{1_{\mathcal{M}_{1}}}= 3.9844 \]
## (Intercept) surface
## 30.092132 3.984417
\(\textbf{Interpretation:}\) Notice that we expected this coefficients since the coefficients for this model are given by the following formula:
\[ \hat{\beta_{0}}= \overline{y} - \overline{x}\hat{\beta_{1}} \] where
\[ \hat{\beta_{1}}= \frac{\sum_{i=1}^{n} (x_{i}- \overline{x})(x_{i} - \overline{y}) }{\sum_{i=1}^{n}(x_{i}- \overline{x})} \] Therefore;
\[ \hat{\beta_{1}}= 3,98\\ \hat{\beta_{0}}= \overline{y} - \overline{x}\hat{\beta_{1}} = 309,33 - (3,98)(70,083)= 30,09. \]
The values \(\overline{y}\) and \(\overline{x}\) are as follows:
## [1] 309.3333
## [1] 70.08333
\[ \left(\mathcal{M}_1\right): \quad prix_i=30.0921 + 3.9844 \text { surface }_i+\varepsilon_i, \quad i=1, \ldots, 24 \]
## 1 2 3 4 5 6 7 8
## 141.6558 229.3130 811.0378 249.2350 787.1313 468.3780 269.1571 221.3441
## 9 10 11 12 13 14 15 16
## 388.6896 169.5467 372.7520 289.0792 157.5935 237.2818 189.4688 309.0013
## 17 18 19 20 21 22 23 24
## 141.6558 149.6246 448.4559 237.2818 348.8455 269.1571 109.7805 428.5338
## 1 2 3 4 5 6 7
## -11.655799 50.687035 -11.037799 18.764951 2.868701 31.622035 50.842868
## 8 9 10 11 12 13 14
## 28.655868 -10.689632 80.453285 -22.751965 10.920785 -2.593465 7.718201
## 15 16 17 18 19 20 21
## 10.531201 15.998701 -56.655799 -71.624632 -73.455882 -37.281799 -78.845465
## 22 23 24
## 25.842868 -24.780465 66.466201
La moyenne des valeurs ajustées est:
\[ \bar{\hat{y}}_{\mathcal{M}_{1}}=309.3333. \]
## [1] 309.3333
La moyenne des résidus d’estimation est:
\[ \bar{\hat{\epsilon}}_{\mathcal{M}_{1}}= -9.636389e-16 \approx 0. \]
## [1] -9.636389e-16
\(\textbf{Interpretation:}\)
Dans ce modèle \((\mathcal{M}_{1})\) nous avons cette moyenne des résidus \(\hat{\epsilon}_{\mathcal{M}_{1}}\) est 0, et ceci peut être confirmé ici.
Nous avons \(\bar{\hat{y}}_{\mathcal{M}_{1}}=309.3333= \bar{y}_{\mathcal{M}_{1}}\). Ce résultat était également prévisible puisque \(\hat{\epsilon}_{\mathcal{M}_{1}}=0\), nous avons que la moyenne des valeurs ajustées, coïncide avec la moyenne de la valeur à prévoir, i.e
\[ \frac{1}{n}\sum_{1}^{n} \hat{y}_{i} = \frac{1}{n}\sum_{1}^{n} y_{i}. \]
b.) * Representer graphiquement les residus d’estimation en fonction es valeurs ajustes:
\(\textbf{Interpretation:}\)
Dans ce cas puisque notre modèle considère la variable constante 1, nous pouvons interpréter \(R^2\). Le modèle semble adapté à ce jeu de données. Nous avons que la valeur \(R_{\mathcal{M}_{1}}^2=0.9474\), cela révèle que \(94,74%\) de la variabilité observée dans notre variable s’explique par cette régression linéaire simple.
\(\textbf{Observation:}\) En général, un R-squared plus élevé indique une plus grande variabilité est expliquée par le modèle.
On considère maintenant le modèle sans constante:
\[ \left(\mathcal{M}_2\right): \quad prix_i=\beta_1 \text { surface }_i+\varepsilon_i, \quad i=1, \ldots, 24 . \]
##
## Call:
## lm(formula = prix ~ surface - 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -75.42 -23.56 19.45 33.46 99.86
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## surface 4.2897 0.1129 38.01 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 45.96 on 23 degrees of freedom
## Multiple R-squared: 0.9843, Adjusted R-squared: 0.9836
## F-statistic: 1445 on 1 and 23 DF, p-value: < 2.2e-16
## surface
## 4.289664
\[ \left(\mathcal{M}_2\right): \quad prix_i= 4.2897 \,\, surface_i+\varepsilon_i, \quad i=1, \ldots, 24 . \]
a.)
Dans le modele \((M_{1})\) (avec constant) et \(\mathcal{M}_2\) (sans constant) nous avons obtenu que les coefficients sont:
\[ \hat{\beta}_{0_{\mathcal{M}_1}}=30.0921, \hat{\beta}_{1_{\mathcal{M}_1}}= 3.9844,\\ \hat{\beta}_{1_{\mathcal{M}_2}}= 4.2897. \]
\(\textbf{Interpretation:}\)
Par conséquent, nous pouvons observer que le coefficient \(\hat{\beta}_{1_{\mathcal{M}_2}}\) du modèle \((\mathcal{M}_2)\) augmente par rapport au coefficient \(\hat{\beta}_{1_{\mathcal{M}_1}}\), cela signifie que le coefficient du modèle sans avoir à tenir compte de la constante augmente (see Brooks, Econometrics).
I cannot say this (BECAREFUL). Le \(R_{\mathcal{M}_{2}}^2=0.9843\). Cela montre que le coefficient \(\beta_1\) explique \(98\%\) du modèle et consistent avec les nuages de points aléatoires, contrary of what happens in the linear regression with a constant, where just \(R_{\mathcal{M}_{1}}^2=0.9474\).
b.)
La moyenne des résidus et des valuers ajustéss est:
\[ \bar{\hat{\epsilon}}_{\mathcal{M}_{2}}= 8.69935 \]
## [1] 8.69935
\[ \bar{\hat{y}}_{\mathcal{M}_{2}}= 300.634 \]
## [1] 300.634
\(\textbf{Interpretation:}\) La moyenne ajustées a diminué et la moyenne des résidus d’estimation a augmenté. Dans ce modèle nous ne considérons pas la constante, cela signifie que le vecteur des résidus d’estimation n’est plus orthogonal au vecteur des valeurs ajustees, cela implique que la moyenne des résidus n’est pas nulle comme on peut le voir, (i.e \(\bar{\hat{\epsilon}}_{\mathcal{M}_{2}} \neq 0\)).
On veut prédire maintenant la variable prix en utilisant la variable surface d’abord centrée, ensuite réduite, plus la constante:
\[ \left(\tilde{\mathcal{M}}_1\right): \quad prix_i=\tilde{\beta}_0+\tilde{\beta}_1 surface_i+\varepsilon_i = X \tilde{\beta} + \epsilon, \quad i=1, \ldots, 24, \]
où surface est la variable centrée de surface.
a.)
## surface prix
## 1 -42.08333333 130
## 2 -20.08333333 280
## 3 125.91666667 800
## 4 -15.08333333 268
## 5 119.91666667 790
## 6 39.91666667 500
## 7 -10.08333333 320
## 8 -22.08333333 250
## 9 19.91666667 378
## 10 -35.08333333 250
## 11 15.91666667 350
## 12 -5.08333333 300
## 13 -38.08333333 155
## 14 -18.08333333 245
## 15 -30.08333333 200
## 16 -0.08333333 325
## 17 -42.08333333 85
## 18 -40.08333333 78
## 19 34.91666667 375
## 20 -18.08333333 200
## 21 9.91666667 270
## 22 -10.08333333 295
## 23 -50.08333333 85
## 24 29.91666667 495
##
## Call:
## lm(formula = prixsurface$prix ~ surfacentre$surfacentre)
##
## Residuals:
## Min 1Q Median 3Q Max
## -78.845 -23.259 5.293 26.546 80.453
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 309.3333 8.9498 34.56 < 2e-16 ***
## surfacentre$surfacentre 3.9844 0.2003 19.90 1.49e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 43.84 on 22 degrees of freedom
## Multiple R-squared: 0.9474, Adjusted R-squared: 0.945
## F-statistic: 395.9 on 1 and 22 DF, p-value: 1.485e-15
b.)
Les estimaterus obtenu dan cet modeles sont:
\[ \hat{\beta}_{0_{\tilde{\mathcal{M}}_1}}=309.3333, \hat{\beta}_{1_{\tilde{\mathcal{M}}_1}}=3.9844, \]
Rappelez-vous que les coefficients du modèle \((\mathcal{M}_{1})\) sont:
\[ \hat{\beta}_{0_{\mathcal{M}_1}}=30.0921, \hat{\beta}_{1_{\mathcal{M}_1}}= 3.9844 \]
\(\textbf{Interpretation:}\) On peut voir que la valeur de la pente dans les deux modèles coïncide \(\hat{\beta}_{1_{\mathcal{M}_1}}=\hat{\beta}_{1_{\tilde{\mathcal{M}}_1}}=3.9844\), alors que la valeur du \(\beta_{0}\) sont complètement différents. Nous devons remarquer ici que le coefficient d’interception est égal à la moyenne de la valeur ajustée de \(y\) dans le modèle \(\mathcal{M}_{1}\), i.e
\[ \hat{\beta}_{0_{\tilde{\mathcal{M}}_1}}=309.3333 = \overline{\hat{y}}_{\mathcal{M}_{1}}. \]
\(\textbf{Proof:}\) On sait que \(\hat{\beta}=(X^{\intercal}X)^{-1}X^{\intercal}y\) par la metode the moindres carres.
\[ Y_i=\beta_1+\beta_2 X_i+\varepsilon_i, \] et nous définissons \(\bar{X}\) comme la moyenne du régresseur: \(\overline{X}=X_1+ \cdots+ X_n\) et nous pouvons réécrire le modèle comme \[ Y_i=\beta_1+\beta_2 \bar{X}+\beta_2\left(X_i-\bar{X}\right)+\varepsilon_i \\ =\widetilde{\beta}_1+\beta_2 \widetilde{X}_i+\varepsilon_i, \]
où \(\widetilde{\beta}_1:=\beta_1+\beta_2 \bar{X}\) et \(\widetilde{X}_i:=X_i-\bar{X}\). \(\widetilde{X}\) est une variable centrée. Ce faisant, nous avons rendu le modèle orthogonal. Cela simplifie considérablement le calcul, à la fin on peut revenir au paramétrage d’origine. Sous forme de matrice, nous avons et oublier le tilde pour la facilité de notation
\[ \left(\begin{array}{c} Y_1 \\ \vdots \\ Y_n \end{array}\right)=\left(\begin{array}{cc} 1 & X_1 \\ \vdots & \vdots \\ 1 & X_n \end{array}\right)\left(\begin{array}{c} \beta_1 \\ \beta_2 \end{array}\right)+\left(\begin{array}{c} \varepsilon_1 \\ \vdots \\ \varepsilon_n \end{array}\right) . \] Soit
\[ X=\left(\begin{array}{cc} 1 & X_1 \\ \vdots & \vdots \\ 1 & X_n \end{array}\right) \] Et, bien sûr,
\[ \beta=\left(\begin{array}{l} \beta_1 \\ \beta_2 \end{array}\right), \]
nous pouvons utiliser
\[ X^{\prime} X=\left(\begin{array}{cc} n & \sum X_i \\ \sum X_i & \sum\left(X_i\right)^2 \end{array}\right)=\left(\begin{array}{cc} n & 0 \\ 0 & \sum\left(X_i\right)^2 \end{array}\right) \text { yielding }\left(X^{\prime} X\right)^{-1}=\left(\begin{array}{cc} n^{-1} & 0 \\ 0 & \left(\sum\left(X_i \right)^2\right)^{-1} \end{array}\right) \]
De plus,
\[ X^{\prime} Y=\left(\begin{array}{ccc} 1 & \ldots & 1 \\ X_1 & \ldots & X_n \end{array}\right)\left(\begin{array}{c} Y_1 \\ \vdots \\ Y_n \end{array}\right)=\left(\begin{array}{c} \sum Y_i \\ \sum Y_i X_i \end{array}\right) \]
par conséquent
\[ \widehat{\beta}=\left(\begin{array}{c} \widehat{\beta_0} \\ \widehat{\beta_1} \end{array}\right)=\left(\begin{array}{cc} n^{-1} & 0 \\ 0 & \left(\sum\left(X_i\right)^2\right)^{-1} \end{array}\right)\left(\begin{array}{c} \sum Y_i \\ \sum Y_i X_i \end{array}\right)=\left(\begin{array}{c} n^{-1} \sum Y_i \\ \left(\sum Y_i X_i\right)\left(\sum\left(X_i\right)^2\right)^{-1} \end{array}\right) . \]
Maintenant nous réintroduisons les tildes avec cette notation que nous avons
\[ \begin{aligned} & \widehat{\widetilde{\beta}}_0=\overline{Y} \\ & \widehat{\beta}_1=\widehat{\widetilde{\beta}}_1=\frac{\sum_{i=1}^n Y_i\left(X_i-\overline{X}\right)}{\left.\sum_{i=1}^n\left(X_{i} - \overline{X} \right.\right)^2}=\frac{\sum_{i=1}^n\left(Y_i-\overline{Y}\right)\left(X_i-\overline{X}\right)}{\sum_{i=1}^n\left(X_i-\overline{X}\right)^2} \\ & \widehat{\beta}_0=\widehat{\widetilde{\beta}}_0-\widehat{\beta}_1 \overline{X} . \end{aligned} \]
c.) * Quelles sont les valeurs ajustées avec le modèle \(\left(\tilde{\mathcal{M}}_1\right)\) ?
## 1 2 3 4 5 6 7 8
## 141.6558 229.3130 811.0378 249.2350 787.1313 468.3780 269.1571 221.3441
## 9 10 11 12 13 14 15 16
## 388.6896 169.5467 372.7520 289.0792 157.5935 237.2818 189.4688 309.0013
## 17 18 19 20 21 22 23 24
## 141.6558 149.6246 448.4559 237.2818 348.8455 269.1571 109.7805 428.5338
## [1] 309.3333
## 1 2 3 4 5 6 7
## -11.655799 50.687035 -11.037799 18.764951 2.868701 31.622035 50.842868
## 8 9 10 11 12 13 14
## 28.655868 -10.689632 80.453285 -22.751965 10.920785 -2.593465 7.718201
## 15 16 17 18 19 20 21
## 10.531201 15.998701 -56.655799 -71.624632 -73.455882 -37.281799 -78.845465
## 22 23 24
## 25.842868 -24.780465 66.466201
## [1] 3.885781e-15
La moyenne des résidus d’estimation est:
\[ \bar{\hat{\epsilon}}_{\tilde{\mathcal{M}}_1}= 3.885781e-15 \approx 0 \]
La moyenne des valuers ajustéss est:
\[ \bar{\hat{y}}_{\tilde{\mathcal{M}}_1}= 309.3333 \]
On considère un modèle avec la variable surface centrée et sans constante:
\[ (\tilde{\mathcal{M}}_{2}): \operatorname{prix}_i=\tilde{\beta}_{1} \widetilde{surface}_i+\eta_i, \quad i=1, \ldots, 24, \]
##
## Call:
## lm(formula = prixsurface$prix ~ surfacentre$surfacentre - 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## 230.5 286.1 314.6 335.9 389.8
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## surfacentre$surfacentre 3.984 1.456 2.736 0.0118 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 318.9 on 23 degrees of freedom
## Multiple R-squared: 0.2455, Adjusted R-squared: 0.2127
## F-statistic: 7.484 on 1 and 23 DF, p-value: 0.01178
## surfacentre$surfacentre
## 3.984417
## [1] 309.3333
## [1] 2.4869e-14
\[ \hat{\beta}_{1}= 3.9844 \]
\(\textbf{Interpretation:}\) On peut observer que la valeur de la pente coïncide dans les deux modèles \(\hat{\beta}_{1_{\tilde{\mathcal{M}}_1}}= 3.9844= \hat{\beta}_{1}\). Contrairement à ce qui s’est passé dans le modèle \((\mathcal{M}_{1})\) et \((\mathcal{M}_{2})\) où la pente change, ici elle atteint la même chose, même si nous n’avons pas la constante.
\[ \left(\mathcal{M}_{1}^{*}\right): \quad \operatorname{prix}_i=\beta_0^*+\beta_1^* \text { surface }_i^*+\varepsilon_i, \quad i=1, \ldots, 24, \]
où surface* est la variable réduite.
## surfacereduite prix
## 1 -0.921815294 130
## 2 -0.439915813 280
## 3 2.758144374 800
## 4 -0.330393204 268
## 5 2.626717243 790
## 6 0.874355497 500
## 7 -0.220870595 320
## 8 -0.483724857 250
## 9 0.436265060 378
## 10 -0.768483641 250
## 11 0.348646973 350
## 12 -0.111347986 300
## 13 -0.834197207 155
## 14 -0.396106770 245
## 15 -0.658961032 200
## 16 -0.001825377 325
## 17 -0.921815294 85
## 18 -0.878006250 78
## 19 0.764832887 375
## 20 -0.396106770 200
## 21 0.217219842 270
## 22 -0.220870595 295
## 23 -1.097051469 85
## 24 0.655310278 495
##
## Call:
## lm(formula = prixsurface$prix ~ surfacereduite$surfacereduite)
##
## Residuals:
## Min 1Q Median 3Q Max
## -78.845 -23.259 5.293 26.546 80.453
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 309.333 8.950 34.56 < 2e-16 ***
## surfacereduite$surfacereduite 181.899 9.142 19.90 1.49e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 43.84 on 22 degrees of freedom
## Multiple R-squared: 0.9474, Adjusted R-squared: 0.945
## F-statistic: 395.9 on 1 and 22 DF, p-value: 1.485e-15
## (Intercept) surfacereduite$surfacereduite
## 309.3333 181.8993
## 1 2 3 4 5 6 7 8
## 141.6558 229.3130 811.0378 249.2350 787.1313 468.3780 269.1571 221.3441
## 9 10 11 12 13 14 15 16
## 388.6896 169.5467 372.7520 289.0792 157.5935 237.2818 189.4688 309.0013
## 17 18 19 20 21 22 23 24
## 141.6558 149.6246 448.4559 237.2818 348.8455 269.1571 109.7805 428.5338
## [1] 309.3333
## 1 2 3 4 5 6 7
## -11.655799 50.687035 -11.037799 18.764951 2.868701 31.622035 50.842868
## 8 9 10 11 12 13 14
## 28.655868 -10.689632 80.453285 -22.751965 10.920785 -2.593465 7.718201
## 15 16 17 18 19 20 21
## 10.531201 15.998701 -56.655799 -71.624632 -73.455882 -37.281799 -78.845465
## 22 23 24
## 25.842868 -24.780465 66.466201
## [1] 2.975051e-16
\[ \widehat{\beta}_{0}^{*}=309.3333 \] \[ \widehat{\beta}_{1}^{*}= 181.8993 \]
\(\textbf{Interpretation}\) On peut observer que
\[ \widehat{\beta}_{0}^{*}=309.3333 = \overline{\hat{y}}_{\mathcal{M}_{1}^{*}}, \]
\[ \overline{\hat{y}}_{\mathcal{M}_{1}^{*}}= 309.3333 \]
\[ \overline{\hat{\epsilon}}_{\mathcal{M}_{1}^{*}}=2.975051e-16 \approx 0 \]
\(\textbf{Interpretation}\) Comme nous nous y attendions puisque ce modèle prend en considération de constant, nous avons que la moyenne des erreurs est zéro. Ensuite, nous avons que \(\overline{\hat{y}}_{\mathcal{M}_{1}^{*}}\) coincides with the value of \(\overline{\hat{y}}_{\mathcal{M}_{1}}\).
\(\textbf{Proof}\)
On a que
\[ \widehat{\beta}_{0}^{*} = \overline{y} - \widehat{\beta}_{1}^{*} \overline{x^{*}}= \overline{y} - \widehat{\beta}_{1}^{*} \frac{1}{\sigma} \overline{x} = \overline{y}, \]
alors
\[ \begin{aligned} & \widehat{\beta}_{0}^{*}=\overline{Y} \\ & \widehat{\beta}_{1}^{*}=\frac{\sum_{i=1}^n\left(Y_{i}-\overline{Y}\right)\left(X_{i}^{*}-\overline{X}^{*}\right)}{\sum_{i=1}^n\left(X_{i}^{*}-\overline{X}^{*}\right)^2}=\frac{\sum_{i=1}^{n} Y_{i}\left(\frac{X_i}{\sigma}\right)}{\frac{1}{\sigma^{2}}\sum_{i=1}^{n}\left(X_{i} \right)^2}= \sigma \hat{\tilde{\beta}}_{1} \\ & \widehat{\beta}_{0}^{*}=\overline{y} -\widehat{\beta}_{1}^{*} \overline{X^{*}}= \overline{y} - \sigma \hat{\tilde{\beta}}_{1} \frac{1}{\sigma} \overline{\tilde{X}}= \overline{y} \end{aligned} \]
lorsque l’écart-type de la surface variable est égal à:
## [1] 45.65267
\[ \sigma= 45.65267. \]
Donc on a :
\[ \widehat{\beta}_{1}^{*} = (45,652) (3,9844) = 181.8993 = \sigma \hat{\tilde{\beta}}_{1}, \\ \widehat{\beta}_{0}^{*} = 309.3333 = \widehat{\tilde{\beta} }_{0}. \]
Considérez les données graisse et on veut prédire le taux de graisse en fonction des autres variables.
##
## Call:
## lm(formula = graisse ~ age + poids + taille + adipos + cou +
## buste + abdom + hanche + cuisse + genou + cheville + biceps +
## avantb + poignet, data = graissed)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.0433 -2.5932 -0.1193 2.8698 9.3164
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -49.74275 36.55914 -1.361 0.17493
## age 0.05871 0.03007 1.952 0.05208 .
## poids -0.17327 0.10060 -1.722 0.08629 .
## taille 0.47077 0.50821 0.926 0.35523
## adipos 0.77667 0.73440 1.058 0.29134
## cou -0.42834 0.21892 -1.957 0.05157 .
## buste -0.04253 0.09840 -0.432 0.66600
## abdom 0.87034 0.08583 10.141 < 2e-16 ***
## hanche -0.22151 0.13816 -1.603 0.11020
## cuisse 0.23855 0.13594 1.755 0.08059 .
## genou -0.01276 0.23003 -0.055 0.95581
## cheville 0.13557 0.20854 0.650 0.51625
## biceps 0.15170 0.16002 0.948 0.34410
## avantb 0.40486 0.18631 2.173 0.03077 *
## poignet -1.48070 0.49656 -2.982 0.00316 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.995 on 236 degrees of freedom
## Multiple R-squared: 0.7475, Adjusted R-squared: 0.7325
## F-statistic: 49.89 on 14 and 236 DF, p-value: < 2.2e-16
## (Intercept) age poids taille adipos cou
## -49.74274705 0.05870989 -0.17327448 0.47076812 0.77666844 -0.42834044
## buste abdom hanche cuisse genou cheville
## -0.04252633 0.87033774 -0.22151147 0.23855250 -0.01275997 0.13557167
## biceps avantb poignet
## 0.15169876 0.40486290 -1.48069897
## [1] -2.322283e-16
## [1] 18.88765
On a le modele suivante:
\[ (\mathcal{M}_{1}): \quad graisse_{i} = \beta_{0} +\beta_{1} \,\, age_{i} + \beta_{2} \,\, poids_{i} + \beta_{3} \,\, taille_{i} + \sum_{i=4}^{14} \beta_{i} \,\, x_{i} + \epsilon_{i}. \]
\[ \hat{\epsilon}_{\mathcal{M}_{1}} = -2.322283e-16 \approx 0. \]
cette valeur est attendue, puisque dans ce modèle nous considérons la constante.
\[ \overline{\hat{y}}_{\mathcal{M}_{1}}= 18.88765 \]
\[ R^{2}_{\mathcal{M}_{1}}=0.7475. \]
Certains des coefficients les plus importants que je vais mentionner nous permettront de comparer avec les modèles suivants, puisque dans le modèle suivant, la taille et le poids variables changeront l’échelle, alors que l’âge variable ne changera pas:
\[ \hat{\beta}_{0_{\mathcal{M}_{1}}}= -49.74275 \\ \hat{\beta}_{1_{\mathcal{M}_{1}}}= 0.05871 \\ \hat{\beta}_{2_{\mathcal{M}_{1}}}= -0.17327 \\ \hat{\beta}_{3_{\mathcal{M}_{1}}}= 0.47077 \]
##
## Call:
## lm(formula = graisse ~ age + poids + taille + adipos + cou +
## buste + abdom + hanche + cuisse + genou + cheville + biceps +
## avantb + poignet, data = graissechange2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.0433 -2.5932 -0.1193 2.8698 9.3164
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -49.74275 36.55914 -1.361 0.17493
## age 0.05871 0.03007 1.952 0.05208 .
## poids -0.38166 0.22158 -1.722 0.08629 .
## taille 0.18534 0.20008 0.926 0.35523
## adipos 0.77667 0.73440 1.058 0.29134
## cou -0.42834 0.21892 -1.957 0.05157 .
## buste -0.04253 0.09840 -0.432 0.66600
## abdom 0.87034 0.08583 10.141 < 2e-16 ***
## hanche -0.22151 0.13816 -1.603 0.11020
## cuisse 0.23855 0.13594 1.755 0.08059 .
## genou -0.01276 0.23003 -0.055 0.95581
## cheville 0.13557 0.20854 0.650 0.51625
## biceps 0.15170 0.16002 0.948 0.34410
## avantb 0.40486 0.18631 2.173 0.03077 *
## poignet -1.48070 0.49656 -2.982 0.00316 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.995 on 236 degrees of freedom
## Multiple R-squared: 0.7475, Adjusted R-squared: 0.7325
## F-statistic: 49.89 on 14 and 236 DF, p-value: < 2.2e-16
Comment changent-elles les estimations des coefficients de régression? Et les valeurs ajustées?
\[ \hat{\beta}_{0_{\mathcal{M}_{2}}}= -49.74275 \\ \hat{\beta}_{1_{\mathcal{M}_{2}}}= 0.05871 \\ \hat{\beta}_{2_{\mathcal{M}_{2}}}= -0.38166 \\ \hat{\beta}_{3_{\mathcal{M}_{2}}}= 0.18534 \]
et les autres valeurs restent les mêmes. Noter que:
\[ \hat{\beta}_{2_{\mathcal{M}_{2}}}= -0.38166 = \frac{1}{0.454} \hat{\beta}_{2_{\mathcal{M}_{1}}} \] \[ \hat{\beta}_{3_{\mathcal{M}_{2}}}= 0.18534 = \frac{1}{2.54}\hat{\beta}_{3_{\mathcal{M}_{1}}} \]
L’échelle est la suivante:
\[ \tilde{X}=X \cdot \operatorname{diag}\left(c_1, c_2, \ldots, c_n\right) \] OU \(c_i\) facteur d’échelle de chaque variable (colonne) et \(\tilde{X}\) une version à l’échelle de \(X\). Appelons la matrice d’échelle diagonale \(C \equiv \operatorname{diag}\left(c_1, c_2, \ldots, c_n\right)\). L’estimateur est donné par :
\[ \hat{\beta}=\left(X^T X\right)^{-1} X^T Y \]
Branchez la matrice mise à l’échelle \(\tilde{X}\) au lieu de \(X\) et utilisez une certaine algèbre de matrice:
\[ \begin{aligned} \hat{\beta}_{\tilde{X}}=& \left(\tilde{X}^T \tilde{X}\right)^{-1} \tilde{X}^T Y=\left(C^T X^T X C\right)^{-1} C^T X^T Y=C^{-1}\left(X^T X\right)^{-1} C^{-1} C X^T Y \\ & =C^{-1}\left(X^T X\right)^{-1} X^T Y=C^{-1} \hat{\beta}_{X} \end{aligned} \]
Ainsi, vous voyez comment le nouveau coefficient est simplement l’ancien coefficient réduit, comme prévu.
Soit le modele
\[ graisse_{i} = \beta_{0} + \beta_{1} \,\, poids_{i} + \beta_{2} \,\, taille_{i} \]
##
## Call:
## lm(formula = graisse ~ poids + taille, data = graissed)
##
## Residuals:
## Min 1Q Median 3Q Max
## -22.2869 -3.3755 0.0152 4.1267 12.1992
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 68.23679 9.65018 7.071 1.56e-11 ***
## poids 0.21494 0.01339 16.056 < 2e-16 ***
## taille -1.24854 0.15055 -8.293 7.06e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 5.429 on 248 degrees of freedom
## Multiple R-squared: 0.5099, Adjusted R-squared: 0.506
## F-statistic: 129 on 2 and 248 DF, p-value: < 2.2e-16
\(\textbf{Interpretation:}\)
Ici, nous pouvons remarquer que la valeur \(R^2\) augmente à mesure que d’autres prédicteurs sont ajoutés au modèle de régression multi-linéaire. Par exemple dans ce cas avec deux variables explicatives, nous avons \(R^2= 0.5099\), tandis que dans le modèle avec les 13 variables explicatives nous avons \(R^2=0.7475\).
Réalisez aussi une régression sur les variables explicatives centrées. Pour centrer les variables explicatives, utilisez la fonction sweep décrite en fin de section.
##
## Call:
## lm(formula = graisse ~ age + poids + taille + adipos + cou +
## buste + abdom + hanche + cuisse + genou + cheville + biceps +
## avantb + poignet, data = graissecentre)
##
## Residuals:
## Min 1Q Median 3Q Max
## -13.8410 -3.9795 0.0982 3.8461 16.3934
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.34563 1.37687 2.430 0.0159 *
## age 0.08825 0.01130 7.808 1.89e-13 ***
## poids 0.07190 0.01020 7.048 1.98e-11 ***
## taille 0.06886 0.01227 5.613 5.57e-08 ***
## adipos 0.09560 0.01139 8.395 4.35e-15 ***
## cou 0.08795 0.01174 7.490 1.37e-12 ***
## buste 0.08280 0.01165 7.109 1.38e-11 ***
## abdom 0.07771 0.01093 7.113 1.35e-11 ***
## hanche 0.07436 0.01113 6.680 1.70e-10 ***
## cuisse 0.08968 0.01215 7.378 2.72e-12 ***
## genou 0.08208 0.01140 7.201 7.96e-12 ***
## cheville 0.08771 0.01277 6.870 5.64e-11 ***
## biceps 0.07074 0.01150 6.151 3.27e-09 ***
## avantb 0.09942 0.01194 8.326 6.83e-15 ***
## poignet 1.06662 0.01122 95.089 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 5.758 on 236 degrees of freedom
## Multiple R-squared: 0.9839, Adjusted R-squared: 0.983
## F-statistic: 1032 on 14 and 236 DF, p-value: < 2.2e-16
\[ \hat{\beta}_{0}= - 3.34563 \\ \hat{\beta}_{1}= 0.08825 \\ \hat{\beta}_{2}= 0.07190 \\ \hat{\beta}_{3}= 0.06886 \]
## [1] -42.81597
\[ \overline{\hat{y}}= -42.81597 \]
## [1] -3.220124e-17
\[ \overline{\hat{\epsilon}}= -3.220124e-17 \approx 0 \]
##
## Call:
## lm(formula = graisse ~ age + poids + taille + adipos + cou +
## buste + abdom + hanche + cuisse + genou + cheville + biceps +
## avantb + poignet, data = graissecentre)
##
## Residuals:
## Min 1Q Median 3Q Max
## -11.6728 -1.0300 0.0572 0.9939 12.6544
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -18.638256 2.422881 -7.693 3.90e-13 ***
## age 0.070019 0.017602 3.978 9.25e-05 ***
## poids 0.045915 0.010761 4.267 2.87e-05 ***
## taille 0.021294 0.005083 4.190 3.95e-05 ***
## adipos 0.202361 0.035580 5.687 3.80e-08 ***
## cou 0.114924 0.024020 4.785 3.02e-06 ***
## buste 0.039385 0.008738 4.507 1.03e-05 ***
## abdom 0.041294 0.009814 4.208 3.67e-05 ***
## hanche 0.039173 0.008800 4.451 1.32e-05 ***
## cuisse 0.079677 0.015812 5.039 9.31e-07 ***
## genou 0.101703 0.024201 4.202 3.75e-05 ***
## cheville 0.206620 0.039540 5.226 3.82e-07 ***
## biceps 0.138842 0.029520 4.703 4.36e-06 ***
## avantb 0.134119 0.031621 4.241 3.19e-05 ***
## poignet 1.347749 0.049396 27.284 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.712 on 236 degrees of freedom
## Multiple R-squared: 0.8203, Adjusted R-squared: 0.8097
## F-statistic: 76.96 on 14 and 236 DF, p-value: < 2.2e-16
\[ \hat{\beta}_{0}= -18.638256 \\ \hat{\beta}_{1}= 0.070019 \\ \hat{\beta}_{2}= 0.045915 \\ \hat{\beta}_{3}= 0.021294 \]
## [1] -42.81597
\[ \overline{\hat{y}}= -42.81597 \]
## [1] -3.220124e-17
\[ \overline{\hat{\epsilon}}= -3.220124e-17 \approx 0 . \]
Créer une fonction qui a comme paramètres d’entrée la variable à prédire y et la matrice des variables explicatives \(\mathrm{X}\) et en sorties, le vecteur \(\hat{\boldsymbol{\beta}}\) des estimateurs de coefficients de régression \(\beta\), le vecteur des valeurs ajustées \(\hat{\mathbf{y}}\), le vecteur des résidus \(\hat{\varepsilon}\) et le \(R^2\). Attention, les opérations avec des matrices peuvent prendre rapidement beaucoup de temps, essayez de créer une fonction rapide; vous pouvez utiliser la fonction crossprod pour calculer des produits de matrices avec des transposées et solve(A,b) pour calculer \(A^{-1} b\). Comparez vos résultats avec ceux obtenus avec la fonction Im sur les deux jeux de données.
## [1] "The intersection value and the slope values are: "
## [,1]
## Intercept 30.09
## Slope 3.98
## [1] "The mean of the fitted values is:"
## [1] 309.0217
## [1] "The mean of the residuals values is:"
## [1] 0.3116667
## [1] "The value of R^2 is :"
## [1] 0.9473477
##
## Call:
## lm(formula = prix ~ ., data = prixsurface)
##
## Coefficients:
## (Intercept) surface
## 30.092 3.984
## our.results lm.results
## (Intercept) 30.09 30.09
## surface 3.98 3.98