p values , r squared value and regression equation on ggplot : R programming

preview_player
Показать описание
#ggplot2 #rprogramming #annotationonplot #p-value, # r-squaredvalue #datavisualisation #scatterplot #smoothline

This video describes how to add p value, r-squared value and regression equation on ggplot2 plot.
# Scatter plot with p values, r-squared value and equation of linear regression model
# Data
conc=c(0 ,0, 0,10,10,10,20,20,20,30,30,30,40,40,40,50,50,50,
60,60,60,70,70,70,80,80,80,90,90,90, 100, 100 ,100)

OD = c(0.00,0.00,0.00,0.05,0.03,0.05,0.10,0.13,0.11,0.17,
0.15,0.15,0.23,0.23,0.22,0.28,0.29,0.27,0.41,0.46,
0.39,0.50,0.49,0.45,0.53,0.54,0.53,0.64,0.65,0.60,
0.74,0.69,0.73)

lmod= lm(OD~conc,df)
summary(lmod)

library(ggplot2)

ggplot(df,aes(conc,OD))+
geom_point()+
geom_smooth(method="lm",se=0)+
theme_classic()+
annotate("text",x=c(50,50,50),y=c(0.7,0.65,0.6),
label=c("p-value: 2.2e-16",
"Adjusted R-squared: 0.9839",
"OD=0.0073*conc-0.038"))

00:00 Data
00:40 scatter plot
02:50 linear regression model
04:40 adding text annotation
06:20 p-value on plot
06:40 R-squared value on plot
07:27 regression equation on plot
08:27 multi-labels in one annotation
Рекомендации по теме
Комментарии
Автор

Thanks for making this video upon request. Much appreciated.

pragneydeme
Автор

Thank you so much! This was super helpful!

maryamk
Автор

Thank you Rajendra Ji. This is really usefull!

chetanpatokar
Автор

Hello Mr Choure, I am kindly requesting for the command for Linear regression model

yetambuyusendoi
Автор

at first thank you for the lesson!
but i have a small question
how to display the number 2 as a superscript in r^2?

BrunoToshiroIchikawa
Автор

is there really no simpler way to add the other values than to copy the same annontate function multiple times? is it not possible to add multiple lines of text within one annotate function?

olebrumm
Автор

Thanks for your video, but I think this approach is only suitable for single graph if you have multiple datasets, this manual copy and paste one text after the other is too cumbersome and unsuitable for large data

fotensolution
join shbcf.ru