R Programming Language Certification Statistical Analysis & Modeling 2 — Questions and Answers
Question 1: Which family argument in glm() is used for logistic regression?
- gaussian
- poisson
- binomial (Correct answer)
- gamma
Correct answer: binomial
Logistic regression models binary outcomes using glm() with family=binomial, which applies the logit link function by default.
Question 2: What does the confint() function compute for a fitted model in R?
- Confidence intervals for model coefficients (Correct answer)
- Prediction intervals for new data
- AIC and BIC values
- Variance inflation factors
Correct answer: Confidence intervals for model coefficients
confint() returns confidence intervals for the parameters of a fitted model, defaulting to 95% confidence level.
Question 3: Which test should you use to compare variances between two groups in R?
- t.test()
- var.test() (Correct answer)
- bartlett.test()
- levene.test()
Correct answer: var.test()
var.test() performs an F-test to compare the variances of two groups and determines if they are statistically equal.
Question 4: What does AIC stand for in model selection?
- Average Information Criterion
- Akaike Information Criterion (Correct answer)
- Adjusted Index of Correlation
- Analytic Information Coefficient
Correct answer: Akaike Information Criterion
AIC (Akaike Information Criterion) penalizes model complexity to balance goodness of fit with parsimony; lower AIC indicates a better model.
Question 5: Which R function performs a Wilcoxon rank-sum test (non-parametric equivalent of t-test)?
- wilcox.test() (Correct answer)
- mann.whitney()
- ranksum()
- nonpar.test()
Correct answer: wilcox.test()
wilcox.test() performs both the Wilcoxon signed-rank test (one-sample/paired) and the Wilcoxon rank-sum (Mann-Whitney) test for two independent samples.
Question 6: What does the predict() function do when called on a fitted lm() model?
- Retrains the model on new data
- Generates predicted values for new or existing data (Correct answer)
- Plots model residuals
- Computes cross-validation scores
Correct answer: Generates predicted values for new or existing data
predict() uses the fitted model coefficients to generate predicted (fitted) values for the original data or new observations supplied via newdata.
Which family argument in glm() is used for logistic regression?