airbnb analysis

# Load dataset airbnb_nyc <- read_csv(C:/Users/MCuser/Downloads/airbnb_ny19.csv)

Exploring Airbnb Dataset in New York City Introduction This dataset contains information about Airbnb listings in New York City. The variables included are:

price: the price of the listing per night accommodates: the number of people the listing can accommodate bedrooms: the number of bedrooms in the listing bathrooms: the number of bathrooms in the listing review_scores_rating: the rating score of the listing neighbourhood_group: the borough the listing is located in We plan to explore the relationship between the price of Airbnb listings and the number of people they can accommodate, as well as the number of bedrooms they have.

Data source: Inside Airbnb

```{r}markdown # Exploring Airbnb Dataset in New York City

Introduction

This dataset contains information about Airbnb listings in New York City. The variables included are:

I plan to explore the relationship between the price of Airbnb listings and the number of people they can accommodate, as well as the number of bedrooms they have.

Data source: Inside Airbnb

The data cleaning

```{r}# Check for missing values
missing_values <- colSums(is.na(airbnb_nyc))
print(missing_values)

# Remove rows with missing values in variables of interest
airbnb_clean <- airbnb_nyc %>%
  drop_na(price, accommodates, bedrooms)

# Remove outliers
airbnb_clean <- airbnb_clean %>%
  filter(price <= quantile(price, 0.99),
         accommodates <= quantile(accommodates, 0.99),
         bedrooms <= quantile(bedrooms, 0.99))

# Check summary statistics after cleaning
summary(airbnb_clean)```

Linear Regression Analysis


```{r}# Perform linear regression
lm_model <- lm(price ~ accommodates + bedrooms, data = airbnb_clean)

# Summary of linear regression
summary(lm_model)```

The equation for the model is:

price
=
�
0
+
�
1
×
accommodates
+
�
2
×
bedrooms
+
�
price=β 
0
​
 +β 
1
​
 ×accommodates+β 
2
​
 ×bedrooms+ϵ

Where:

�
0
β 
0
​
  is the intercept,
�
1
β 
1
​
  is the coefficient for accommodates,
�
2
β 
2
​
  is the coefficient for bedrooms, and
�
ϵ is the error term.
The p-values for both accommodates and bedrooms are significant (p < 0.05). The adjusted 
�
2
R 
2
  value is 0.36, indicating that the model explains 36% of the variance in the price of Airbnb listings.

Data Visualization 

# Scatterplot with regression line

ggplot(airbnb_nyc, aes(x = accommodates, y = price, color = as.factor(bedrooms))) + geom_point() + geom_smooth(method = “lm”, se = FALSE, aes(group = 1)) + scale_color_manual(values = c(“red”, “blue”, “green”, “orange”, “purple”)) + labs(x = “Accommodates”, y = “Price”, title = “Price vs Accommodates by Number of Bedrooms”, caption = “Data source: Inside Airbnb”, color = “Bedrooms”) + theme_minimal() + theme(legend.position = “bottom”)```

The visualization above shows the relationship between the price of Airbnb listings and the number of people they can accommodate, colored by the number of bedrooms. Each point represents a listing, and the line represents the linear regression model fitted to the data.

Essay

  1. The data Cleaning:

Missing values were handled by removing rows with missing values in the variables of interest. Outliers were removed by filtering out observations with prices, accommodates, and bedrooms beyond the 99th percentile. b. Visualization Interpretation:

The visualization illustrates a positive relationship between the price of Airbnb listings and the number of people they can accommodate. Additionally, it shows that listings with more bedrooms tend to have higher prices, as indicated by the trend of colors from lighter (fewer bedrooms) to darker (more bedrooms) along the regression line. c. Additional Considerations:

While this analysis focused on linear regression and visualization of price against accommodates and bedrooms, further exploration could include examining the impact of other variables such as location or property type on listing prices. Additionally, more sophisticated modeling techniques like random forests or gradient boosting could be explored for predictive accuracy. This document provides an overview of exploring the Airbnb dataset in New York City, including data cleaning, linear regression analysis, data visualization, and a reflective essay on the process.