R Programming Language Certification Statistical Analysis & Modeling 1 — Questions and Answers
Question 1: Which function in R fits a linear regression model?
- glm()
- lm() (Correct answer)
- regress()
- linearModel()
Correct answer: lm()
lm() (linear model) fits ordinary least squares linear regression and returns an object with coefficients, residuals, and fit statistics.
Question 2: What does the p-value in a t-test represent?
- The probability the null hypothesis is true
- The probability of observing results as extreme as observed, assuming H0 is true (Correct answer)
- The effect size of the difference
- The confidence level of the test
Correct answer: The probability of observing results as extreme as observed, assuming H0 is true
The p-value is the probability of obtaining a test statistic as extreme as or more extreme than the observed value, assuming the null hypothesis is true.
Question 3: Which function performs a Shapiro-Wilk test for normality in R?
- ks.test()
- shapiro.test() (Correct answer)
- normality.test()
- lillie.test()
Correct answer: shapiro.test()
shapiro.test() performs the Shapiro-Wilk test, which evaluates whether a sample comes from a normally distributed population.
Question 4: What is the purpose of the cor() function in R?
- Corrects outliers in data
- Computes correlation coefficients between variables (Correct answer)
- Runs a regression model
- Performs ANOVA
Correct answer: Computes correlation coefficients between variables
cor() computes pairwise correlation coefficients (Pearson by default) measuring linear association between numeric variables.
Question 5: Which function performs a one-way ANOVA in R?
- anova_test()
- aov() (Correct answer)
- oneway()
- f.test()
Correct answer: aov()
aov() fits an analysis of variance model and can be followed by summary() to display the ANOVA table with F-statistics and p-values.
Question 6: What does the summary() function return when applied to an lm() object?
- Only the residuals
- Coefficients, R-squared, F-statistic, and p-values (Correct answer)
- A plot of the regression line
- Only the model formula
Correct answer: Coefficients, R-squared, F-statistic, and p-values
summary() on an lm object displays coefficient estimates with standard errors and p-values, R-squared, adjusted R-squared, and the overall F-test.
Which function in R fits a linear regression model?