bmi-2011s

35
Reading data Gender and age Height and weight Inference What about the BMI? Viˇ sina, teˇ za in BMI Primer analize Andrej Blejec 20. oktober 2011

Upload: andrej-blejec

Post on 07-Mar-2016

221 views

Category:

Documents


2 download

DESCRIPTION

http://ablejec.nib.si/seminar2011/BMI-2011S.pdf

TRANSCRIPT

Page 1: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Visina, teza in BMIPrimer analize

Andrej Blejec

20. oktober 2011

Page 2: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Data analysis: BMI

To show the flavor of R data analysis, we will analyze a smalldataset of people’s height and weight. People try to care abouttheir body weight. It is a common knowledge, that weight isincreasing with height. To compensate for the influence of heighton weight, Body Mass Index (BMI) was introduced that can becalculated as:

BMI =weight

height2

where weight is measured in kilograms and height is measured inmeters.Our analysis will try to investigate the weights of different genderand age groups and the influence of height on weight andcalculated BMI.

Page 3: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Data file: bmiall.txt

gender age weight heightM 17 73.6 1.730M 17 71.0 1.765M 17 62.4 1.770M 17 71.0 1.870M 17 72.4 1.765

...

F 18 52.6 1.626F 18 46.2 1.624F 18 52.4 1.638F 18 54.0 1.630F 18 55.2 1.690F 18 55.4 1.677

Page 4: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Reading data

gender age weight height1 M 17 73.6 1.7302 M 17 71.0 1.7653 M 17 62.4 1.7704 M 17 71.0 1.8705 M 17 72.4 1.7656 M 17 104.0 1.825

Page 5: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Get info about the data

'data.frame': 419 obs. of 4 variables:$ gender: Factor w/ 2 levels "F","M": 2 2 2 2 2 2 2 2 2 2 ...$ age : int 17 17 17 17 17 17 17 17 17 17 ...$ weight: num 73.6 71 62.4 71 72.4 104 70.4 79.8 63.4 75.8 ...$ height: num 1.73 1.76 1.77 1.87 1.76 ...

[1] 419 4

Page 6: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Data summary

gender age weight heightF:205 Min. :17.00 Min. : 44.80 Min. :1.502M:214 1st Qu.:17.00 1st Qu.: 57.20 1st Qu.:1.652

Median :17.00 Median : 63.20 Median :1.720Mean :17.49 Mean : 64.59 Mean :1.7203rd Qu.:18.00 3rd Qu.: 71.00 3rd Qu.:1.780Max. :18.00 Max. :104.00 Max. :1.970

Page 7: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Gender and age tables

genderF M

205 214

agegender 17 18

F 101 104M 112 102

Page 8: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Flat contingency table

> highWeight <- weight > mean(weight)> ftable(gender, age, highWeight)

highWeight FALSE TRUEgender ageF 17 80 21

18 80 24M 17 40 72

18 29 73

Page 9: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Contingency tables ...

, , age = 17

genderhighWeight F M

FALSE 80 40TRUE 21 72

, , age = 18

genderhighWeight F M

FALSE 80 29TRUE 24 73

Page 10: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

... and independence test

Call: xtabs(formula = ~highWeight + gender + age)Number of cases in table: 419Number of factors: 3Test for independence of all factors:Chisq = 89.81, df = 4, p-value = 1.448e-18

highWeight gender age Freq1 FALSE F 17 805 FALSE F 18 803 FALSE M 17 407 FALSE M 18 292 TRUE F 17 216 TRUE F 18 244 TRUE M 17 728 TRUE M 18 73

Page 11: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Total, row, and column proportions: prop.table()

agegender 17 18

F 0.24 0.25M 0.27 0.24

agegender 17 18

F 0.49 0.51M 0.52 0.48

agegender 17 18

F 47.4 50.5M 52.6 49.5

Page 12: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Plot table - weight above Q3

17 18F 4 8M 43 49

Page 13: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Mosaic plot

Weight above Q3 = 71

17 18

FM

Page 14: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Barplot

17 18

Weight above Q3 = 71

010

2030

40

Page 15: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Numerical variables and summary statistics

> mean(weight)

[1] 64.5883

> mean(height)

[1] 1.719964

> c(sd(weight), sd(height))

[1] 10.53051077 0.08752747

> (V <- var(cbind(weight, height)))

weight heightweight 110.8916572 0.601565848height 0.6015658 0.007661059

> cor(weight, height)

[1] 0.6526635

> my.cor <- V[1, 2]/(sd(weight) * sd(height))> cat("Correlation r =", my.cor, "\n")

Correlation r = 0.6526635

Page 16: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Are there differences in weight and height in gender ageclasses?

Group.1 Group.2 weight height1 17 F 58.51881 1.6506442 18 F 59.42500 1.6566443 17 M 69.12500 1.7758574 18 M 70.88137 1.791794

Page 17: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Grand tour: heightData, histogram, boxplot, and quantile plot

●●●

●●

●●●●●●●

●●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●

●●●●

●●●●

●●

●●●

●●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●●●●

●●●

●●●

●●

●●●

●●

●●●

●●

●●●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●●

●●●●●●

●●

●●

●●●●

●●●

●●

●●●●

●●

●●

●●●●

●●

0 100 200 300 400

1.5

1.7

1.9

Index

x

Histogram of x

x

Fre

quen

cy1.5 1.6 1.7 1.8 1.9 2.0

020

4060

80

1.5

1.7

1.9

●●●

●●

●●

●●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●●

●●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●●●

●●●

●●●

●●

●●

●●

●●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●●

●●●

●●

●●

●●●●

●●

●●

●●●●

●●

●●

●●●●

●●

−3 −2 −1 0 1 2 3

1.5

1.7

1.9

Normal Q−Q Plot

Theoretical Quantiles

Sam

ple

Qua

ntile

s

Page 18: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Grand tour: weight

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●●

●●●

●●

●●

●●

●●●

●●●

●●●●

●●●

●●●

●●

●●●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●●

●●●●

●●●

●●

●●

●●●●●

●●

●●●●

0 100 200 300 400

5070

90

Index

x

Histogram of x

xF

requ

ency

40 50 60 70 80 90

020

4060

80

●●●●●●●●

5070

90

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●

●●●●

●●●

●●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●●●●

●●

● ●●●

−3 −2 −1 0 1 2 3

5070

90

Normal Q−Q Plot

Theoretical Quantiles

Sam

ple

Qua

ntile

s

Page 19: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

I am heavy because I am tall :)

●●

●●

●●

●●

● ●

●●

●●●

●●

● ●

●●●

●●

●●

●●

●●●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●

●●

●●

● ●

●●

●●●

●●●

●●● ●

● ●●

●●●

●●

●●

●●

●●

●● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●

● ●

●●

● ●●

●●●

● ●

●●●

●●

● ●

●●

●● ●

●●

●●

●●

●●

● ●

●●

●● ●

● ●

●●

● ●●●

●●

●●

● ●●

●●

●●

●●●● ●

●●

●●●●

1.5 1.6 1.7 1.8 1.9

5070

90

height

wei

ght

1

M MM

MM

M

M

M

M

MM

M

M

M

MM

M

MM

MM

M

M

M

M

M

MM

M

M

M

M

M

M

MMMMM

M

M

MM

M

MM

MM

M

MM

M

M

MM

M M

M

M

M

MM

M

MM

M

M

MMMM

M

M

M

M

MM

M

MMM

M

M

MMM

M

M

M

M

MMMM

M

M MMM

M

M

M

MM

M

M

MM

M

MM

M

M

MM

M

MM

MM

M

M

M

M

MM

MM

MM

M

MM

MMM

M

M

M

MM

MM

M

M MM

M

M

MM

M

M

M MM

M

MM

M M

M

M

M

M

M

MM

MM

MM M

M MM

M

M

MM

M

M

MMM

MMM

M

MM

M

MMM

M

MM MM

M

MM

MMMM

M

MMM

MM

MFF

F

F

FFF

F FF

F FF

F

FFFF

FF

FFF

FF

F

F

FF

FF

F

F

F

FF FF

F

FF

FFF

FFF

FF F

FF

F

FF

FFFF

F

F FFF

F

FFFF

FF

F

FFF

FF

F F

F

F

FF

FF FF

F

FF

F

F

F F

FF

F

FF

F FF

FF FF FF

FFF

FFF F

FF

FFF F

F

F

FFF

F

F

FF

F

FF

F

FF

F

F F

FF

F

F F

FF

F

F

F

FF

FFF

FF

FFF

FF

FF FF

F

F

F

F

F

F

F

F FFF

FF

F FF

FF FFF

FF

F

FFF

F FFF F

F

FFFFF FF

1.5 1.6 1.7 1.8 1.9

5070

90

heightw

eigh

t

2

● ●

●●

●●

●●

●●

● ●

●●

●●●●

●●

●●

●●

● ●

●●

●●

●●●

●●

●●●

●●●

●●

● ●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

● ●

●●

●● ●

●●

●●

●●

●●

●●

●●

●●●

● ●●

●●

●●

●●

●●●

●●●

●●●

● ●

●●●

●●●

●●

●●●

●●

●●

●● ●●

●●

●●●

●●●

● ●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

● ●

●●

●●

●●

● ●

●●

●●

● ●●

●●●

● ●

●●●

●●

● ●

●●

●●● ●

●●●

●●

●●

● ●

●●

●●

●●

●●

●●●

●●●●

●●

●● ●●

● ●●●

● ●●

● ●●●

●●●

●●● ●

●●●●●

●●

1.5 1.6 1.7 1.8 1.9

5070

90

height

wei

ght

3

●●

●●

●●

●●

● ●

●●

●●●●

●●

●●

●●

● ●

●●

●●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

● ●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●

● ●●

●●

● ●

●●

●●●

●●●

●●● ●

● ●●

●●●

●●

●●●

●●

●●

●● ●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

● ●

●●

●●

● ●

●●

●●

● ●●

●●●

● ●

●●●

●●

● ●

●●

●● ●

●●

●●

●●

●●

● ●

●●

●●●

●●

●●

● ●●●

●●

●●

● ●●

● ●●

●●

●●●● ●

●●

●●●●

1.4 1.6 1.8 2.0

4060

8010

0

height

wei

ght

4

Page 20: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

I am heavy because I am tall :)

Gender: F

Call:lm(formula = y ~ x)

Coefficients:(Intercept) x

-29.63 53.58

Gender: M

Call:lm(formula = y ~ x)

Coefficients:(Intercept) x

-81.98 85.20

Page 21: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

I am heavy because I am tall :)

●●

●●

●●

●●

● ●

●●

●●●

●●

● ●

●●●

●●

●●

●●

●●●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●

●●

●●

● ●

●●

●●●

●●●

●●● ●

● ●●

●●●

●●

●●

●●

●●

●● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●

● ●

●●

● ●●

●●●

● ●

●●●

●●

● ●

●●

●● ●

●●

●●

●●

●●

● ●

●●

●● ●

● ●

●●

● ●●●

●●

●●

● ●●

●●

●●

●●●● ●

●●

●●●●

1.5 1.6 1.7 1.8 1.9

5070

90

height

wei

ght

1

M MM

MM

M

M

M

M

MM

M

M

M

MM

M

MM

MM

M

M

M

M

M

MM

M

M

M

M

M

M

MMMMM

M

M

MM

M

MM

MM

M

MM

M

M

MM

M M

M

M

M

MM

M

MM

M

M

MMMM

M

M

M

M

MM

M

MMM

M

M

MMM

M

M

M

M

MMMM

M

M MMM

M

M

M

MM

M

M

MM

M

MM

M

M

MM

M

MM

MM

M

M

M

M

MM

MM

MM

M

MM

MMM

M

M

M

MM

MM

M

M MM

M

M

MM

M

M

M MM

M

MM

M M

M

M

M

M

M

MM

MM

MM M

M MM

M

M

MM

M

M

MMM

MMM

M

MM

M

MMM

M

MM MM

M

MM

MMMM

M

MMM

MM

MFF

F

F

FFF

F FF

F FF

F

FFFF

FF

FFF

FF

F

F

FF

FF

F

F

F

FF FF

F

FF

FFF

FFF

FF F

FF

F

FF

FFFF

F

F FFF

F

FFFF

FF

F

FFF

FF

F F

F

F

FF

FF FF

F

FF

F

F

F F

FF

F

FF

F FF

FF FF FF

FFF

FFF F

FF

FFF F

F

F

FFF

F

F

FF

F

FF

F

FF

F

F F

FF

F

F F

FF

F

F

F

FF

FFF

FF

FFF

FF

FF FF

F

F

F

F

F

F

F

F FFF

FF

F FF

FF FFF

FF

F

FFF

F FFF F

F

FFFFF FF

1.5 1.6 1.7 1.8 1.9

5070

90

heightw

eigh

t

2

● ●

●●

●●

●●

●●

● ●

●●

●●●●

●●

●●

●●

● ●

●●

●●

●●●

●●

●●●

●●●

●●

● ●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

● ●

●●

●● ●

●●

●●

●●

●●

●●

●●

●●●

● ●●

●●

●●

●●

●●●

●●●

●●●

● ●

●●●

●●●

●●

●●●

●●

●●

●● ●●

●●

●●●

●●●

● ●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

● ●

●●

●●

●●

● ●

●●

●●

● ●●

●●●

● ●

●●●

●●

● ●

●●

●●● ●

●●●

●●

●●

● ●

●●

●●

●●

●●

●●●

●●●●

●●

●● ●●

● ●●●

● ●●

● ●●●

●●●

●●● ●

●●●●●

●●

1.5 1.6 1.7 1.8 1.9

5070

90

height

wei

ght

3

●●

●●

●●

●●

● ●

●●

●●●●

●●

●●

●●

● ●

●●

●●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

● ●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●

● ●●

●●

● ●

●●

●●●

●●●

●●● ●

● ●●

●●●

●●

●●●

●●

●●

●● ●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

● ●

●●

●●

● ●

●●

●●

● ●●

●●●

● ●

●●●

●●

● ●

●●

●● ●

●●

●●

●●

●●

● ●

●●

●●●

●●

●●

● ●●●

●●

●●

● ●●

● ●●

●●

●●●● ●

●●

●●●●

1.4 1.6 1.8 2.0

4060

8010

0

height

wei

ght

4

Page 22: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Regression

●●

●●

●●

● ●

●●

●●●

● ●

●●●

●●

●●

●●

●●●

● ●

●●

●●

●●

●●

●●

●●

●●●

●●

● ●

●●

●●

●●

●●

●●

● ●

●●

●●

●●●

●●

●●

● ●

●●●

●●

● ●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

● ●

●●

● ●

●●●

●●●

● ●

●●

●●

●●

●●

● ●

●●

●●

● ●

●●

●● ●

●●

●●

●●●

●●

●●

● ●●

●●

●●

●●●●

●●

●● ●●

1.4 1.5 1.6 1.7 1.8 1.9 2.0

4050

6070

8090

110

height

wei

ght

Page 23: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Extract coefficients from all models

F M(Intercept) -29.62659 -81.98327height 53.58033 85.19731

Page 24: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Gender and age effects on height and weight

Df Sum Sq Mean Sq F value Pr(>F)gender 1 1.76308 1.76308 514.1828 < 2e-16 ***age 1 0.01282 0.01282 3.7395 0.05382 .Residuals 416 1.42642 0.00343---Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Df Sum Sq Mean Sq F value Pr(>F)gender 1 12631 12631.2 156.6954 <2e-16 ***age 1 188 187.9 2.3305 0.1276Residuals 416 33534 80.6---Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Page 25: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Gender and height effects on weight

Call:lm(formula = weight ~ 0 + gender * height)

Residuals:Min 1Q Median 3Q Max

-15.8396 -5.1961 -0.9167 4.2347 38.5225

Coefficients:Estimate Std. Error t value Pr(>|t|)

genderF -29.627 16.339 -1.813 0.0705 .genderM -81.983 15.882 -5.162 3.80e-07 ***height 53.580 9.875 5.426 9.82e-08 ***genderM:height 31.617 13.294 2.378 0.0178 *---Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 7.931 on 415 degrees of freedomMultiple R-squared: 0.9855, Adjusted R-squared: 0.9853F-statistic: 7027 on 4 and 415 DF, p-value: < 2.2e-16

Page 26: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Plot of predicted values shows interaction

●●

●●

●●

●●

●●●

● ●

●●

●●

●●

●●●

● ●

●●

●●

●●

●●

●●●

● ●

●●

●●

●●

●●

● ●

●●

●●●

●●

●●

● ●

●●●

●●

● ●

●●

●●

●●

●●

●●

● ●

●●

● ●

● ●

●●●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●

●● ●

●●

●●●

●●

●●

● ●●

●●

●●

●●●●

●●

●●

●●

1.5 1.6 1.7 1.8 1.9

5060

7080

9010

0

height

wei

ght

●●

●●

●●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●●

● ●

●●

●●

●●

●●●

●●

●● ●● ●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●●

●● ●

●●

● ●

●●

●●

●●

●●

●●

● ●

●●●

●●

● ●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●●

●●●

●●

● ●

●●

● ●●●

●●

●●●

●●●●

●●

●●●

●● ●●

●●

Page 27: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Student t-test

Welch Two Sample t-test

data: height by gendert = -22.6415, df = 416.359, p-value < 2.2e-16alternative hypothesis: true difference in means is not equal to 095 percent confidence interval:-0.1410314 -0.1184996

sample estimates:mean in group F mean in group M

1.653688 1.783453

Page 28: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Distribution of BMI

●●

●●

●●●●●

●●●

●●

●●●

●●

●●

●●●

●●

●●

●●●●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●●

●●●●

●●

●●

●●●

●●

●●

●●●

●●●●●

●●●●●●●

●●

●●●

●●

●●●●

●●

●●

●●

●●

●●

●●●●●●●

●●●●

●●

●●

●●

●●●●

●●

●●●

●●

●●

●●●●

●●●

●●

●●

●●●●

●●

●●●●●●●●●●●●

●●

●●

●●●●●●

●●

●●●●

●●●●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●●●

●●

●●●●●●

●●●●●

●●●●●●●

●●

●●●●●

●●●

●●

●●●●

●●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●●

●●●●

●●

●●

●●●●●

●●

●●●●●

0 100 200 300 400

2030

Index

x

Histogram of x

x

Fre

quen

cy

20 25 30 35

040

100

●●●●

●●●

2030

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●●

● ●●

●●

●●

●●●

●●

●●

●● ●

●●●●

●●●●●●

●●

● ●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●●●

●●

●●●

●●

●●

●●

●●●●

●●

●●●

●●

●●

●●

●●

●●●

●●

●●

●●●●

●●

●●●●

●●

●●

●●

●●

● ●

●●

●● ●●●

●●

●●●

●●●● ●

●●

●●● ●

●●

●●

●● ●

●●

●●

●●

●●●●

● ●

●●

●●

●●

●●●●

●●●●

●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●●

●●

●●

●●●●

●●

●● ●

●●

−3 −2 −1 0 1 2 3

2030

Normal Q−Q Plot

Theoretical Quantiles

Sam

ple

Qua

ntile

s

Page 29: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Make a new data frame and show correlations

weight height BMIweight 1.000 0.653 0.768height 0.653 1.000 0.022BMI 0.768 0.022 1.000

Page 30: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Plot scattergrams

weight

1.5 1.6 1.7 1.8 1.9

●●

●●

●●

●●

● ●

●●

●●●

●●

● ●

●●●

●●

●●

●●

●●●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●●

●●●

●●●

● ●●

●●●

●●

●●

●●

●●

●● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●

● ●

●●

● ●●

●●●

● ●

●●●

●●

●●

●●

●● ●

●●

●●

●●

●●

● ●

●●

●● ●

● ●

●●

●●●

●●

●●

● ●●

●●

●●

●●●●

●●

●●●●

5070

90

●●

● ●

● ●

●●

●●

●●

● ● ●

●●

●●

● ●●

●●

●●

●●

●● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

● ●

●●

●●

●●

●●

●●

●●

● ●●

● ●●

●●●

●●●

●●

●●

●●

●●

●●●●

● ●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

● ●●

●●

●●●

●●

●●

●●

●●●

● ●

●●

●●

●●

●●

●●

● ●●

●●

●●

●● ●

●●

●●

●● ●

●●

●●

●●● ●

● ●

●●●●

1.5

1.7

1.9

●●●

●●

●●

●● ●●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

● ●●

●●

●●

●●●

●● ●

● ●

●●

●●

●●

●●

●●

●●

●●

●● ●●

● ●

●●●

●● ●

●●

●●

●●

●●●

●●

●●

●● ●

●●

●●

●●

●●●●

●● ●

●●●

●●

●●●

●●

●●●

●●

●●●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

● ●

●●●

●●

●●

●●

●●

● ●

●●●

●●

●●

●● ●

●●

●●

●●

●●

●● ●●

●●

● ●

●●●

●●

●●

●●

●●●

●●●

●●

● ●

●●●●

●●

● ●

● ●●●

●●

● ●

●● ●●

●●

height ●●●

●●

●●

●● ●●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

● ●●

●●

●●

●●●

●● ●

● ●

●●

●●

●●

●●

●●

●●

●●

●● ●●

● ●

●●●

●● ●

●●

●●

●●

●●●

●●

●●

●● ●

●●

●●

●●

●●●●

●● ●

●●●

●●

●●

●●

●●●

●●

●●●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

● ●

●●●

●●

●●

●●

●●

● ●

●●●

●●

●●

●● ●

●●

●●

●●

●●

●● ●●

●●

● ●

●●●

●●

●●

●●

●●●

●●●

●●

● ●

●●●●

●●

● ●

● ●●●

●●

● ●

●● ●●

●●

50 60 70 80 90

● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●● ●●

●●●

● ●●

●●

●●

●●

●●

● ●● ●

●●

●●●

●●

●●

●● ● ●

● ●

●●

●●

●●

●●●

●●

● ●●●

●●

●●●

●●

●●

●●

● ●

●●

●● ●

●●

●●●

● ●

●●●

●●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

● ●●

●●●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●

● ●

●●

● ●●●

●●

●●●●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●● ●

●●●

● ●●

●●

●●

●●

●●

● ●● ●

●●

●●●

●●

●●

●●● ●

● ●

●●

●●

●●

●●●

●●

● ● ●●

●●

●●●●

●●

●●

●●

● ●

●●

●● ●

●●

●●●

● ●

●●●

● ●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

● ●●

●●●●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

● ●

●●

● ●

●●●

●●●

● ●

●●

● ●●●

●●

●●

●●

20 25 30 35

2025

3035

BMI

Page 31: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Distributions of numerical variables

F M

1.5

1.6

1.7

1.8

1.9

height

F M

5060

7080

9010

0

weight

F M

2025

3035

BMI

Page 32: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Calculated sizes of symbols

weight

1.5 1.6 1.7 1.8 1.9

● ●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●●

●●●

●●

● ●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●●

●●

● ●

●●

●● ●

● ●●

●●

●●

●●

●●

●●

●●●

● ●●●

●●

● ●

●●

●●●

●●●

●●●

● ●

●●●

●●●

●●

●●●

●●

●●

●● ●●

●●

●●●

●●●

● ●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

● ●

●●

●●

●●

● ●

●●

●●

● ●●

●●●

● ●

●●●

●●

● ●

●●

●● ●

●●●

●●

●●

● ●

●●

●●

●●

●●●

●●●●

●●

● ●●●

● ●●●

● ●●

● ●●●

●●●

●●● ●

●●

●●●●

5070

90

●●

● ●

●●

●●

●●

●●

●●

● ● ●●

●●

●●

●●

●●

●●

●●

●● ●

●●

●●

●●●

●●

●● ●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●●

●●●

●●

●●

●●●●

● ●

●● ●

●● ●●

●●

●●

●●

●●

● ●●

●● ●

●●

●●●

●●●

●●

●●

●●●

●●●

●●●●

●●

● ●●

●●

●●

●●

●●

●●

●●

● ●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●

● ●●

●●

●●●

●●

●●

●●

●●●

●● ●

●●

●●

●●

●●

●●

● ●

● ●●

●●

●●

●●

●● ●●

●●●●

●● ●

●●●

●●

●●●●● ●●

● ●

●●●●

1.5

1.7

1.9

●●●

●●

●●

●●

●●●● ●●●

●●

●●

● ●●

●●

●●

●●

●● ●

●●

●●

●●

●●

●●●

●● ●●

●●

●●

●●●

●● ●

●●

●● ●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●●

●● ●●

● ●

●●●

●● ●

●●

●●

●●

●●●

●●●

●●

●● ●

●●

●●

●●

●●

●●●●

●●

●● ●

●● ●

●●

●●●

●●●

●●

●●●

●●

●●●●●●

●●

●● ●

●●

●●

●●

● ●

●●

●●

● ●●

●●

● ●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●●

●●

● ●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●● ●●

●●

● ●

●●●

●●

●●

●●

●●●

●●●

●●

● ●

●●

● ●

● ●●●

●●

● ●●

● ●●●

●●

●● ●●

●● ●●

●●

height ●●●

●●

●●

●●

●●

●● ●●●

●●

●●

● ●●

●●

●●

●●

●● ●

●●

●●

●●

●●

●●●

●● ●●

●●

●●

●●●

●● ●

●●

●● ●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●●

●● ●●

● ●

●●●

●● ●

●●

●●

●●

●●●

●●●

●●

●● ●

●●

●●

●●

●●

●●●●

●●

●● ●

●● ●

●●

●●

●●

●●

●●●

●●

●●● ●●

●●

●● ●

●●

●●

●●

● ●

●●

●●

● ●●●●

● ●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●●

●●

● ●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●● ●●

●●

● ●

●●●

●●

●●

●●

●●●

●●●

●●

● ●

●●

● ●

●●●●

●●

● ●●

● ●●●●●

●● ●

●● ●●

●●

50 60 70 80 90

●●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●

● ●●

●●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●●● ●●

●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●● ●● ●

●●

●●●

●●

●●

●●

●●● ●

●●

●● ●

●●

●●

●●

●●

●●●

●●

●●

● ●●●

●●

●●●● ●

●●

●●

●●

● ●

● ●

●● ●● ●

● ●

●●●

● ●●●

●●

●●●●

●●

●●

● ●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●●●●

●●●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●●

● ●

●●

●●●●

●●

●●●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●

● ●●

●●●

●●

●●

●●●

●●

●●

●●

●●● ●

●●●● ●●

●●

●●●

●●

●●●

●●●

●●

●●

●●

●● ●● ●

●●

●●●

●●

●●

●●

●●● ●

●●

●● ●

●●

●●

●●

●●

●●●

●●

●●

● ● ●●

●●

●●●● ●

●●

●●●

●●

● ●

● ●

●● ●● ●

● ●

●●●

● ●●● ●

●●

● ●●●

●●

●●

● ●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●● ●●

●●●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●●

●●

● ●

●●

●●●

●●●

● ●

●●

● ●●●

●●

●●

●●

20 25 30 35

2025

3035

BMI

Page 33: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

BMI classes

> bmic <- cut(BMI, c(0, 13, 18, 25, 30, Inf))> levels(bmic)

[1] "(0,13]" "(13,18]" "(18,25]" "(25,30]" "(30,Inf]"

> levels(bmic) <- c("S", "s", "N", "h", "H")> bmic <- factor(bmic, levels = c("S", "s", "N", "h", "H"),+ ordered = T)> is.ordered(bmic)

[1] TRUE

Page 34: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Color coded BMI classes

weight

1.5 1.6 1.7 1.8 1.9

● ●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●●

●●●

●●

● ●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●●

●●

● ●

●●

●● ●

● ●●

●●

●●

●●

●●

●●

●●●

● ●●●

●●

● ●

●●

●●●

●●●

●●●

● ●

●●●

●●●

●●

●●●

●●

●●

●● ●●

●●

●●●

●●●

● ●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

● ●

●●

●●

●●

● ●

●●

●●

● ●●

●●●

● ●

●●●

●●

● ●

●●

●● ●

●●●

●●

●●

● ●

●●

●●

●●

●●●

●●●●

●●

● ●●●

● ●●●

● ●●

● ●●●

●●●

●●● ●

●●

●●●●

5070

90

●●

● ●

●●

●●

●●

●●

●●

● ● ●●

●●

●●

●●

●●

●●

●●

●● ●

●●

●●

●●●

●●

●● ●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●●

●●●

●●

●●

●●●●

● ●

●● ●

●● ●●

●●

●●

●●

●●

● ●●

●● ●

●●

●●●

●●●

●●

●●

●●●

●●●

●●●●

●●

● ●●

●●

●●

●●

●●

●●

●●

● ●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●

● ●●

●●

●●●

●●

●●

●●

●●●

●● ●

●●

●●

●●

●●

●●

● ●

● ●●

●●

●●

●●

●● ●●

●●●●

●● ●

●●●

●●

●●●●● ●●

● ●

●●●●

1.5

1.7

1.9

●●●

●●

●●

●●

●●●● ●●●

●●

●●

● ●●

●●

●●

●●

●● ●

●●

●●

●●

●●

●●●

●● ●●

●●

●●

●●●

●● ●

●●

●● ●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●●

●● ●●

● ●

●●●

●● ●

●●

●●

●●

●●●

●●●

●●

●● ●

●●

●●

●●

●●

●●●●

●●

●● ●

●● ●

●●

●●●

●●●

●●

●●●

●●

●●●●●●

●●

●● ●

●●

●●

●●

● ●

●●

●●

● ●●

●●

● ●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●●

●●

● ●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●● ●●

●●

● ●

●●●

●●

●●

●●

●●●

●●●

●●

● ●

●●

● ●

● ●●●

●●

● ●●

● ●●●

●●

●● ●●

●● ●●

●●

height ●●●

●●

●●

●●

●●

●● ●●●

●●

●●

● ●●

●●

●●

●●

●● ●

●●

●●

●●

●●

●●●

●● ●●

●●

●●

●●●

●● ●

●●

●● ●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●●

●● ●●

● ●

●●●

●● ●

●●

●●

●●

●●●

●●●

●●

●● ●

●●

●●

●●

●●

●●●●

●●

●● ●

●● ●

●●

●●

●●

●●

●●●

●●

●●● ●●

●●

●● ●

●●

●●

●●

● ●

●●

●●

● ●●●●

● ●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●●

●●

● ●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●● ●●

●●

● ●

●●●

●●

●●

●●

●●●

●●●

●●

● ●

●●

● ●

●●●●

●●

● ●●

● ●●●●●

●● ●

●● ●●

●●

50 60 70 80 90

●●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●

● ●●

●●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●●● ●●

●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●● ●● ●

●●

●●●

●●

●●

●●

●●● ●

●●

●● ●

●●

●●

●●

●●

●●●

●●

●●

● ●●●

●●

●●●● ●

●●

●●

●●

● ●

● ●

●● ●● ●

● ●

●●●

● ●●●

●●

●●●●

●●

●●

● ●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●●●●

●●●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●●

● ●

●●

●●●●

●●

●●●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●

● ●●

●●●

●●

●●

●●●

●●

●●

●●

●●● ●

●●●● ●●

●●

●●●

●●

●●●

●●●

●●

●●

●●

●● ●● ●

●●

●●●

●●

●●

●●

●●● ●

●●

●● ●

●●

●●

●●

●●

●●●

●●

●●

● ● ●●

●●

●●●● ●

●●

●●●

●●

● ●

● ●

●● ●● ●

● ●

●●●

● ●●● ●

●●

● ●●●

●●

●●

● ●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●● ●●

●●●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●●

●●

● ●

●●

●●●

●●●

● ●

●●

● ●●●

●●

●●

●●

20 25 30 35

2025

3035

BMI

Page 35: BMI-2011S

Reading data Gender and age Height and weight Inference What about the BMI?

Barplots are easy to understand ...

S s N h H

FM

050

100

150