Airbnb <- read.csv("airbnb_116.csv", header=TRUE, sep=",")
library(latticeExtra)
## Loading required package: lattice
Question 1: accommodates and cleaning fee are selected as quantitative variables and room type and host is super-host are categorical variables.
Questions 2 and 3: 2. a) Regarding accommodates, the mean and median are 4.2 and 4.0, respectively. These numbers—62.77 and 47.50—were received for the cleaning cost. The existence of a considerably high maximum value (16.0) and a mean (4.2) that is somewhat greater than the median (4.0) indicate a larger tail on the right side of the distribution, indicating a right-skewed distribution. The cleaning-fee variable has a right-skewed distribution, as seen by its highest value (389.0), which is substantially bigger than both the median (47.50) and mean (62.77). This pattern indicates that the distribution’s tail is being pulled to the right by a small number of big values.
3.a and b)the capacity of listings is typically consistent, while cleaning fees vary more, especially among entire homes and apartments. Superhost status does not seem to affect the number of guests accommodated, but room type correlates with the cleaning fee charged.
Accommodates:Distribution is nearly symmetric, with most listings accommodating a similar number of guests.A few listings accommodate significantly more guests, as seen by outliers.
Cleaning Fee:Right-skewed distribution, with most listings charging a lower cleaning fee and a few charging much higher fees. Outliers present, indicating some listings with unusually high cleaning fees.
Accommodates vs. Superhost Status:No marked difference in the number of guests accommodated by superhosts vs. non-superhosts. Both groups have outliers, indicating some listings that can accommodate many guests.
Cleaning Fee vs. Room Type: Entire homes/apartments tend to have higher cleaning fees compared to private or hotel rooms. Clear outliers in the entire homes/apartments category suggest some listings with significantly higher cleaning fees.
bwplot(~accommodates, data=Airbnb)
histogram(~accommodates, data=Airbnb, main="Number of bedrooms in Asheville AirBnBs", xlab="accomadates",type="count")
summary(Airbnb$accommodates)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.0 2.0 4.0 4.2 6.0 16.0
bwplot(~cleaning_fee, data=Airbnb)
histogram(~cleaning_fee, data=Airbnb, main="Number of bedrooms in Asheville AirBnBs", xlab="cleaning_fee",type="count")
bwplot(accommodates ~ host_is_superhost, data=Airbnb )
bwplot(room_type ~ cleaning_fee, data=Airbnb )
summary(Airbnb$cleaning_fee)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 0.00 25.00 47.50 62.77 75.00 389.00 2
accommodates_std <- sd(Airbnb$accommodates)
accommodates_range <- range(Airbnb$accommodates)
accommodates_iqr <- IQR(Airbnb$accommodates)
cleaning_fee_std <- sd(Airbnb$cleaning_fee)
cleaning_fee_range <- range(Airbnb$cleaning_fee)
print(accommodates_std)
## [1] 2.626397
print(accommodates_range)
## [1] 2 16
print(accommodates_iqr)
## [1] 4
Question 4: According to the Airdna , in 2023, the average cleaning fee in the U.S. for a private/shared room on Airbnb was $48 per stay, while the average fee for a house with five bedrooms was $303. Therefore, the cleaning fee highly depends on the number of rooms. The null hypothesis is that the average Airbnb cleaning fee is at least $48; the alternative hypothesis is that the average cleaning fee is less than $48. https://www.airdna.co/blog/airbnb-cleaning-fees-what-hosts-need-to-know
mean_cleaning_fee <- mean(Airbnb$cleaning_fee)
std_dev <- sd(Airbnb$cleaning_fee)
n <- length(Airbnb$cleaning_fee)
mu_0 <- 48
t.test_result <- t.test(Airbnb$cleaning_fee, mu = mu_0, alternative = "two.sided")
# Output the result
print(t.test_result)
##
## One Sample t-test
##
## data: Airbnb$cleaning_fee
## t = 1.4324, df = 47, p-value = 0.1587
## alternative hypothesis: true mean is not equal to 48
## 95 percent confidence interval:
## 42.02518 83.51648
## sample estimates:
## mean of x
## 62.77083
Question 5:The 95% confidence interval for the mean number of people that Airbnb listings accommodate ranges from approximately 3.45 to 4.95. Lower Bound (3.45): The interval’s lower bound represents that on average, the smallest Airbnb listing accommodates at least 3 to 4 people. This could be indicative of properties that offer at least one bedroom or a studio layout that can comfortably accommodate a small group or family. Upper Bound (4.95): The upper limit rounds up to about 5 people, suggesting that many Airbnb listings cater comfortably to medium-sized groups or families. This can imply the presence of multiple bedrooms or more spacious accommodations.
t.test(Airbnb$accommodates, mu=2, alternative = "two.sided")
##
## One Sample t-test
##
## data: Airbnb$accommodates
## t = 5.9231, df = 49, p-value = 3.074e-07
## alternative hypothesis: true mean is not equal to 2
## 95 percent confidence interval:
## 3.453586 4.946414
## sample estimates:
## mean of x
## 4.2
t.test(Airbnb$accommodates)$"conf.int"
## [1] 3.453586 4.946414
## attr(,"conf.level")
## [1] 0.95
Question 6: Since the P-value is less than the significance level (0.05), we reject the null hypothesis. There is sufficient evidence to warrant rejection of the claim that the mean of cleaning fee in Airbnb is $50.
Question 7:This indicates that we are 95% confident that the true mean cleaning fee for Airbnb listings falls between approximately $42.03 and $83.52. This range captures the average amount that a guest might expect to pay as a cleaning fee when booking an Airbnb. The width of this interval suggests some variability in cleaning fees, possibly reflecting differences in property size, location, or host policies.
t.test(Airbnb$cleaning_fee, mu=2, alternative = "two.sided")
##
## One Sample t-test
##
## data: Airbnb$cleaning_fee
## t = 5.8931, df = 47, p-value = 3.906e-07
## alternative hypothesis: true mean is not equal to 2
## 95 percent confidence interval:
## 42.02518 83.51648
## sample estimates:
## mean of x
## 62.77083
t.test(Airbnb$cleaning_fee)$"conf.int"
## [1] 42.02518 83.51648
## attr(,"conf.level")
## [1] 0.95
Question 8: Due to the challenge of finding a perfect continuous variable for Airbnb, we can treat certain variables that have a relatively high range of numerical values as continuous. We consider ‘reviews_per_month’ as it represents a rate, which is inherently continuous. This variable indicates the average number of reviews a listing receives per month, and higher review activity could correlate with higher prices, either due to increased demand or perceived value.
Question 9: The data reveal a strong positive linear relationship between the cleaning fee and Airbnb prices, with a substantial portion of the price variability explained by the cleaning fee. The statistical analysis confirms the relationship is significant.
reg = lm(price ~ cleaning_fee, data=Airbnb)
xyplot(price ~ cleaning_fee, data = Airbnb, type = c("p", "r"))
summary(reg)
##
## Call:
## lm(formula = price ~ cleaning_fee, data = Airbnb)
##
## Residuals:
## Min 1Q Median 3Q Max
## -236.59 -45.35 -3.83 27.93 384.15
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 15.4810 21.9768 0.704 0.485
## cleaning_fee 2.2426 0.2325 9.647 1.26e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 113.9 on 46 degrees of freedom
## (2 observations deleted due to missingness)
## Multiple R-squared: 0.6692, Adjusted R-squared: 0.662
## F-statistic: 93.07 on 1 and 46 DF, p-value: 1.259e-12
Question 10:Intercept (15.481042): The base price for Airbnb listings without a cleaning fee is approximately $15.48. Slope (2.242585): Each additional dollar in cleaning fee increases the listing price by approximately $2.24, indicating a strong positive relationship.
library(lattice)
reg = lm(price ~ cleaning_fee, data=Airbnb)
coefficients = coef(reg)
print(coefficients)
## (Intercept) cleaning_fee
## 15.481042 2.242585
b0 <- coefficients[1] # Intercept
b1 <- coefficients[2] # Slope
cat("The regression equation is: yhat =", b0, "+", b1, "x\n")
## The regression equation is: yhat = 15.48104 + 2.242585 x
xyplot(price ~ cleaning_fee, data = Airbnb, type = c("p", "r"),
panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.abline(reg, col = "red")
},
main = "Scatterplot with Regression Line: Price vs Cleaning Fee")
Question 11: The intercept, b0, represents the estimated price of an Airbnb listing when the cleaning fee is zero, indicating the baseline price for listings without cleaning charges. The slope, b1, indicates that for each additional dollar in the cleaning fee, the listing price increases by a corresponding amount. This positive slope implies that higher cleaning fees are associated with higher listing prices. These coefficients demonstrate the impact of cleaning fees on the overall pricing of Airbnb listings.
Question 12: A positive correlation coefficient (close to +1) suggests a strong positive association between cleaning_fee and price, which would mean listings with higher cleaning fees tend to have higher prices.
correlation_coefficient <- cor(Airbnb$price, Airbnb$cleaning_fee, use = "complete.obs") # Handling NA values appropriately
print(correlation_coefficient)
## [1] 0.8180702
Question 13: The R² value of 0.669, or 66.9%, indicates that approximately two-thirds of the variability in Airbnb prices can be explained by the cleaning fees alone. This relatively high R² suggests that cleaning fees are a significant predictor of price, making them a useful factor for hosts in setting prices. However, about 33.1% of the price variability remains unexplained by this model, suggesting that other factors also influence pricing and could be incorporated into a more comprehensive model for better accuracy.
reg = lm(price ~ cleaning_fee, data=Airbnb)
model_summary = summary(reg)
print(model_summary$r.squared)
## [1] 0.6692388
Question 14: The p-value of 1.258572e-12 is significantly small, indicating that we reject the null hypothesis that the slope is zero at the 0.05 level of significance. This confirms a statistically significant relationship between the cleaning fee and the price, meaning that changes in the cleaning fee are associated with changes in the pricing of Airbnb listings. This result is essential for hosts when setting pricing strategies.
reg = lm(price ~ cleaning_fee, data=Airbnb)
model_summary = summary(reg)
print(model_summary$coefficients)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 15.481042 21.9768054 0.7044264 4.847185e-01
## cleaning_fee 2.242585 0.2324539 9.6474426 1.258572e-12
Question 15: The R-squared value reveals that cleaning fees significantly predict pricing, making them a valuable factor in pricing decisions. However, incorporating more variables could yield a better understanding and a more detailed model. Adding another variable to the regression model allows you to observe the independent impact of each variable on pricing while controlling for the effects of other factors in the mode.
Question 16:
Reg2 = lm(price ~ guests_included + cleaning_fee , data=Airbnb)
xyplot(price ~ guests_included + cleaning_fee , data = Airbnb, type = c("p", "r"))
summary(Reg2)
##
## Call:
## lm(formula = price ~ guests_included + cleaning_fee, data = Airbnb)
##
## Residuals:
## Min 1Q Median 3Q Max
## -219.65 -38.59 -1.37 28.37 402.69
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.3559 24.9597 0.215 0.831
## guests_included 9.0296 10.4509 0.864 0.392
## cleaning_fee 2.0353 0.3345 6.084 2.34e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 114.2 on 45 degrees of freedom
## (2 observations deleted due to missingness)
## Multiple R-squared: 0.6746, Adjusted R-squared: 0.6602
## F-statistic: 46.65 on 2 and 45 DF, p-value: 1.067e-11
Question 17: The two-variable model, including both cleaning_fee and guests_included, shows a higher Adjusted R-Squared than the one-variable model, indicating a better fit and more accurate pricing predictions.
Question 18:In analyzing the Airbnb Asheville data, the regression models provided good understanding of the factors that affect pricing. The initial analysis focused on price as influenced by cleaning_fee, revealing a strong positive relationship indicated by both high R-squared values and statistically significant p-values, indicating that listings with higher cleaning fees tend to charge more. However, the data also exhibited right-skewness, especially in the distribution of price, which could potentially violate the assumptions of normality required for optimal regression analysis. The incorporation of a second variable, guests_included, in a multiple regression model aimed to enhance the predictive accuracy. While this model improved the Adjusted R-squared value, indicating a better fit, the significance of the guests_included variable was minimal. This suggests that while cleaning_fee strongly predicts price adjustments, the effect of the number of guests included is less pronounced. Given the observed skewness in price, applying a transformation such as a logarithmic transformation might have been beneficial to stabilize variance and normalize the distribution. Such a transformation could lead to more reliable statistical inferences, reducing the impact of outliers and utilizing the linear modeling framework more effectively.