When there’s people with 0 self esteem, we expect them to rate a life satisfaction as 2.4
With every 1 increase in self-esteem, we expect to see 0.65 increase in satisfaction of life
Predictor of self esteem explains 50% of the variation
Some reasons we might found this relationship:
Causation, higher self esteem causes more satisfaction of life
Pure chance, luck of sample, not representing whole population
Reverse causation: greater satisfaction o flife causes higher self esteem
Third variable causes both to be seeming related
Define & Check the data set (Categorical)
plot(mini$is.female)
summary(mini$is.female) #1 person seems left the field blank, the question intended to have only 2 responses, thus, there's an outlier
No Yes
1 27 80
Removing Outlier (categorical)
levels(mini$is.female)[1] <-NA
Define Linear Models
library(gplots)
Warning: package 'gplots' was built under R version 4.5.3
---------------------
gplots 3.3.0 loaded:
* Use citation('gplots') for citation info.
* Homepage: https://talgalili.github.io/gplots/
* Report issues: https://github.com/talgalili/gplots/issues
* Ask questions: https://stackoverflow.com/questions/tagged/gplots
* Suppress this message with: suppressPackageStartupMessages(library(gplots))
---------------------
Attaching package: 'gplots'
The following object is masked from 'package:stats':
lowess
mod2<-lm(satlife ~ is.female, data = mini)plotmeans(satlife ~ is.female, data=mini, xlab="Female", ylab="Satisfaction with Life")install.packages("gplots")
Warning: package 'gplots' is in use and will not be installed
abline(mod2, col="red", lwd =3)
coef(mod2)
(Intercept) is.femaleYes
5.296296 1.678704
summary(mod2)$r.squared
[1] 0.1262859
0 = no
1 = yes
When x is 0, female = no, dealing wiith males
Expected life satisfaction for male is 5.29 (x-intercept)
When goes from male to female, the expected life satisfaction for female is expected to increase by 1.67 (slope)
Our model explains 13% of variation in gender and satisfaction of life
Self esteem predicts life satisfaction better as it has a higher r-squared (explaining 50% of the variation) while gender only explains 13% of the variation
4 reasons:
Chance: Sample by chance show this relationship that may not represent the whole population
Causation: Being female causes greater satisfaction of life
Reverse causation: If you have greater life satisfaction, that make you women???NOT REALLY WORKING