Exercises for 2.3: Simple inferential statistics

Preliminaries

  • load the driving.Rdatafile.
  • type head( driving )to look at the first few observations
  • load the following packages: lsr
load( "~/Work/Research/Rbook/workshop_dsto/datasets/driving.Rdata")
head( driving )
library(lsr)

Exercise 2.3.1: Confidence intervals

  • use ciMean()to calculate the 95% confidence interval for the mean age
  • use ciMean()to calculate the 99% confidence interval for the mean age
  • use ciMean()to calculate 95% confidence intervals for all variables
  • use aggregateand ciMeanto calculate 95% confidence intervals for the mean age separately for each distractor type

Exercise 2.3.2: Independent samples t-test

  • Run a t-test comparing the number of errors (at time 1) for the peak hour group versus the non peak hour group.
  • Calculate Cohen’s d.

Exercise 2.3.3: Paired samples t-test

  • Run a paired samples t-test to see if the number of errors made at time 2 differs from the number of erros people made at tie 1

Exercise 2.3.4: Chi-square goodness of fit tests

  • Run a chi-square goodness of fit to see if the number of females vs males differs significantly from chance

Exercise 2.3.5: Chi-square tests of association

  • Run a chi-square test of association to see if there is a significant association between gender and distractor type
  • Calculate Cramer’s V for the association

Exercise 2.3.6: Testing the significance of a single correlation

  • use cor.testto see if the Pearson correlation between errors and RT at time 1 is significant
  • again using cor.test, see if the Spearman correlation between errors and RT at time 1 is significant

Exercise 2.3.7: Testing all pairwise correlations

  • use correlateto test the significance of all pairwise correlations among (numeric) variables in driving