R Programming Language Certification Research & Evidence-Based Practice 2 — Questions and Answers
Question 1: Which R function is used to perform a paired t-test when comparing before-and-after measurements on the same subjects?
- t.test(x, y, paired = FALSE)
- t.test(x, y, paired = TRUE) (Correct answer)
- wilcox.test(x, y, paired = TRUE)
- chisq.test(x, y)
Correct answer: t.test(x, y, paired = TRUE)
Setting paired = TRUE in t.test() tells R the two vectors are matched pairs from the same subjects.
Question 2: In R, what does the `set.seed()` function ensure in a research context?
- Faster computation of random samples
- Reproducibility of random number generation (Correct answer)
- Prevention of duplicate values in a dataset
- Encryption of sensitive research data
Correct answer: Reproducibility of random number generation
set.seed() initializes the random number generator to a fixed state, ensuring the same 'random' results on every run.
Question 3: A researcher uses `lm(outcome ~ predictor, data = df)` in R. What does this fit?
- A logistic regression model
- A simple linear regression model (Correct answer)
- A Cox proportional hazards model
- A Poisson regression model
Correct answer: A simple linear regression model
lm() fits a linear model; with one predictor this is simple linear regression.
Question 4: Which R package provides the `tidy()` function to convert model outputs into clean data frames suitable for reporting?
- ggplot2
- dplyr
- broom (Correct answer)
- tidyr
Correct answer: broom
The broom package's tidy() function converts statistical model objects into tidy data frames.
Question 5: What is the purpose of `confint()` in R when evaluating a regression model?
- Compute confusion matrix metrics
- Calculate confidence intervals for model parameters (Correct answer)
- Test for multicollinearity among predictors
- Check residual normality
Correct answer: Calculate confidence intervals for model parameters
confint() returns confidence intervals for the estimated coefficients of a fitted model.
Question 6: In R, which function from the `psych` package computes Cronbach's alpha to assess scale reliability?
- reliability()
- alpha() (Correct answer)
- cronbach()
- scale.reliability()
Correct answer: alpha()
psych::alpha() computes Cronbach's alpha and related reliability statistics for a set of items.
Question 7: A researcher wants to check for publication bias in a meta-analysis using R. Which plot is most commonly used for this purpose?
- Violin plot
- Funnel plot (Correct answer)
- Forest plot
- Bland-Altman plot
Correct answer: Funnel plot
Funnel plots display effect sizes against standard errors; asymmetry suggests publication bias.
Which R function is used to perform a paired t-test when comparing before-and-after measurements on the same subjects?