Simple linear regression and prediction in R ,with validation of model

Опубликовано: 25 Апрель 2026
на канале: Rajendra Choure
2,766
73

#simplelinearregression #rprogramming #

This video discusses linear regression and prediction using R programming, for the analysis of biochemical assay results.


Data: https://drive.google.com/file/d/1kW0R...

Download the csv file and store in your working directory, as shown in video

import the data
setwd("H:/Rworks/R training/linear regression") # set your working directory and save data file in that directory.
df = read.csv("assayRes.csv")
head(df)
str(df)
attach(df)
plot(conc,abs)
cor.test(conc,abs)

split the data
index= sample(1:nrow(df), round(0.8*nrow(df),0),replace=FALSE)

train= df[index,]
test=df[-index, ]

dim(train)
dim(test)

fit model
lm_mod = lm(abs~conc,train)
lm_mod
summary(lm_mod)

plot(lm_mod)
validate the model
pred = predict(lm_mod,test)
pred

test$pred=pred
test

visualize the predcited and actual vlaues
library(ggplot2)
ggplot(test,aes(x=conc))+
geom_point(aes(y=abs),color="red")+
geom_point(aes(y=pred),color="blue")