Problems

Hone your R skills by doing problems.

1 2 3 4 5 6 7 8 9 10
educ 15 11 15 16 9 7 10 11 13 16
child 2 2 1 0 3 5 3 4 2 0

1 You collected the above set of data on years of education and

number of children for a sample of 10 married adults:

1.1 Use plot() or ggplot() to produce a scatter plot of the data.

1.2 Use plot() with abline() or ggplot() with geom_smooth() to draw the

regression line on the scatterplot.

1.3 Use R to calculate the regression slope and intercept. Report the

results in equation form, i.e. \(y=\alpha+\beta x\).

1.4 Predict the number of children for an adult with 11 years of education.

2 Use the lm() function to find the relationship between C and F.

You should find a linear equation of the form \(y=mx+b\). Hint: we know that 0 degree C equals 32 degree F, and that -40 degree C equals -40 degree F. Show your R code.

3 Use the cars package that is included in R. Type head(cars).

These are breaking distance, in feet, as they relate to the car speed, in mph.

3.1 Create a linear model

Capture the relashionship between speed and distance.

3.2 Use R, to find an estimate for the parameters of your model.

Report your results in one equation.

3.3 Predict the stopping distance of a car driving 23 mph.

3.4 Predict the speed of a car, if it took it 40 feet to stop.