learn some statistical inference

Author

Bongani Ncube

Welcome to interactive learning

R Statistics Essential Training

Creating crosstabs for categorical variables

  • load the titanic dataset
  • look at the structure of the dataset using str()

Convert table to data frame with one row per observation

Check first five rows of data using head()

Create contingency table for survived and Class

  • Call also get cell, row, and column %
  • With rounding to get just 2 decimal places
  • Multiplied by 100 to make %

Chi-squared test

Additional tables

  • Observed frequencies (same as ttab)
  • Expected frequencies
  • Pearson’s residual
  • Standardized residual

Analysis of Variance

Comparing means with ANOVA

  • fill in and run , all have the same variance of 64

draw a boxplot

Combine vectors into a single data frame

Stack data to get one column with outcome

and second columns with group

Conduct one-way ANOVA

  • Formula result is F(3, 116) = 3.24, p = .025

Post-hoc comparisons

Your turn
10:30
  • define 4 variables with 40 observations , all have the same variance of 81 with mean

30,34,36,41

  • get the data into shape
  • now run an ANOVA test
  • do a post hoc test and save it in an object
  • plot the results using plot()