R Programming Language Certification Research & Evidence-Based Practice 5 — Questions and Answers
Question 1: Which R approach is used to implement k-fold cross-validation for evaluating predictive model performance?
- Using the caret or tidymodels package with trainControl(method='cv', number=k) (Correct answer)
- Using summary() on a fitted lm() object
- Using predict() with newdata on training data
- Using anova() to compare nested models
Correct answer: Using the caret or tidymodels package with trainControl(method='cv', number=k)
The caret package's trainControl(method='cv', number=k) sets up k-fold cross-validation for unbiased model evaluation.
Question 2: A researcher uses `mice` package in R. What research problem does this address?
- Multiple testing correction
- Missing data imputation using chained equations (Correct answer)
- Multi-level modeling of nested data
- Measurement invariance testing
Correct answer: Missing data imputation using chained equations
The mice package implements Multiple Imputation by Chained Equations (MICE) to handle missing data in research datasets.
Question 3: In R, `lavaan::sem()` is used for which type of analysis common in social science research?
- Survival analysis
- Structural Equation Modeling (Correct answer)
- Sequential experimental modeling
- Spatial estimation modeling
Correct answer: Structural Equation Modeling
The lavaan package's sem() function fits Structural Equation Models, allowing simultaneous estimation of multiple relationships.
Question 4: Which R function implements the Wilcoxon rank-sum test as a non-parametric alternative to the independent-samples t-test?
- kruskal.test()
- wilcox.test(x, y, paired = FALSE) (Correct answer)
- friedman.test()
- mann.whitney.test()
Correct answer: wilcox.test(x, y, paired = FALSE)
wilcox.test() with paired = FALSE performs the Wilcoxon rank-sum (Mann-Whitney U) test for two independent groups.
Question 5: In evidence-based research, what does `AIC` (Akaike Information Criterion) help researchers do when comparing R models?
- Determine statistical significance of individual predictors
- Select the model with the best balance of fit and complexity (Correct answer)
- Calculate the power of a study design
- Estimate missing values in the outcome variable
Correct answer: Select the model with the best balance of fit and complexity
AIC penalizes model complexity while rewarding fit; lower AIC indicates a better-balanced model among candidates.
Question 6: A researcher wants to visualize the relationship between a continuous predictor and a binary outcome from a logistic regression in R. Which approach is most informative?
- A boxplot of the predictor by outcome group
- A scatter plot with a logistic curve using geom_smooth(method='glm', method.args=list(family='binomial')) (Correct answer)
- A histogram of the predictor variable
- A Q-Q plot of the model residuals
Correct answer: A scatter plot with a logistic curve using geom_smooth(method='glm', method.args=list(family='binomial'))
geom_smooth with method='glm' and binomial family overlays a fitted logistic S-curve on the scatter plot.
Question 7: Which R function from base R computes a chi-square test of independence between two categorical variables in a contingency table?
- fisher.test()
- chisq.test() (Correct answer)
- prop.test()
- binom.test()
Correct answer: chisq.test()
chisq.test() tests whether two categorical variables are independent using the chi-square statistic on a contingency table.
Which R approach is used to implement k-fold cross-validation for evaluating predictive model performance?