Back to Course

FoSSA: Fundamentals of Statistical Software & Analysis

0% Complete
0/0 Steps
  1. Course Information

    Meet the Teaching Team
  2. Course Dataset 1
  3. Course Dataset 2
  4. MODULE A1: INTRODUCTION TO STATISTICS USING R, STATA, AND SPSS
    A1.1 What is Statistics?
  5. A1.2.1a Introduction to Stata
  6. A1.2.2b: Introduction to R
  7. A1.2.2c: Introduction to SPSS
  8. A1.3: Descriptive Statistics
  9. A1.4: Estimates and Confidence Intervals
  10. A1.5: Hypothesis Testing
  11. A1.6: Transforming Variables
  12. End of Module A1
    1 Quiz
  13. MODULE A2: POWER & SAMPLE SIZE CALCULATIONS
    A2.1 Key Concepts
  14. A2.2 Power calculations for a difference in means
  15. A2.3 Power Calculations for a difference in proportions
  16. A2.4 Sample Size Calculation for RCTs
  17. A2.5 Sample size calculations for cross-sectional studies (or surveys)
  18. A2.6 Sample size calculations for case-control studies
  19. End of Module A2
    1 Quiz
  20. MODULE B1: LINEAR REGRESSION
    B1.1 Correlation and Scatterplots
  21. B1.2 Differences Between Means (ANOVA 1)
  22. B1.3 Univariable Linear Regression
  23. B1.4 Multivariable Linear Regression
  24. B1.5 Model Selection and F-Tests
  25. B1.6 Regression Diagnostics
  26. End of Module B1
    1 Quiz
  27. MODULE B2: MULTIPLE COMPARISONS & REPEATED MEASURES
    B2.1 ANOVA Revisited - Post-Hoc Testing
  28. B2.2 Correcting For Multiple Comparisons
  29. B2.3 Two-way ANOVA
  30. B2.4 Repeated Measures and the Paired T-Test
  31. B2.5 Repeated Measures ANOVA
  32. End of Module B2
    1 Quiz
  33. MODULE B3: NON-PARAMETRIC MEASURES
    B3.1 The Parametric Assumptions
  34. B3.2 Mann-Whitney U Test
  35. B3.3 Kruskal-Wallis Test
  36. B3.4 Wilcoxon Signed Rank Test
  37. B3.5 Friedman Test
  38. B3.6 Spearman's Rank Order Correlation
  39. End of Module B3
    1 Quiz
  40. MODULE C1: BINARY OUTCOME DATA & LOGISTIC REGRESSION
    C1.1 Introduction to Prevalence, Risk, Odds and Rates
  41. C1.2 The Chi-Square Test and the Test For Trend
  42. C1.3 Univariable Logistic Regression
  43. C1.4 Multivariable Logistic Regression
  44. End of Module C1
    1 Quiz
  45. MODULE C2: SURVIVAL DATA
    C2.1 Introduction to Survival Data
  46. C2.2 Kaplan-Meier Survival Function & the Log Rank Test
  47. C2.3 Cox Proportional Hazards Regression
  48. C2.4 Poisson Regression
  49. End of Module C2
    1 Quiz

Learning Outcomes

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

  • Explain when and how to use post hoc testing 
  • Explain the concept of multiple comparisons and be able to correct for it in their analysis
  • Apply extensions to the basic ANOVA test and interpret their results
  • Explain when and how to use repeated measures statistics

You can download a copy of the slides here: B2.4 Repeated Measures and the Paired t-test

B2.5 PRACTICAL: R

For this test you need a variable that has been measured twice in the same participants, so open the FoSSA Mouse data set.

Most statistical software (as a default) always assumes that each row is a participant, so if you have paired measurements you need to make sure you have stored them as separate variables, and they are matched up correctly so each participants ‘before’ and ‘after’ for example are on the same row in your data set.

Here we are going to do a paired t-test between the mouse weights at the start and end of the trial.

The paired t test command in R is:

ttest(x, y, paired=TRUE)

Here we write:

mouse<-FoSSA_mouse_data

t.test(mouse$Weight_baseline, mouse$Weight_end, paired=TRUE)

  • Question B2.5: Run the test and interpret the output. Is there a significant difference in mouse weight between the beginning and end of the trial?
Answer

Answer B2.5:

The output is:

> t.test(mouse$Weight_baseline, mouse$Weight_end, paired=TRUE)

Paired t-test

data:  mouse$Weight_baseline and mouse$Weight_end
t = 0.069672, df = 59, p-value = 0.9447
alternative hypothesis: true mean difference is not equal to 0
95 percent confidence interval:
-0.6468068  0.6934734
sample estimates:
mean difference
0.02333333

Our value for t is very small (0.070), which indicates a very small difference between the variables. Looking at the two tailed p-value (which is the default), there is no significant difference in weight between the start and end of the trial (p=0.94). We fail to reject the null hypothesis.

B2.5 PRACTICAL: Stata

For this test you need a variable that has been measured twice in the same participants, so open the FoSSA Mouse data set.

Most statistical software (as a default) always assumes that each row is a participant, so if you have paired measurements you need to make sure you have stored them as separate variables, and they are matched up correctly so each participants ‘before’ and ‘after’ for example are on the same row in your data set.

Here we are going to do a paired t-test between the mouse weights at the start and end of the trial.

The paired t test command in Stata is:

ttest var1=var2

Here we write:

ttest Weight_baselin= Weight_end

  • Question B2.5: Run the test and interpret the output. Is there a significant difference in mouse weight between the beginning and end of the trial?
Answer

The output is:

Our value for t is very small (0.070), which indicates a very small difference between the variables. Looking at the two tailed p-value (the middle value, Ha: mean(diff) !=0; P= 0.945), there is no significant difference in weight between the start and end of the trial. We fail to reject the null hypothesis.

B2.5 PRACTICAL: SPSS

For this test you need a variable that has been measured twice in the same participants, so open the FoSSA Mouse data set.

SPSS always assumes that each row is a participant, so if you have paired measurements you need to make sure you have stored them as separate variables, and they are matched up correctly so each participants ‘before’ and ‘after’ for example are on the same row in your data set.

Here we are going to do a paired t-test between the mouse weights at the start and end of the trial.

Select

Analyze >> Compare Means and Proportions >> Paired-Samples T Test

Move the two variables you are interested in into the spaces for Variable 1 and Variable 2 in Pair 1. In this case Weight_baseline and Weight_end.

You will notice that a second blank ‘pair’ is automatically created when you have completed the first pair. Also, your variables do not disappear from the box on the left hand side as they do in the majority of tests. This is because you can create multiple pairs to test in one go, and you can compare one variable to any number of variables.

Run the test and interpret the output. Is there a significant difference in mouse weight between the beginning and end of the trial?

Answer

Our value for t is very small (0.070), which indicates a very small difference between the variables.

SPSS has offered us a one-sided (one tailed) P value and a two-sided (two tailed) P value. As we didn’t make any predictions about the direction of change we want the two tailed P value.

Therefore P= 0.945 and there is no significant difference in weight between the start and end of the trial. We fail to reject the null hypothesis.

SPSS also automatically gives us an output for correlation between the variables when you run a paired t-test, so you will also see this in your output window.

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Questions or comments?x