DS EXP5
DS EXP5
No: 5
Linear Regression, Test of significance and
DATE:
Residual Analysis
Aim:
To write the R program for Linear Regression, Test of Significance and Residual
Analysis
Procedure:
Step 1: Understand the input, output, and constraints.
Step 2: Break the problem into small steps logically.
Step 3: Define variables to store input and output.
Step 4: Use loops or conditionals to process the data.
Step 5: Write the code to implement the logic step by step.
Step 6: Test the program with sample inputs and verify outputs.
Step 7: Optimize and clean up the code for readability.
DataSet:
Source code:
library(ggplot2)
dataset <- salary_data
head(dataset)
model <- lm(Salary ~ Experience, data = dataset)
summary(model)
actual <- dataset$Salary
predicted <- predict(model)
sse_value <- sum((actual - predicted)^2)
sst_value <- sum((actual - mean(actual))^2)
rmse_value <- sqrt(mean((actual - predicted)^2))
Result:
Thus, to write the R program for Linear Regression, Test of Significance and Residual
Analysis was successfully verified.