Linear Regression with One Regressor

General Information

  • Exercise covers linear regression with one regressor.

  • Data is available in the corresponding folder on Ilias.

Task 1: Linear Regression with One Regressor

  • Objective: Examine the linear relationship between the number of rooms and monthly rent.

  • Data from rental apartments in Lucerne:

    • Example values:

      • Price: 1,538 (2.5 rooms), 3,651 (6.0 rooms), etc.

  • Compute coefficients:

    • β<em>1\beta<em>1 (slope) and β</em>0\beta</em>0 (intercept).

  • Predict rental prices for:

    • 5.5-room and 3.5-room apartments.

Task 2: Linear Regression Analysis

  • Utilize a larger dataset for analysis in R.

  • Steps:

    1. Set up the R environment using tidyverse package.

    2. Import dataset: rental_data_lucerne.csv.

    3. Examine data structure and summary statistics, and check for missing values.

    4. Use histograms to explore variable distributions.

    5. Perform linear regression analysis:

    • Interpret the coefficient of determinationR2R^2.

    1. Create a scatterplot with a fitted linear regression line overlay.