data= read.csv("C:\\Users\\69412\\Desktop\\Housing_prices.csv")
head(data)
## ID river rooms price age industry ptratio low_ses
## 1 1 No 6-room 21.6 78.9 7.07 17.8 9.14
## 2 2 No 7-room 34.7 61.1 7.07 17.8 4.03
## 3 3 No 7-room 33.4 45.8 2.18 18.7 2.94
## 4 4 No 7-room 36.2 54.2 2.18 18.7 5.33
## 5 5 No 6-room 28.7 58.7 2.18 18.7 5.21
## 6 6 No 6-room 20.4 61.8 8.14 21.0 8.26
####Present the study design, null and alternative hypotheses (5%) Study Design: The study is designed to analyze the relationship between the number of rooms in a house and the house’s price within a given dataset. This will be done through descriptive statistics, visualization, and inferential statistics. Null Hypothesis (H0): There is no significant difference in housing prices among houses with different numbers of rooms. Alternative Hypothesis (H1): There is a significant difference in housing prices among houses with different numbers of rooms. #### Describe the characteristics of the study sample by the number of rooms/house (10%)
dim(data)
## [1] 372 8
summary(data$rooms)
## Length Class Mode
## 372 character character
hist(data$price, main = "Distribution of House Prices", xlab = "price", breaks = 30, col = "green")
#### Develop and interpret a box plot to describe the differences in
housing prices among the number of rooms per household (10%) can use
ggplot2
boxplot(data$price ~ data$rooms, main = "Housing Prices by Number of Rooms", xlab = "Number of Rooms", ylab = "Price", col = "lightblue")
##### Conduct a statistical test to determine whether housing prices
were different among houses with different numbers of rooms. Interpret
the findings (15%)
anova_test= aov(price ~ rooms, data = data)
summary(anova_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## rooms 3 7162 2387.2 43.49 <2e-16 ***
## Residuals 368 20202 54.9
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey_result = TukeyHSD(anova_test)
tukey_result
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = price ~ rooms, data = data)
##
## $rooms
## diff lwr upr p adj
## 5-room-4-room -3.215556 -9.373321 2.942210 0.5331459
## 6-room-4-room 1.603780 -3.477109 6.684668 0.8475492
## 7-room-4-room 11.511053 6.108559 16.913546 0.0000004
## 6-room-5-room 4.819335 0.948716 8.689954 0.0077590
## 7-room-5-room 14.726608 10.442544 19.010672 0.0000000
## 7-room-6-room 9.907273 7.407162 12.407384 0.0000000