R-help to exercise 12

 

             

# Read the data into a dataframe, give names to the variables, and inspect the data:

gun=read.table("http://www.uio.no/studier/emner/matnat/math/STK4900/v17/gun.dat", col.names=c("method","phys","team","rounds"))

gun

 

# Check that the data correspond to those given in the exercise.

  

# QUESTION a)

 

# Compute correlations:

cor(gun)

 

# How are the correlations between the covariates ("method","phys","team")?

# Can you explain the reason for this?

# How are the correlations between the covariates and "rounds"?

 

 

# QUESTIONS b,c and d)

# Define the covariates as factors (categorical covariates):

gun$method=factor(gun$method)

gun$phys=factor(gun$phys)

gun$team=factor(gun$team)

 

 

# Fit a model with main effects and interactions and write the anova table:

gfit=lm(rounds~method*phys*team, data=gun) 

anova(gfit)

 

# What does the anova table tell you? Which interactions and main effects are significant?

 

# Look at the estimates:

summary(gfit)

 

# Give an interpretation of the (most important) estimates.