Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

How to add regression line to the given scatter plot in R?

$
0
0

@harry wrote:

I am currently trying to plot my regression model in the given scatter plot which I have a plot by using ggplot.I want to know how I can plot my model in the given plot.

#### Is the fertility rate of a country was a good predictor of the percentage of the population under 15?
ggplot(WHO, aes(x = FertilityRate, y = Under15)) + geom_point()

####  log transformation:
ggplot(WHO, aes(x = log(FertilityRate), y = Under15)) + geom_point()

#### Simple linear regression model to predict the percentage of the population under 15, using the log of the fertility rate:
mod = lm(Under15 ~ log(FertilityRate), data = WHO)
summary(mod)

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles