Predict weight when height is given using linear regression in R

+4 votes
Suppose I have heights of a few people and based on that I need to predict their weights. is that possible in R?
Dec 12, 2018 in Data Analytics by Ali
• 10,380 points
476 views

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+1 vote

You can the concept of linear regression for this purpose. Its a statistic tool used to build relationship between to variables called predictor variable which is heights of people in your case and response variable which is weight in this case. Follow these steps:

  • Gather heights and weights like atleast a few observations.
  • use the lm() function to create the relationship model
  • use the coefficients from the model and create a mathematical equation.
  • predict the weight of new observations using the predict() function.
answered Dec 12, 2018 by Maverick
• 10,020 points
+1 vote

You can try something like this:

# The predictor vector.
a <- c(111, 123, 134, 156, 145, 176, 198, 133, 131, 181)

# The resposne vector.
b <- c(56, 61, 65, 71, 45, 54, 74, 76, 68, 58)

# Apply the lm() function.
relation <- lm(a~b)

# Find weight of a person with height 170.
z <- data.frame(x = 170)
result <-  predict(relation,z)
print(result)
answered Dec 12, 2018 by Purva

Related Questions In Data Analytics

+5 votes
0 answers
0 votes
1 answer

Steps to evaluate Linear Regression in R

 These are sequential steps which need to ...READ MORE

answered Jul 25, 2018 in Data Analytics by CodingByHeart77
• 3,680 points
79 views
0 votes
2 answers

When scoring a logistic regression model , is having the predicted variable in test dataset mandatory ?

Answer to your follow up question: We can ...READ MORE

answered Oct 17, 2018 in Data Analytics by Anmol
• 1,620 points
34 views
0 votes
1 answer

R programming: Linear programming problems

The documentation for the lp package provides ...READ MORE

answered Feb 4 in Data Analytics by Tyrion anex
• 8,280 points
51 views
0 votes
1 answer

R programming: Linear Equation

Use expand.grid to get all possible combinations ...READ MORE

answered Apr 30 in Data Analytics by Sophie may
• 9,330 points
10 views
+1 vote
2 answers
0 votes
1 answer

R programming logic

Use gsub to match the substring that we want ...READ MORE

answered Nov 16, 2018 in Data Analytics by Maverick
• 10,020 points
18 views
0 votes
1 answer

How is R applied in real world?

R Programming gives a broad variety of ...READ MORE

answered Oct 29, 2018 in Data Analytics by Maverick
• 10,020 points
27 views
0 votes
1 answer

Error saying "Error in rnorm() : argument "n" is missing, with no default" in R

Hey @ali, rnorm() function requires an argument, ...READ MORE

answered Oct 30, 2018 in Data Analytics by Maverick
• 10,020 points
110 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.