R Programming Language Certification Statistical Analysis & Modeling in R 1 — Questions and Answers
Question 1: Which R function fits a linear regression model?
- lm() (Correct answer)
- glm()
- regress()
- fit_linear()
Correct answer: lm()
lm() fits ordinary least squares linear models and returns an object with coefficients, residuals, and fit statistics.
Question 2: What does the summary() function return when applied to a linear model in R?
- Coefficients, standard errors, t-values, p-values, and R-squared (Correct answer)
- A plot of residuals
- The model formula only
- A confusion matrix
Correct answer: Coefficients, standard errors, t-values, p-values, and R-squared
summary(lm_object) displays the regression table with estimates, standard errors, t-statistics, p-values, and model fit statistics.
Question 3: Which function performs a two-sample t-test in R?
- t.test() (Correct answer)
- ttest()
- mean_test()
- hypothesis.test()
Correct answer: t.test()
t.test() performs one-sample, two-sample, or paired t-tests and returns the t-statistic, p-value, and confidence interval.
Question 4: What does cor() compute in R?
- The correlation coefficient between two or more variables (Correct answer)
- The covariance matrix
- A regression coefficient
- A chi-square statistic
Correct answer: The correlation coefficient between two or more variables
cor() computes Pearson (default), Spearman, or Kendall correlation coefficients between numeric vectors or columns.
Question 5: Which R function performs a one-way ANOVA?
- aov() (Correct answer)
- anova()
- lm()
- kruskal.test()
Correct answer: aov()
aov() fits an analysis of variance model; use summary(aov_object) to see the F-statistic and p-value.
Question 6: What does the p-value represent in a hypothesis test conducted in R?
- The probability of observing data at least as extreme as the sample, given the null hypothesis is true (Correct answer)
- The probability the null hypothesis is true
- The effect size
- The confidence interval width
Correct answer: The probability of observing data at least as extreme as the sample, given the null hypothesis is true
A p-value is the probability of obtaining a test statistic as extreme as observed, assuming the null hypothesis is true.
Which R function fits a linear regression model?