Question: Using programming language R Question 1: Conditional Expectations 2 points possible (graded) The heights dataset from the dslabs package (available from CRAN) contains self-reported heights

Using programming language R

Question 1: Conditional Expectations

2 points possible (graded)

The heights dataset from the dslabs package (available from CRAN) contains self-reported heights (in inches) for male and female students from three Harvard Biostatistics classes:

# install.packages("dslabs") if needed library(dslabs) data(heights) head(heights)

## sex height ## 1 Male 75 ## 2 Male 70 ## 3 Male 68 ## 4 Male 74 ## 5 Male 61 ## 6 Female 65

For simplicity, round heights to the nearest inch:

heights$height <- round(heights$height)

Treat these data as data for the whole population.

A. Calculate the conditional probability that a person 67 inches tall is female.

B. Calculate the conditional probability that a person is female for the vector of heights hts = 60:80. Make a plot of this conditional probability versus hts. Suppose you predict female for any height for which the conditional probability of being female E(Y=FemaleIX=xis > 0.5. What is the maximum height for which you predict a person is female?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres the R code to solve the given questions using the h... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!