R commands y2 Flashcards
What is the command to read data in from file x.txt and call it y?
y <- read.table(“x.txt”, h=T)
How do you specify that a dataset has a header?
h=T or header=TRUE
What is the command of printing dataset x?
print(x)
How do you plot every possible pair of variables in a dataset together?
plot(datasetname)
How do you see the correlation coefficient of each pair of variables in a dataset?
cor(datasetname)
How do you get the ANOVA for a model?
anova(modelname)
How do you know which variable to remove from a model after an looking at the significance of every variable?
Look at the values in the Pr(>|t|) column and remove the independent variable with the highest
When do you stop removing variables from a model when looking at the variance caused by specific variables?
When the Pr(>|t|) value of every variable remaining is significant (<0.05)
How do you make the model that you are using for looking at the variance provided by each variable?
m1=lm(DV~ IV1 + IV2 + IV3, data = datasetname)
How do you create the second model for a variance analysis after removing the first IV?
m1=lm(DV~ IV1 + IV2, data = datasetname)
How do you get the formula for the model after you have removed the final variable?
print(modelname)
What is a way to see if the model is significant without looking at the Pr(>|t|)?
Do an ANOVA between two models (e.g. ANOVA(m7,m8) and if the Pr(>F) value is significant then the penultimate model is significant
What does AIC stand for?
Akaike’s Information Criterion
What is the goal of running an AIC?
To minimise the AIC value
What are the benefits of an AIC?
The program runs to completion, so it is quicker than by hand