Merge branch 'HEAD' of https://git.yaemiku.dev/yaemiku/sad.git
This commit is contained in:
+101
-15
@@ -16,7 +16,16 @@ fig.width = 8
|
||||
fig.height = 5
|
||||
```
|
||||
|
||||
### Data Fields
|
||||
# Import data
|
||||
|
||||
The dataset contains apartment sales and rent offers from the 15 largest cities in Poland (Warsaw, Lodz, Krakow, Wroclaw, Poznan, Gdansk, Szczecin, Bydgoszcz, Lublin, Katowice, Bialystok, Czestochowa). The data comes from local websites with apartments for sale. To fully capture the neighborhood of each apartment better, each offer was extended by data from the Open Street Map with distances to points of interest (POI). The data is collected monthly and covers a timespan between August 2023 and June 2024
|
||||
|
||||
## Files
|
||||
|
||||
- apartments_pl_YYYY_MM.csv: sale price
|
||||
- apartments_rent_pl_YYYY_MM.csv: monthly rent
|
||||
|
||||
## Data Fields
|
||||
1. ```city``` - the name of the city where the property is located
|
||||
1. ```type``` - type of the building
|
||||
1. ```squareMeters``` - the size of the apartment in square meters
|
||||
@@ -31,8 +40,7 @@ fig.height = 5
|
||||
1. ```condition``` - the condition of the apartment
|
||||
1. ```has[features]``` - whether the property has key features such as assigned parking space, balcony, elevator, security, storage room
|
||||
1. ```price``` - offer price in Polish Zloty
|
||||
apartments_pl_YYYY_MM.csv: sale price
|
||||
apartments_rent_pl_YYYY_MM.csv: monthly rent
|
||||
|
||||
|
||||
|
||||
```{r import data}
|
||||
@@ -47,12 +55,19 @@ df_list <- lapply(seq_along(files), function(i) {
|
||||
|
||||
rent <- do.call(rbind, df_list)
|
||||
|
||||
# price/m^2
|
||||
rent$price_m2 <- rent$price / rent$squareMeters
|
||||
|
||||
has_cols <- grep("^has", names(rent), value = TRUE)
|
||||
|
||||
rent[has_cols] <- lapply(rent[has_cols], function(x) {
|
||||
tolower(x) == "yes"
|
||||
})
|
||||
|
||||
rent$poi_group <- cut(rent$poiCount,
|
||||
breaks = c(-1, 2, 5, 10, Inf),
|
||||
labels = c("0–2", "3–5", "6–10", "11+"))
|
||||
|
||||
rent_norm <- rent %>%
|
||||
group_by(city) %>%
|
||||
mutate(
|
||||
@@ -62,29 +77,100 @@ rent_norm <- rent %>%
|
||||
) %>%
|
||||
mutate() %>%
|
||||
ungroup()
|
||||
|
||||
rent_wo_outliers <- rent %>%
|
||||
group_by(city) %>%
|
||||
filter(log(price_m2) > 3) %>%
|
||||
ungroup()
|
||||
|
||||
cities <- unique(rent$city)
|
||||
```
|
||||
|
||||
# Ceny, heatmapy
|
||||
# Wykresy
|
||||
|
||||
```{r heatmaps}
|
||||
ggplot(rent) + geom_point(aes(x=city, y=price, col=centreDistance), alpha=0.1, size=0.5) + scale_color_viridis_c()
|
||||
ggplot(rent, aes(x = city, y = price_m2)) +
|
||||
geom_violin(fill = "lightgray", alpha = 0.3) +
|
||||
geom_boxplot(width = 0.1, outlier.alpha = 0.01) +
|
||||
stat_summary(fun = mean,
|
||||
geom = "point",
|
||||
shape = 21,
|
||||
size = 0.1,
|
||||
fill = "red") +
|
||||
theme_minimal() +
|
||||
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
|
||||
labs(title = "Rozkład ceny za m² w miastach",
|
||||
x = "Miasto",
|
||||
y = "Cena za m² (PLN)")
|
||||
|
||||
ggplot(rent_norm) + geom_point(aes(x=longitude_n, y=latitude_n, col=log(price)), alpha=0.01, size=0.2) + facet_wrap(~ city) + scale_color_viridis_c()
|
||||
ggplot(rent, aes(x=centreDistance, y=price_m2, col = buildYear)) +
|
||||
geom_point(, alpha=0.1, size=0.5) +
|
||||
geom_smooth(method = "lm", se = TRUE, color = "red") +
|
||||
facet_wrap(~ city) +
|
||||
theme_minimal() +
|
||||
labs(
|
||||
title = "Cena za m² vs odległość od centrum",
|
||||
x = "Odległość od centrum (km)",
|
||||
y = "Cena za m² (PLN)")
|
||||
|
||||
ggplot(rent_norm, aes(x=longitude_n, y=latitude_n, col=price_m2)) +
|
||||
geom_point(alpha=0.01, size=0.2) +
|
||||
facet_wrap(~ city) +
|
||||
scale_color_viridis_c() +
|
||||
theme_minimal()
|
||||
|
||||
ggplot(rent[rent$city=="warszawa", ], aes(x=longitude, y=latitude, col=log(price))) +
|
||||
geom_point(alpha=0.1, size=0.2) +
|
||||
scale_color_viridis_c() +
|
||||
theme_minimal()
|
||||
|
||||
ggplot(rent[rent$city=="warszawa", ], aes(x=longitude, y=latitude, col=price_m2)) +
|
||||
geom_point(alpha=0.1, size=0.2) +
|
||||
scale_color_viridis_c() +
|
||||
theme_minimal()
|
||||
|
||||
ggplot(rent, aes(x = poi_group, y = price_m2)) +
|
||||
geom_boxplot(fill = "lightgray") +
|
||||
stat_summary(fun = mean, geom = "point", shape = 21, size = 3, fill = "red") +
|
||||
theme_minimal() +
|
||||
labs(
|
||||
title = "Cena za m² w zależności od dostępności POI",
|
||||
x = "POI (grupy)",
|
||||
y = "Cena za m² (PLN)"
|
||||
)
|
||||
|
||||
ggplot(rent[rent$city=="warszawa", ]) + geom_point(aes(x=longitude, y=latitude, col=log(price)), alpha=0.1, size=0.1) + scale_color_viridis_c()
|
||||
```
|
||||
|
||||
# Czy ceny normalne?
|
||||
|
||||
```{r isnormal}
|
||||
prices_overall <- rent$price
|
||||
```{r lillieford}
|
||||
log_rent <- log(rent$price_m2)
|
||||
summary(log_rent)
|
||||
prices_overall <- log_rent
|
||||
lillie.test(prices_overall)
|
||||
prices_warsaw <- rent[rent$city=="bialystok", ]$price
|
||||
lillie.test(prices_warsaw)
|
||||
prices_without_warsaw <- rent[rent$city!="warszawa", ]$price
|
||||
lillie.test(prices_without_warsaw)
|
||||
|
||||
df_plot <- data.frame(log_price = log_rent)
|
||||
ggplot(df_plot, aes(x = log_price)) +
|
||||
geom_histogram(aes(y = after_stat(density)),
|
||||
bins = 50,
|
||||
fill = "lightblue",
|
||||
color = "white")
|
||||
|
||||
results <- rent %>%
|
||||
group_by(city) %>%
|
||||
summarise(p_value = lillie.test(log(price_m2))$p.value, mean = mean(price_m2), var = var(price_m2))
|
||||
|
||||
show(results)
|
||||
|
||||
qqnorm(log_rent)
|
||||
qqline(log_rent, col = "red")
|
||||
|
||||
qqnorm(log(rent_wo_outliers$price_m2))
|
||||
qqline(log(rent_wo_outliers$price_m2), col = "red")
|
||||
```
|
||||
|
||||
```{r dyst empi}
|
||||
x<-ecdf
|
||||
# Wiek vs Cena
|
||||
|
||||
```{r buildYear}
|
||||
ggplot(rent) + geom_jitter(aes(x=buildYear, y=price, col=centreDistance), alpha=0.2, size=0.01) + scale_color_viridis_c()
|
||||
```
|
||||
Reference in New Issue
Block a user