One way, two way and n way ANOVA are used to test difference in means when we have one, two and n factor variables. A key assumption when performing these ANOVAs is that the measurements are independent. When we have repeated measures this assumption is violated, so we have to use repeated measures ANOVA. Repeated […]

## Repeated measures ANOVA in R Solutions

Solutions to exercises found here #################### # # # Exercise 1 # # # #################### #load the data setwd(“H:/data analysis”) library(foreign) exercise = read.csv(“exer.csv”) attach(exercise) head(exercise) ## id diet exertype pulse time ## 1 1 1 1 85 1 ## 2 1 1 1 85 2 ## 3 1 1 1 88 3 ## 4 […]

## Two Way ANOVA in R Exercises

One way analysis of variance helps us understand the relationship between one continuous dependent variable and one categorical independent variable. When we have one continuous dependent variable and more than one independent categorical variable we cannot use one way ANOVA. When we have two independent categorical variable we need to use two way ANOVA. When […]

## Two Way ANOVA in R Solutions

Solutions to exercises found here #################### # # # Exercise 1 # # # #################### #Read in the moth experiment data setwd(“H:/datasets”) moth.experiment = read.csv(“moth trap experiment.csv”, header = TRUE) #Inspect structure of the data head(moth.experiment) ## number.of.moths location type.of.lure ## 1 32 Top Chemical ## 2 29 Top Chemical ## 3 16 Top Chemical […]

## One Way Analysis of Variance Exercises

When we are interested in finding if there is a statistical difference in the mean of two groups we use the t test. When we have more than two groups we cannot use the t test, instead we have to use analysis of variance (ANOVA). In one way ANOVA we have one continuous dependent variable […]

## One Way Analysis of Variance Solutions

These are the solutions to the exercises One Way Analysis of Variance here #################### # # # Exercise 1 # # # #################### #Read in the cancer survival.csv data setwd(“H:/datasets”) cancer.survival = read.csv(“cancer survival.csv”, header = TRUE) #Inspect structure of the data head(cancer.survival) ## Survival Organ ## 1 124 Stomach ## 2 42 Stomach ## […]

## Paired t-test in R Exercises

The paired samples t test is used to check if there are any differences in the mean of the same sample at two different time points. For example a medical researcher collects data on the same patients before and after a therapy. A paired t test will show if the therapy improves patient outcomes. There […]

## Paired t test in R Solutions

Solutions to exercises on paired t-test found here #################### # # # Exercise 1 # # # #################### #Load package MASS library(MASS) #attach anorexia data so that variables are easily accessible attach(anorexia) #Inspect structure of the data head(anorexia) ## Treat Prewt Postwt ## 1 Cont 80.7 80.2 ## 2 Cont 89.4 80.1 ## 3 Cont […]

## Independent t test in R

The independent t test is used to test if there is any statistically significant difference between two means. Use of an independent t test requires several assumptions to be satisfied. The assumptions are listed below The variables are continuous and independent The variables are normally distributed The variances in each group are equal When these […]

## Independent t-test Solutions

Below are the solutions to these exercises on the independent t test #################### # # # Exercise 1 # # # #################### #Display the first few rows of the data to understand its structure head(mtcars) ## mpg cyl disp hp drat wt qsec vs am gear carb ## Mazda RX4 21.0 6 160 110 3.90 2.620 […]