Simple Linear Regression with lm in R
📖 Scenario: You are a data analyst at a small company. You want to understand how advertising spending affects sales. You have data on advertising budgets and sales for several months.
🎯 Goal: Build a simple linear regression model using lm in R to predict sales based on advertising spending.
📋 What You'll Learn
Create a data frame with advertising and sales data
Create a variable for the formula to use in the model
Use the
lm function to build the linear regression modelPrint the summary of the model to see the results
💡 Why This Matters
🌍 Real World
Linear regression is used in business to understand relationships between variables, like advertising spend and sales.
💼 Career
Data analysts and data scientists use linear regression to build predictive models and make data-driven decisions.
Progress0 / 4 steps