Regression in R - Assignment-15

Practice Problems: Regression in R

Problem 1: Simple Linear Regression – Predicting Electricity Consumption

Problem Statement

A household wants to study the relationship between the number of electrical appliances used per day and its daily electricity consumption.

The following data are collected:

Appliances UsedElectricity Consumption (Units)
28
311
414
517
619
723
826
929

Tasks

Using Simple Linear Regression in R:

  1. Create a suitable data frame.
  2. Build a linear regression model to predict electricity consumption based on the number of appliances used.
  3. Obtain the regression equation.
  4. Display the model summary.
  5. Find the regression coefficients.
  6. Calculate the predicted electricity consumption for a household using 10 appliances.
  7. Obtain the predicted values and residuals.
  8. Plot the actual observations and the fitted regression line.
  9. Find and interpret the R-squared value.

Problem 2: Multiple Linear Regression – Predicting House Price

Problem Statement

A real estate company wants to predict the price of a house based on:

  • Area of the house (square feet)
  • Number of bedrooms

The following data are collected:

HouseArea (sq. ft.)BedroomsPrice (Lakhs)
1800132
2950238
31100245
41250352
51400358
61550364
71700472
81900480
92100488
102300598

Tasks

Using Multiple Linear Regression in R:

  1. Create a data frame containing the given data.
  2. Build a multiple linear regression model to predict house price using:
    • Area
    • Number of bedrooms
  3. Display the regression coefficients.
  4. Obtain the detailed model summary.
  5. Find the R-squared and Adjusted R-squared values.
  6. Predict the price of a house having:
    • Area = 1800 sq. ft.
    • Bedrooms = 4
  7. Obtain predicted values and residuals.
  8. Create an Actual vs Predicted Price plot.
  9. Interpret the contribution of the independent variables to the predicted house price.

Problem 3: Logistic Regression – Predicting Customer Purchase

Problem Statement

An online shopping company wants to predict whether a customer will purchase a product based on the amount of time spent browsing the website.

The outcome is represented as:

  • 0 → Did Not Purchase
  • 1 → Purchased

The following data are collected:

CustomerBrowsing Time (Minutes)Purchase
120
230
340
451
560
671
780
891
9101
10121
11130
12141
13151
14171
15181

Tasks

Using Binary Logistic Regression in R:

  1. Create a data frame containing the browsing time and purchase information.
  2. Build a Logistic Regression model using browsing time as the predictor.
  3. Display the model summary and interpret the regression coefficient.
  4. Predict the probability of purchase for each customer.
  5. Convert predicted probabilities into class labels using a 0.5 threshold.
  6. Create a confusion matrix comparing actual and predicted classes.
  7. Calculate the classification accuracy.
  8. Predict whether a new customer who spends 11 minutes browsing is likely to purchase the product.
  9. Plot the actual observations and the Logistic Regression probability curve.


Comments

Popular posts from this blog

Statistical Methods Lab ( R Language) PCCBL308 Semester 3 KTU BTech CB and CU 2024 Scheme - Dr Binu V P

Programs in R - using control statements - Assignment 2

Programs to try using Functions in R - Assignment 3