1.1.4 Flashcards

(16 cards)

1
Q

What are explanatory variables?

A

Explanatory variable = independent variable = predictor variable = X

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

What are outcome variables?

A

Outcome variable = dependent variable = response variable = X

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

What is the difference between the manipulation of variables in experimental and observational studies?

A

Experimental = explanatory variable is manipulated before response variable is measured
Observational = variables are observed as they naturally exist (not controlled)

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

What does the group_by() function do?

A

Creates a grouping in the dataframe
Subsequent functions will be computed on each group

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

Why do we combine the group_by() and summarise() functions?

A

To reduce a variable into a summary value for each group in a grouping variable

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

How can we input group_by() and summarise() into R?

A

data %>%
group_by(grouping variable) %>%
summarise(
summary_value = …
)

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

How do we map something on a plot e.g. the colour, to something in the data e.g. a variable?

A

ggplot(data = dataframe, aes(x = variable 1, col = group in variable)) +
geom_density()

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

How can we split one plot up using facet_wrap to create separate graphs for each set of values/groups in a variable?

A

ggplot(data = dataframe, aes(x = variable)) +
geom_histogram() +
face_wrap(~variable/group)

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

What is the most easily interpreted visualisation of the relationship between two numeric variables?

A

Scatterplot

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

What is covariance, and what can it express?

A

A measure of how two numeric variables vary together
Can express the directional relationship

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

What are two ways of using the cov() function to calculate covariance?

A

Use $ to pull out variables from the datset e.g.
cov(dataframe$variableX, dataframe$variableY)
or
Specify dataframe and use %>% + call cov() inside
data %>%
summarise(
mean_variableX = mean(variableX)
mean_variableY = mean(vaariableY),
cov_variableXY = cov(variableX, variableY)
)

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

How can we summarise one categorical variable using the table function?

A

table(dataframe$categorical variable)
or
data %>%
count(categorical variable)

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

What is a two-way table?

A

A table with each variable on either dimension

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

How can we create a two-way table for two categorical variables in R?

A

table(dataframe$variable1, dataframe$variable2)

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

How can we create a proportion table for two categorial variables in R?

A

dataframe %>%
select(variableX, variableY) %>%
table() %>%
prop.table() for total proportions
prop.table(margin = 1) for proportions of each row
prop.table(margin = 2) for proportions of each column

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

How can we make a mosaic plot to visualise a contingency table of two categorical variables in R?

A

dataframe %>%
select(variable X, variable Y) %>%
table() %>%
or prop.table(margin = 1) %>%
or prop.table(margin = 2) %>%
plot()