Back to Course

FoSSA Français

0% Complete
0/0 Steps
  1. Information sur le cours

    Rencontrez l'équipe enseignante
  2. Jeu de données du cours 1
  3. Jeu de données du cours 2
  4. MODULE A1: INTRODUCTION AUX STATISTIQUES AVEC R ET STATA
    A1.1 Qu'est-ce que les Statistiques?
  5. A1.2.1a Introduction à Stata
  6. A1.2.2b: Introduction à R
  7. A1.2.2c: Introduction to SPSS
  8. A1.3: Statistiques Descriptives
  9. A1.4: Estimations et Intervalles de Confiance
  10. A1.5: Tests d'Hypothèses
  11. A1.6: Transformation de Variables
  12. Fin du Module A1
    1 Quiz
  13. MODULE A2: CALCULS DE PUISSANCE STATISTIQUE & DE TAILLE D’ÉCHANTILLON
    A2.1 Concepts Clés
  14. A2.2 Calculs de puissance pour une différence de moyennes
  15. A2.3 Calculs de puissance pour une différence de proportions
  16. A2.4 Calcul de taille d’échantillon pour les essais randomisés (RCTs)
  17. A2.5 Calculs de taille d’échantillon pour les études transversales (ou sondages)
  18. A2.6 Calcul de taille d'échantillon pour un devis cas-contrôle
  19. Fin du Module A2
    1 Quiz
  20. MODULE B1: RÉGRESSION LINÉAIRE
    B1.1 Corrélation et Nuages de Points (scatterplots)
  21. B1.2 Différences Entre Moyennes (ANOVA à un facteur)
  22. B1.3 Régression Linéaire Univariée
  23. B1.4 Régression Linéaire Multivariée
  24. B1.5 Sélection de Modèles et Tests F
  25. B1.6 Diagnostics de Régression
  26. Fin du Module B1
    1 Quiz
  27. MODULE B2: COMPARAISONS MULTIPLES & MESURES RÉPÉTÉES
    B2.1 ANOVA Approfondie— Tests Post-Hoc
  28. B2.2 Correction pour Comparaisons Multiples
  29. B2.3 ANOVA à deux facteurs (Two-way ANOVA)
  30. B2.4 Mesures Répétées et Test T Apparié
  31. B2.5 ANOVA pour Mesures Répétées
  32. Fin du Module B2
    1 Quiz
  33. MODULE B3: MÉTHODES NON-PARAMETRIC
    B3.1 Hypothèses des Tests Paramétriques
  34. B3.2 Test U de Mann-Whitney
  35. B3.3 Test de Kruskal-Wallis
  36. B3.4 Test des rangs signés de Wilcoxon
  37. B3.5 Test de Friedman
  38. B3.6 Corrélation des Rangs de Spearman
  39. Fin du Module B3
    1 Quiz
  40. MODULE C1: DONNÉES BINAIRES & RÉGRESSION LOGISTIQUE
    C1.1 Introduction à la prévalence, au Risque, aux Cotes (Odds) et aux Taux
  41. C1.2 Le Test du Chi Carré & le Test de Tendance
  42. C1.3 Régression Logistique Univariée
  43. C1.4 Régression Logistique Multivariée
  44. Fin du Module C1
    1 Quiz
  45. MODULE C2: DONNÉES DE SURVIE
    C2.1 Introduction aux Données de Survie
  46. C2.2 Fonction de Survie de Kaplan-Meier & Test du Log-Rank
  47. C2.3 Régression de Cox à Risque Proportionnel
  48. C2.4 Régression de Poisson
  49. Fin du Module C2
    1 Quiz
Lesson 25 of 49
In Progress

B1.6 Diagnostics de Régression

Learning Outcomes

By the end of this section, students will be able to:

  • Explore the data with correlations and scatterplots.
  • Use an ANOVA to test for a difference in means across a categorical variable.
  • Conduct univariable and multivariable linear regression
  • Check the regression diagnostics of a linear model.

You can download a copy of the slides here: B1.6 Regression Diagnostics

Video B1.6 – Regression Diagnostics (6 minutes)

B1.6 PRACTICAL: Stata

One of the final steps of any linear regression is to check that the model assumptions are met. Satisfying these assumptions allows you to perform statistical hypothesis testing and generate reliable confidence intervals.

Here we are going to practice checking the normality and homoscedasticity of the residuals.

Checking Normality of Residuals

We need to make sure that our residuals are normally distributed with a mean of 0. This assumption may be checked by looking at a histogram or a Q-Q-Plot.

To look at our residuals, we use the post-estimation command ‘predict’ after the multivariable command we used above in B1.4a with bmi_grp4, ldlc and currsmoker.

 predict sbp_r, resid

I have called my new variable “sbp_r”, and the option “resid” specifies that I want residuals rather than the default predicted linear values.

Then I can use the ‘sum’ command to check the mean, and then plot a histogram.

sum sbp_r

     hist sbp_r

Checking Homoscedasticity

 One of main assumptions of ordinary least squares linear regression is that there is homogeneity of variance (i.e. homoscedasticity) of the residuals. If the variance of our residuals is heteroscedastic then this indicates model misspecification. To check this we plot the values of our residuals against the fitted (predicted) values from our regression, and we hope to see a random scatterplot with no pattern. If we see a pattern, i.e. the scatterplot gets wider or narrower at a certain range of values, then this indicates heteroscedasticity and we need to re-evaluate our model.

Stata’s command for this is ‘rvfplot’. After you run your multivariable model, type:

 rvfplot, yline(0)

Question B1.6: Examine your residuals from the multivariable regression in B1.4. Does this model appear to violate the assumptions of normality and homoscedasticity?

Answer

The mean of the residuals is 0, which is one assumption fulfilled.

The histogram of the residuals also appears normal:

When looking at the rvfplot, we see:

There appears to a be a random ball of dots, with no pattern. This is what we want. There does not appear to be heteroscedasticity.

B1.6 PRACTICAL: SPSS

One of the final steps of any linear regression is to check that the model assumptions are met. Satisfying these assumptions allows you to perform statistical hypothesis testing and generate reliable confidence intervals.

Here we are going to practice checking the normality and homoscedasticity of the residuals.

Checking Normality of Residuals

We need to make sure that our residuals are normally distributed with a mean of 0. This assumption may be checked by looking at a histogram or a Q-Q-Plot.

To do this in SPSS, we need to first save the residuals. When you are in the General Linear Model window click on the Save button on the right hand side. Then tick the box for Unstandardized Residuals. Press continue and run the test as normal.

SPSS will output your residuals as a new variable. You can run descriptive statistics on this variable as outlined in Module A1.

Select

Analyze >> Descriptive >> Explore.

Select the option for Histogram within the Plots tab. You can deselect all other plot types so you don’t end up with too much output.

Checking Homoscedasticity

One of main assumptions of ordinary least squares linear regression is that there is homogeneity of variance (i.e. homoscedasticity) of the residuals. If the variance of our residuals is heteroscedastic then this indicates model misspecification. To check this we plot the values of our residuals against the fitted (predicted) values from our regression, and we hope to see a random scatterplot with no pattern. If we see a pattern, i.e. the scatterplot gets wider or narrower at a certain range of values, then this indicates heteroscedasticity and we need to re-evaluate our model.

To do this in SPSS you also need to save your unstandardized predicted values. Go back to your General Linear Model, open the Save tab again and select Unstandardized Predicted Values as well as Unstandardized Residuals.

Then create a scatter plot of these in the same way as you did in B1.1.

Examine your residuals from the multivariable regression in B1.4. Does this model seem to violate the assumptions of normality and homoscedasticity? 

Answer

The mean of the residuals is 0, which is one assumption fulfilled.

The histogram of the residuals also appears normal.

When looking at the scatter plot there appears to a be a random ball of dots, with no pattern. This is what we want. There does not appear to be heteroscedasticity.

B1.6 PRACTICAL: R

One of the final steps of any linear regression is to check that the model assumptions are met. Satisfying these assumptions allows you to perform statistical hypothesis testing and generate reliable confidence intervals.

Here we are going to practice checking the normality and homoscedasticity of the residuals.

Checking Normality of Residuals

We need to make sure that our residuals are normally distributed with a mean of 0. This assumption may be checked by looking at a histogram or a Q-Q-Plot.

To look at our residuals, we can use the function resid(). This function extracts the model residuals from the fitted model object (for example, in our case we would type resid(fit1)).

To check our residuals from the model we fit in B1.4 we would type:

hist(resid(fit5), main=”Histogram of the residuals”, xlab=”Residuals”)

> sum(resid(fit5))

[1] 4.768824e-12

It appears that our residuals are normally distributed with zero mean.

Checking Homoscedasticity

One of main assumptions of ordinary least squares linear regression is that there is homogeneity of variance (i.e. homoscedasticity) of the residuals. If the variance of our residuals is heteroscedastic then this indicates model misspecification, similar to the reasons discussed before.

To check homogeneity in variance this we plot the values of the residuals against the fitted (predicted) values from the regression model. If the assumptions is satisfied we should see a random scatter of the points with no pattern. If we see a pattern, i.e. the scatterplot gets wider or narrower at a certain range of values, then this indicates heteroscedasticity and we need to re-evaluate our model. To plot the residuals versus the fitted values, we can use plot(resid(fit5) ~ fitted(fit5), …).

> plot(resid(fit5) ~ fitted(fit5), main=”The residuals versus the fitted values”, xlab=”Fitted values”, ylab=”Residuals”, cex=0.8)
> abline(0,0, col=2)

Question B1.6: Examine your residuals from the multivariable regression in B1.4. Does this model appear to violate the assumptions of homoscedasticity?

Answer

There appears to be a random ball of dots, with no pattern. This is what we want. There does not appear to be heteroscedasticity.

👋 Before you go, leave an anonymous rating & feedback

Average rating 4.7 / 5. Vote count: 14

No votes so far! Be the first to rate this post.

Please share any positive or negative feedback you may have.

Feedback is completely anonymous

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Questions or comments?x