06_Statistical_Analysis Flashcards

(5 cards)

1
Q

Front

A

Back

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

How do you run a two-sample t-test in R?

A

Use t.test(x, y, var.equal=) for means difference.

Code:
t.test(mpg ~ am, data = mtcars, var.equal = FALSE)

Notes:
Check normality & variance assumptions; use wilcox.test for nonparametric alternative.

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

How do you run a chi-squared test of independence?

A

Use chisq.test() on a contingency table.

Code:
tbl <- table(mtcars$cyl, mtcars$am)
chisq.test(tbl)

Notes:
Expected counts should be sufficiently large; else consider Fisher’s exact test (fisher.test).

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

How do you test correlation with cor.test()?

A

Use cor.test(x, y, method=’pearson’|’spearman’).

Code:
cor.test(mtcars$mpg, mtcars$hp, method=’spearman’)

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

How do you check normality?

A

Use shapiro.test() for small samples; also inspect QQ plots.

Code:
shapiro.test(mtcars$mpg)

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