0
0
R Programmingprogramming~5 mins

Linear regression (lm) in R Programming - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the lm() function in R?
The lm() function fits a linear regression model, which finds the best straight line to describe the relationship between a dependent variable and one or more independent variables.
Click to reveal answer
beginner
In the formula lm(y ~ x, data = df), what does y ~ x mean?
It means we want to predict y (dependent variable) using x (independent variable). The tilde ~ separates the outcome from the predictor.
Click to reveal answer
beginner
What does the coefficient estimate in a linear regression model represent?
It shows how much the dependent variable changes when the independent variable increases by one unit, assuming other variables stay the same.
Click to reveal answer
beginner
How do you check the summary of a linear model in R?
Use the summary() function on the model object, like summary(model). It shows coefficients, significance, and model fit statistics.
Click to reveal answer
intermediate
What does the Residuals section in summary(lm) tell you?
It shows the differences between observed and predicted values. Small residuals mean the model fits the data well.
Click to reveal answer
What does the lm() function in R do?
AFits a linear regression model
BCreates a scatter plot
CCalculates the mean of a variable
DPerforms a t-test
In lm(y ~ x, data = df), what is y?
AData frame name
BDependent variable
CIndependent variable
DModel summary
Which function shows detailed results of a linear model in R?
Alm()
Bplot()
Cmean()
Dsummary()
What does a coefficient estimate of 2 mean in a simple linear regression?
AFor each 1 unit increase in x, y increases by 2 units
BThe model has 2 predictors
CThe residual is 2
DThe intercept is 2
What do residuals represent in a linear regression model?
AModel coefficients
BPredicted values only
CDifferences between observed and predicted values
DIndependent variables
Explain how to fit a simple linear regression model in R using lm() and interpret the output.
Think about predicting one variable from another and checking the model summary.
You got /5 concepts.
    Describe what residuals are in linear regression and why they matter.
    Residuals tell us how well the model predictions match the actual data.
    You got /4 concepts.