Section 39 Simple Linear Regression Model: Exercise
39.1 Exercise 1:
Blood pressure of individuals
Fit a simple linear regression model of SBP with Age. Use the
lm
function to fit the model and discuss theanova
andsummary
outputs. Also check the diagnostic plots for model assumptions.Using the
lm
object, create your own customised R function that will return both theanova
table andsummary
table. Thesummary
table should include estimates of mean, SE, 95% CI along with t-statisic and corresponding two-tailed probability.Use the formula discussed earlier to develop your own
my.lm
function to fit a simple regression model. The function will take thex
andy
vectors through its arguments, fit a simple regression model and provideanova
andsummary
outputs.
39.2 Exercise 2:
The colony forming unit counts of bacteria grown at first 24 hours: bacteria.csv
The data include counts of colony forming unit (cfu) of a bacterium species recorded at each hour.
Fit a simple linear model of cfu data with hour.
Present the estimated mean, SE and confidence intervals.
39.3 Exercise 3:
Spending on different forms of advertisments and sales: Advertising.csv
Data show the spending on different forms of advertisments and sales for 200 companies.
Using a simple linear regression model, assess if the TV advertisement has contributed to sales. Use the
lm
function to fit the model and discuss theanova
andsummary
outputs. Also check the diagnostic plots for model assumptions.
39.4 Exercise 4:
Credit card balance of individuals: Credit.csv
Data include the credit card balance of 400 individuals and their personal profiles.
Using a simple linear regression model, evaluate if the balance depends on the age and income of individuals. Use the
lm
function to fit the model and discuss theanova
andsummary
outputs. Also check the diagnostic plots for model assumptions.Evaluate if the balance is different between the levels of Gender.