R Year 2 Flashcards

1
Q

t test

A

t.test(vector, mu = no, alternative = “g”)

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

mu

A

Average

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

Alternative =

A

l for lower
g for greater

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

Can a t-test be used?

A

Do a variance test

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

Variance test

A

var.test(height$female, height$male) compares the variances of two groups of data to see if a t test can be used

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

Is it normal

A

shapiro test

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

Shapiro test

A

Shapiro.test() compares data to a normal distribution

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

equation for chi squared

A

sum(((chi$observed-chi$expected)^2)/chi$expected)

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

multiple linear regression

A

model1 = lm(dv ~ iv1+iv2+iv3….etc, dataset)
Compares dv to each iv within the dataset.

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

Remove rows containing 0 values

A

na.omit(data)

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

Anova

A

anova(data)
Number within the range is not significant difference

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

AIC

A

AIC = step(model1, direction = “backward”)

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

checking by going forward

A

forward = step(naive, scope = dv ~ iv1+iv2+iv3…, direction = “forward”)

where naive is the simplest model = lm(iv~1, data)

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

Give all the data the same scale

A

scale(data)

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

Correlation PCA

A

PCA = princomp(data, cor=TRUE)

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

Covariance PCA

A

PCA = princomp(data)

17
Q

Visualising PCA

A

screeplot(PCA)
Has elbow

18
Q

Way to see first two PCs

A

biplot(PCA)

19
Q

Influence of each component on original variables

A

loadings(PCA)

20
Q

Triangular matrix of differences

A

matrix1 = dist(data)

21
Q

Make clusters using matrix

A

clusters = hclust(matrix1)
can add in method = “single”, “complete”, etc default is euclidean

22
Q

Create dendrogram

A

plot(clusters)

23
Q

divide dendrogram into 4 clusters

A

rect.hclust(clusters, k=4, border=”red”)

24
Q

Make triangular distance matrix of dendrogram

A

cophenetic = cophenetic(clusters)

25
Q

Find cophenetic correlation

A

cor(matrix1, cophenetic)
Higher value given is better