Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Statement Given a data file of 507 individuals and their physical attributes (weight, height, etc. from the body dataset at http://www.amstat.org/publications/jse/datasets/), create two linear

Problem Statement Given a data file of 507 individuals and their physical attributes (weight, height, etc. from the body dataset at http://www.amstat.org/publications/jse/datasets/), create two linear regression models and their correlation:

between a person's BMI and their age.

between a person's weight and a combination of physical attributes. The authors propose the following formula:

-110 + 1.34(ChestDiameter) + 1.54(ChestDepth) + 1.20(BitrochantericDiameter) + 1.11(WristGirth) + 1.15(AnkleGirth) + 0.177(Height)

Background BMI is short for Body Mass Index, is a measure based on a person's weight and height. It is used as a estimator of healthy body weight (see http://en.wikipedia.org/wiki/Body_mass_index ) Linear regression is a form of regression analysis in which the relationship between one or more independent variables and another variable, called the dependent variable, is modeled by a least squares function, called a linear regression equation. A linear regression equation with one independent variable represents a straight line when the predicted value (i.e. the dependant variable from the regression equation) is plotted against the independent variable: this is called a simple linear regression. For example, suppose that a straight line is to be fit to the points (yi, xi), where i = 1, ..., n; y is called the dependent variable and x is called the independent variable, and we want to predict y from x.

Least Squares and Correlation The method we are going to use is called the least squares method. It takes a list of x values and y values (the same number of each) and calculates the slope and intercept of a line that best matches those values. See http://easycalculation.com/statistics/learn-regression.php for an example.

To calculate the least squares line, we need to calculate the following values from the data:

sumX and sumY:

the sum of all the X values and the sum of all the Y values

sumXY: the sum of all the products of each corresponding X,Y pair

sumXSquared and sumYSquared: the sum of the square of every X value and the sum of the square of every Y value

N: the number of pairs

The calculation then is:

slope=(N*sumXY - (sumX*sumY))/(N*sumXSquared - (sumX)2 )

intercept = (sumY - (slope*sumX)) / N

We will also then calculate the correlation coefficient, and indication of how "linear" the points are (how much, in total, the points are correlated as a line).

That calculation is:

corr = (N*sumXY - (sumX*sumY)) / sqrt((N*sumXSq - (sumX)2 ) * (N*sumYSq - (sumY)2 ))

The correlation value ranges between -1 and 1. A negative value means an inverse correlation, a positive value a positive correlation. Values near -1 or 1 are "good" correlations, values near 0 are "bad" correlations. See http://easycalculation.com/statistics/learn-correlation.php

Project Description

gather the data from the provided file 'bodydat.txt'. The file 'body.txt' describes the data.

For the BMI calculation, Age will be the x values, BMI the y values. The BMI calculation must be done with a function.

- BMI is not a value found in the data. You will have to calculate it using the data.

- Get the units right when you calculate the BMI!

For the formula (body weight vs. physical attributes), Weight will be the x values and the formula results the y values. The calculation of the formula must be done with a function.

- all units are correct as provided in the data for the formula

calculate the slope and intercept of a linear regression line for those two measures. Print those two values for both measures. The calculation must be done with a function.

calculate the correlation between the x and y data for both measures. Print the correlation. The calculation must be done with a function.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions