Перейти к содержимому

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

Rajendra Choure

0:00 / 0:00

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

2 782 просмотра · 5 лет назад
Rajendra Choure
9,43 тыс. подписчиков
2 782 просмотра · 5 лет назад
#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")