R Programming Language Certification Research & Evidence-Based Practice 3 — Questions and Answers
Question 1: Which R function performs a Shapiro-Wilk test to assess whether a variable follows a normal distribution?
- ks.test()
- shapiro.test() (Correct answer)
- nortest::ad.test()
- var.test()
Correct answer: shapiro.test()
shapiro.test() implements the Shapiro-Wilk normality test, returning a W statistic and p-value.
Question 2: In evidence-based research with R, what does a p-value below 0.05 conventionally indicate?
- The effect size is large
- The null hypothesis is accepted
- The result is statistically significant at the 5% level (Correct answer)
- The confidence interval contains zero
Correct answer: The result is statistically significant at the 5% level
A p-value < 0.05 means there is less than a 5% probability of observing the data if the null hypothesis were true.
Question 3: Which R function computes Cohen's d for measuring effect size between two groups?
- effect.size() from base R
- cohens_d() from the effectsize package (Correct answer)
- power.t.test()
- pwr.t.test()
Correct answer: cohens_d() from the effectsize package
The effectsize package provides cohens_d() to calculate Cohen's d standardized mean difference.
Question 4: A researcher fits a logistic regression in R using `glm(y ~ x, family = binomial)`. What does the model predict?
- The continuous mean of y
- The log-odds of y being 1 (Correct answer)
- The variance of y given x
- The absolute risk difference
Correct answer: The log-odds of y being 1
Logistic regression with binomial family models the log-odds (logit) of the binary outcome.
Question 5: In R, `cor.test(x, y, method = 'spearman')` is preferred over Pearson correlation when:
- Both variables are normally distributed
- The relationship is linear and homoscedastic
- Data are ordinal or the relationship is monotonic but not linear (Correct answer)
- Sample size exceeds 1000
Correct answer: Data are ordinal or the relationship is monotonic but not linear
Spearman correlation is a rank-based non-parametric method appropriate for ordinal data or non-linear monotonic relationships.
Question 6: What does the `VIF()` function from the car package measure in a multiple regression context?
- Variance explained by each predictor
- Variance Inflation Factor for multicollinearity detection (Correct answer)
- Model fit compared to a null model
- Heteroscedasticity of residuals
Correct answer: Variance Inflation Factor for multicollinearity detection
VIF (Variance Inflation Factor) quantifies how much a predictor's variance is inflated due to correlation with other predictors.
Question 7: Which R function is used to conduct a one-way ANOVA to compare means across three or more groups?
- t.test()
- aov() (Correct answer)
- kruskal.test()
- chisq.test()
Correct answer: aov()
aov() fits an analysis of variance model; summary(aov(...)) displays the ANOVA table with F-statistic and p-value.
Which R function performs a Shapiro-Wilk test to assess whether a variable follows a normal distribution?