Lab #7: Comparing two groups with NHST


Remember to download the report template for this lab and open it in RStudio. You can download the template by clicking this link: http://bradthiessen.com/html5/stats/m300/lab7report.Rmd


Theory-based NHST (t-test)


Doctors and obesity

Let’s begin with the example we went through in class: Do doctors spend less time with obese patients? We’ll attempt to answer this question via null hypothesis significance testing (NHST). We’ll conduct a t-test first; then we’ll use randomization-based methods.

Let’s load the data and take a look at its structure:

doctors <- read.csv(url("http://bradthiessen.com/html5/stats/m300/doctors.csv"))
str(doctors)
## 'data.frame':    71 obs. of  2 variables:
##  $ weight: Factor w/ 2 levels "average","obese": 1 1 1 1 1 1 1 1 1 1 ...
##  $ time  : int  15 15 45 40 45 20 40 30 40 30 ...

We want to test the difference in time between average and obese patients. Let’s visualize the distribution of the time variable by weight:

# Side-by-side dotplots
dotPlot( ~time | weight, data = doctors, 
          width=1,            #Width of each "bar" = 1
          layout = c(1,2),    #Plot 1 column, 2 rows
          xlab = "Minutes spent with patient")