0% found this document useful (0 votes)
19 views1 page

Linear Regression p2

The document shows code to perform linear regression on height and age data, fit a linear model, make predictions, and plot the regression line on a chart.

Uploaded by

Priyu Sakhare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views1 page

Linear Regression p2

The document shows code to perform linear regression on height and age data, fit a linear model, make predictions, and plot the regression line on a chart.

Uploaded by

Priyu Sakhare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

# Values of age in months

x <- c(5,6,7,8,9,10,15,20,25,30)
# Values of height in cm.
y <- c(50,52,54,55,56,58,65,70,74,78)
relation <- lm(x~y)
print(relation)
a <- data.frame(x = 35)
View(a)
result <- predict(relation,a)
print(result)
png(file = "lr.png")

# Plot the chart.


plot(y,x,col = "blue",main = "Height & age Regression",
abline(lm(x~y)),cex = 1.3,pch = 16,xlab = "Age in months",ylab = "Height in
cm")

# Save the file.


dev.off()

You might also like