# Create a custom dataset
data <- data.frame(
Age = c(25, 30, 35, 40, 45, 50, 55, 60, 65, 70),
Income = c(35000, 40000, 45000, 50000, 55000, 60000,
65000, 70000, 75000, 80000),
Education = c(12, 14, 16, 16, 18, 20, 20, 22, 24, 24)
)
# Display the dataset
print(data)
# Create a linear regression model
lm_model <- lm(Income ~ Age + Education, data = data)
# Summary of the linear regression model
summary(lm_model)
new_data <- data.frame(Age = 35, Education = 16)
predicted_income <- predict(lm_model, newdata =
new_data)
# Display the prediction
cat("Predicted Income:", predicted_income, "\n")
0 Comments