0% found this document useful (0 votes)
25 views1 page

Simple Linear Regression, Prediction: Heart and Body Weights

This document provides instructions for performing simple linear regression on a dataset of cat weights to predict heart weight based on body weight using R. The tasks include: 1) Loading the cats dataset and selecting data for male cats only, 2) Creating a scatterplot to examine the linear relationship between variables, 3) Fitting a linear regression model and adding the line to the plot, 4) Analyzing the coefficients and making predictions about heart weight differences based on body weight differences.

Uploaded by

Naski Kuafni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views1 page

Simple Linear Regression, Prediction: Heart and Body Weights

This document provides instructions for performing simple linear regression on a dataset of cat weights to predict heart weight based on body weight using R. The tasks include: 1) Loading the cats dataset and selecting data for male cats only, 2) Creating a scatterplot to examine the linear relationship between variables, 3) Fitting a linear regression model and adding the line to the plot, 4) Analyzing the coefficients and making predictions about heart weight differences based on body weight differences.

Uploaded by

Naski Kuafni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Lab 8

Simple linear regression, prediction: Heart and body weights

1. In the R package MASS there is a dataset called cats. Run the following commands:
library(MASS)

data(cats)

Have a look at the dataset. The variables Bwt and Hwt give the weight of the body (kg)
and the heart (g), respectively. There are both male and female cats. Make a dataset with
the data from males only.

2. Make a scatterplot of the data for the male cats (Bwt on x-axis, Hwt on y-axis). Does it
look reasonable to use a linear regression model for the data?
3. Fit a linear regresison model for the male cats, that allows for prediction of the heart
weight given the body weight. Add the fitted regression line to the scatterplot from the
previous question.
4. Find the coefficients of the fitted line. How large is the expected difference in heart
weight for two cats with a difference of 1 kg in bodyweight? Find a confidence interval
for this difference? How large is the expected difference in heart weight for two cats with
a difference of 100 g in bodyweight?
5. Use model validation plot to examine if the model is appropriate for the data.
6. Use the estimates to find the expected heart weight for a male cat that weighs 3 kg. Then
try the commands (where you replace the name regModel with whatever name you gave
the the model fit in question 2).

newObs <- data.frame(Bwt=3)


newObs
predict(regModel, newObs)
predict(regModel, newObs, interval="predict")

You might also like