R commands y2 Flashcards

1
Q

What is the command to read data in from file x.txt and call it y?

A

y <- read.table(“x.txt”, h=T)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you specify that a dataset has a header?

A

h=T or header=TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the command of printing dataset x?

A

print(x)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you plot every possible pair of variables in a dataset together?

A

plot(datasetname)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you see the correlation coefficient of each pair of variables in a dataset?

A

cor(datasetname)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you get the ANOVA for a model?

A

anova(modelname)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you know which variable to remove from a model after an looking at the significance of every variable?

A

Look at the values in the Pr(>|t|) column and remove the independent variable with the highest

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When do you stop removing variables from a model when looking at the variance caused by specific variables?

A

When the Pr(>|t|) value of every variable remaining is significant (<0.05)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you make the model that you are using for looking at the variance provided by each variable?

A

m1=lm(DV~ IV1 + IV2 + IV3, data = datasetname)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you create the second model for a variance analysis after removing the first IV?

A

m1=lm(DV~ IV1 + IV2, data = datasetname)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you get the formula for the model after you have removed the final variable?

A

print(modelname)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a way to see if the model is significant without looking at the Pr(>|t|)?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does AIC stand for?

A

Akaike’s Information Criterion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the goal of running an AIC?

A

To minimise the AIC value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the benefits of an AIC?

A

The program runs to completion, so it is quicker than by hand

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you run an AIC on a model?

A

backward=step(modelname,direction=”backward”)

17
Q

How do you see the formula from the model after doing an AIC?

A

summary(modelname)

18
Q

What is PCA used for?

A

To explore the structure of multivariate data, it is a data reduction technique

19
Q

Limitations of PCA?

A

no null hypothesis

20
Q

Assumptions of PCA?

A

variables are continuous or on an interval scale

21
Q

How to remove a column from a dataset?

A

newdatasetname=olddatasetname[,-1]
where the column you are removing is the first column

22
Q

What are the two types of PCA?

A

covariance or correlation matrix

23
Q

What is a covariance PCA?

A

It gives some more weight to some variables than others depending on their variance

24
Q

What is a correlation matrix PCA?

A

it expresses every variable in standard deviation units so each one is weighted equally

25
Q

How to do a correlation matrix?

A

yourname=princomp(dataset,cor=TRUE)

26
Q

How to do a covariance matrix?

A

yourname=princomp(dataset)

27
Q
A