can you hear the music
This commit is contained in:
+211
-72
@@ -8,7 +8,7 @@ output:
|
|||||||
---
|
---
|
||||||
|
|
||||||
```{r setup, include=FALSE}
|
```{r setup, include=FALSE}
|
||||||
knitr::opts_chunk$set(echo = TRUE)
|
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
|
||||||
library(ggplot2)
|
library(ggplot2)
|
||||||
library(patchwork)
|
library(patchwork)
|
||||||
library(dplyr)
|
library(dplyr)
|
||||||
@@ -18,6 +18,8 @@ library(tidyr)
|
|||||||
library(purrr)
|
library(purrr)
|
||||||
library(broom)
|
library(broom)
|
||||||
library(tibble)
|
library(tibble)
|
||||||
|
library(binom)
|
||||||
|
library(reshape2)
|
||||||
fig.width = 10
|
fig.width = 10
|
||||||
fig.height = 10
|
fig.height = 10
|
||||||
```
|
```
|
||||||
@@ -46,6 +48,8 @@ Dane są zbierane miesięcznie i obejmują okres od sierpnia 2023 roku do czerwc
|
|||||||
|
|
||||||
|
|
||||||
```{r import data}
|
```{r import data}
|
||||||
|
|
||||||
|
# Wczytujemy pliki
|
||||||
files_rent <- list.files("rent", pattern = "\\.csv$", full.names = TRUE)
|
files_rent <- list.files("rent", pattern = "\\.csv$", full.names = TRUE)
|
||||||
files_apartments <- list.files("apartments", pattern = "\\.csv$", full.names = TRUE)
|
files_apartments <- list.files("apartments", pattern = "\\.csv$", full.names = TRUE)
|
||||||
files_rent <- sort(files_rent)
|
files_rent <- sort(files_rent)
|
||||||
@@ -67,10 +71,10 @@ apartments_list <- lapply(seq_along(files_apartments), function(i) {
|
|||||||
|
|
||||||
df <- do.call(rbind, c(rent_list, apartments_list))
|
df <- do.call(rbind, c(rent_list, apartments_list))
|
||||||
|
|
||||||
# price/m^2
|
# Dodatkowe parametry
|
||||||
df$price_m2 <- df$price / df$squareMeters
|
df$price_m2 <- df$price / df$squareMeters
|
||||||
df$log_price <- log(df$price)
|
df$log_price <- log10(df$price)
|
||||||
df$log_price_m2 <- log(df$price_m2)
|
df$log_price_m2 <- log10(df$price_m2)
|
||||||
df$floor_ratio <- df$floor / df$floorCount
|
df$floor_ratio <- df$floor / df$floorCount
|
||||||
df$age <- 2024 - df$buildYear
|
df$age <- 2024 - df$buildYear
|
||||||
|
|
||||||
@@ -78,6 +82,8 @@ df$city <- as.factor(df$city)
|
|||||||
df$offer_type <- as.factor(df$offer_type)
|
df$offer_type <- as.factor(df$offer_type)
|
||||||
df$month_id <- as.factor(df$month_id)
|
df$month_id <- as.factor(df$month_id)
|
||||||
|
|
||||||
|
df$month_num <- as.numeric(as.character(df$month_id))
|
||||||
|
|
||||||
has_cols <- grep("^has", names(df), value = TRUE)
|
has_cols <- grep("^has", names(df), value = TRUE)
|
||||||
|
|
||||||
df[has_cols] <- lapply(df[has_cols], function(x) {
|
df[has_cols] <- lapply(df[has_cols], function(x) {
|
||||||
@@ -100,10 +106,17 @@ df <- df %>%
|
|||||||
) %>%
|
) %>%
|
||||||
ungroup()
|
ungroup()
|
||||||
|
|
||||||
|
# Podzbiory danych
|
||||||
rent <- df[df$offer_type == "rent",]
|
rent <- df[df$offer_type == "rent",]
|
||||||
rent_warsaw <- rent[rent$city == "warszawa",]
|
rent_warsaw <- rent[rent$city == "warszawa",]
|
||||||
apartments <- df[df$offer_type == "apartment",]
|
apartments <- df[df$offer_type == "apartment",]
|
||||||
apartments_warsaw <- apartments[apartments$city == "warszawa",]
|
apartments_warsaw <- apartments[apartments$city == "warszawa",]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Wstępna analiza
|
||||||
|
|
||||||
|
```{r first overview}
|
||||||
|
summary(df)
|
||||||
|
|
||||||
df_city <- df %>%
|
df_city <- df %>%
|
||||||
count(city) %>%
|
count(city) %>%
|
||||||
@@ -116,12 +129,16 @@ rent_city <- rent %>%
|
|||||||
group_by(city) %>%
|
group_by(city) %>%
|
||||||
summarise(mean_price_m2 = mean(price_m2, na.rm = TRUE))
|
summarise(mean_price_m2 = mean(price_m2, na.rm = TRUE))
|
||||||
|
|
||||||
|
apartments_city <- apartments %>%
|
||||||
|
group_by(city) %>%
|
||||||
|
summarise(mean_price_m2 = mean(price_m2, na.rm = TRUE))
|
||||||
|
|
||||||
ggplot(df_city, aes(x = reorder(city, -perc), y = perc)) +
|
ggplot(df_city, aes(x = reorder(city, -perc), y = perc)) +
|
||||||
geom_col(fill = "steelblue") +
|
geom_col(fill = "steelblue") +
|
||||||
geom_text(aes(label = paste0(round(perc, 1), "%")),
|
geom_text(aes(label = paste0(round(perc, 1), "%")),
|
||||||
vjust = -0.3, size = 3) +
|
vjust = -0.3, size = 3) +
|
||||||
labs(
|
labs(
|
||||||
title = "Procent mieszkań według miasta",
|
title = "Procent ofert według miasta",
|
||||||
x = "Miasto",
|
x = "Miasto",
|
||||||
y = "Procent"
|
y = "Procent"
|
||||||
) +
|
) +
|
||||||
@@ -130,18 +147,44 @@ ggplot(df_city, aes(x = reorder(city, -perc), y = perc)) +
|
|||||||
|
|
||||||
ggplot(rent_city, aes(x = reorder(city, mean_price_m2),
|
ggplot(rent_city, aes(x = reorder(city, mean_price_m2),
|
||||||
y = mean_price_m2)) +
|
y = mean_price_m2)) +
|
||||||
geom_col(fill = "steelblue") +
|
geom_col(fill = "green") +
|
||||||
coord_flip() +
|
coord_flip() +
|
||||||
labs(
|
labs(
|
||||||
title = "Średnia cena m² wg miasta",
|
title = "Średnia cena/m² wg miasta (wynajem)",
|
||||||
x = "Miasto",
|
x = "Miasto",
|
||||||
y = "Średnia cena m²"
|
y = "Średnia cena/m²"
|
||||||
|
) +
|
||||||
|
theme_minimal()
|
||||||
|
|
||||||
|
ggplot(apartments_city, aes(x = reorder(city, mean_price_m2),
|
||||||
|
y = mean_price_m2)) +
|
||||||
|
geom_col(fill = "purple") +
|
||||||
|
coord_flip() +
|
||||||
|
labs(
|
||||||
|
title = "Średnia cena/m² wg miasta (kupno)",
|
||||||
|
x = "Miasto",
|
||||||
|
y = "Średnia cena/m²"
|
||||||
) +
|
) +
|
||||||
theme_minimal()
|
theme_minimal()
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# Wykresy
|
```{r czy miasta się różnią}
|
||||||
|
kruskal.test(price_m2 ~ city, data = rent)
|
||||||
|
|
||||||
|
kruskal.test(price_m2 ~ city, data = apartments)
|
||||||
|
```
|
||||||
|
|
||||||
|
```{r udział balkonów}
|
||||||
|
x <- sum(df$hasBalcony, na.rm = TRUE)
|
||||||
|
n <- sum(!is.na(df$hasBalcony))
|
||||||
|
|
||||||
|
binom.confint(x, n, methods = "wilson")
|
||||||
|
```
|
||||||
|
|
||||||
|
# Analiza cen
|
||||||
|
|
||||||
|
## Ceny/m^2 w miastach
|
||||||
|
|
||||||
```{r violiny}
|
```{r violiny}
|
||||||
ggplot(rent, aes(x = city, y = price_m2)) +
|
ggplot(rent, aes(x = city, y = price_m2)) +
|
||||||
@@ -152,6 +195,7 @@ ggplot(rent, aes(x = city, y = price_m2)) +
|
|||||||
labs(title = "Zależność ceny za m² od miasta (wynajem)",
|
labs(title = "Zależność ceny za m² od miasta (wynajem)",
|
||||||
x = "Miasto",
|
x = "Miasto",
|
||||||
y = "Cena za m² (PLN)")
|
y = "Cena za m² (PLN)")
|
||||||
|
|
||||||
ggplot(apartments, aes(x = city, y = price_m2)) +
|
ggplot(apartments, aes(x = city, y = price_m2)) +
|
||||||
geom_violin(fill = "purple", alpha = 0.3) +
|
geom_violin(fill = "purple", alpha = 0.3) +
|
||||||
geom_boxplot(width = 0.1, outlier.alpha = 0.01) +
|
geom_boxplot(width = 0.1, outlier.alpha = 0.01) +
|
||||||
@@ -162,6 +206,8 @@ ggplot(apartments, aes(x = city, y = price_m2)) +
|
|||||||
y = "Cena za m² (PLN)")
|
y = "Cena za m² (PLN)")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Zgodność rozkładów pomiędzy miesiącami
|
||||||
|
|
||||||
```{r zgodność rozkładów na przestrzeni miesięcy (kupno)}
|
```{r zgodność rozkładów na przestrzeni miesięcy (kupno)}
|
||||||
ks_long <- apartments %>%
|
ks_long <- apartments %>%
|
||||||
group_split(city) %>%
|
group_split(city) %>%
|
||||||
@@ -234,7 +280,7 @@ ks_long <- rent %>%
|
|||||||
ggplot(ks_long, aes(m1, m2, fill = ks)) +
|
ggplot(ks_long, aes(m1, m2, fill = ks)) +
|
||||||
geom_tile() +
|
geom_tile() +
|
||||||
facet_wrap(~city) +
|
facet_wrap(~city) +
|
||||||
scale_fill_viridis_c() +
|
scale_fill_viridis_c(option = "plasma") +
|
||||||
theme_minimal() +
|
theme_minimal() +
|
||||||
labs(
|
labs(
|
||||||
title = "Statystyka K-S D pomiędzy miesiącami (wynajem)",
|
title = "Statystyka K-S D pomiędzy miesiącami (wynajem)",
|
||||||
@@ -244,13 +290,16 @@ ggplot(ks_long, aes(m1, m2, fill = ks)) +
|
|||||||
ggplot(ks_long, aes(m1, m2, fill = p >= 0.05)) +
|
ggplot(ks_long, aes(m1, m2, fill = p >= 0.05)) +
|
||||||
geom_tile() +
|
geom_tile() +
|
||||||
facet_wrap(~city) +
|
facet_wrap(~city) +
|
||||||
scale_fill_viridis_c() +
|
scale_fill_viridis_c(option = "plasma") +
|
||||||
theme_minimal() +
|
theme_minimal() +
|
||||||
labs(
|
labs(
|
||||||
title = "Kiedy odrzucamy H_0 (dystrubuanty z tego samego rozkładu)",
|
title = "Kiedy odrzucamy H_0 (dystrubuanty z tego samego rozkładu)",
|
||||||
x = "Miesiąc", y = "Miesiąc", fill = "p >= 0.05"
|
x = "Miesiąc", y = "Miesiąc", fill = "p >= 0.05"
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Cena a dokładna lokalizacja
|
||||||
|
|
||||||
```{r heatmapy}
|
```{r heatmapy}
|
||||||
ggplot(rent, aes(x=longitude_n, y=latitude_n, col=price_m2_n)) +
|
ggplot(rent, aes(x=longitude_n, y=latitude_n, col=price_m2_n)) +
|
||||||
geom_point(alpha=0.03, size=0.4) +
|
geom_point(alpha=0.03, size=0.4) +
|
||||||
@@ -272,6 +321,8 @@ ggplot(apartments, aes(x=longitude_n, y=latitude_n, col=price_m2_n)) +
|
|||||||
y = "wysokość geograficzna")
|
y = "wysokość geograficzna")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Warszawa
|
||||||
|
|
||||||
```{r heatmapy Warszawa}
|
```{r heatmapy Warszawa}
|
||||||
ggplot(rent_warsaw, aes(x=longitude, y=latitude, col=log_price)) +
|
ggplot(rent_warsaw, aes(x=longitude, y=latitude, col=log_price)) +
|
||||||
geom_point(alpha=0.2, size=0.4) +
|
geom_point(alpha=0.2, size=0.4) +
|
||||||
@@ -293,16 +344,18 @@ ggplot(apartments_warsaw, aes(x=longitude, y=latitude, col=log_price)) +
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#Porównanie dystrybuanty empirycznej z dystrybuantą rozkładu normalnego
|
# Czy ceny normalne?
|
||||||
#o nieobciążonych estymatorach
|
|
||||||
|
## Porównanie dystrybuant empirycznych z dystrybuantami estymowanych rozkładów normalnych
|
||||||
|
|
||||||
```{r dystrybuanty}
|
```{r dystrybuanty}
|
||||||
x<-log(rent$price_m2)
|
z <- seq(min(rent$log_price_m2,apartments$log_price_m2), max(rent$log_price_m2,apartments$log_price_m2), length.out = 300000)
|
||||||
t<-log(apartments$price_m2)
|
|
||||||
z <- seq(min(x,t), max(x,t), length.out = 300000)
|
dystrybuanta_empiryczna_wynajem<-ecdf(rent$log_price_m2)
|
||||||
dystrybuanta_empiryczna_wynajem<-ecdf(x)
|
dystrybuanta_empiryczna_kupno<-ecdf(apartments$log_price_m2)
|
||||||
dystrybuanta_empiryczna_kupno<-ecdf(t)
|
dystrybuanta_teoretyczna_wynajem<-pnorm(z, mean=mean(rent$log_price_m2), sd=sd(rent$log_price_m2))
|
||||||
dystrybuanta_teoretyczna_wynajem<-pnorm(z, mean=mean(x), sd=sd(x))
|
dystrybuanta_teoretyczna_kupno<-pnorm(z, mean=mean(apartments$log_price_m2), sd=sd(apartments$log_price_m2))
|
||||||
dystrybuanta_teoretyczna_kupno<-pnorm(z, mean=mean(t), sd=sd(t))
|
|
||||||
ggplot() +
|
ggplot() +
|
||||||
geom_step(
|
geom_step(
|
||||||
aes(x = z, y = dystrybuanta_empiryczna_wynajem(z), color = "Empiryczna wyn"),
|
aes(x = z, y = dystrybuanta_empiryczna_wynajem(z), color = "Empiryczna wyn"),
|
||||||
@@ -336,8 +389,27 @@ ggplot() +
|
|||||||
) +
|
) +
|
||||||
theme_minimal() +
|
theme_minimal() +
|
||||||
theme(plot.title = element_text(hjust = 0.5))
|
theme(plot.title = element_text(hjust = 0.5))
|
||||||
|
|
||||||
|
lillie.test(rent$log_price_m2)
|
||||||
|
lillie.test(apartments$log_price_m2)
|
||||||
|
|
||||||
|
df_plot <- data.frame(log_price_m2 = df$log_price_m2_n)
|
||||||
|
ggplot(df, aes(x = log_price_m2_n)) +
|
||||||
|
geom_histogram(aes(y = after_stat(density)),
|
||||||
|
bins = 50,
|
||||||
|
fill = "lightblue",
|
||||||
|
color = "white") +
|
||||||
|
facet_wrap(~ offer_type)
|
||||||
|
|
||||||
|
qqnorm(rent$log_price_m2_n)
|
||||||
|
qqline(rent$log_price_m2_n, col = "red")
|
||||||
|
|
||||||
|
qqnorm(apartments$log_price_m2_n)
|
||||||
|
qqline(apartments$log_price_m2_n, col = "red")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Regresja
|
||||||
|
|
||||||
```{r prosta regresja ceny od odległości od centrum dla wynajmu}
|
```{r prosta regresja ceny od odległości od centrum dla wynajmu}
|
||||||
|
|
||||||
ggplot(rent, aes(x=centreDistance, y=price_m2)) +
|
ggplot(rent, aes(x=centreDistance, y=price_m2)) +
|
||||||
@@ -365,30 +437,43 @@ ggplot(apartments, aes(x=centreDistance, y=price_m2)) +
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# Czy ceny normalne?
|
## Model liniowy
|
||||||
|
|
||||||
```{r lillieford}
|
```{r model liniowy wynajmu}
|
||||||
lillie.test(rent_warsaw$log_price_m2_n)
|
|
||||||
lillie.test(apartments_warsaw$log_price_m2_n)
|
|
||||||
|
|
||||||
df_plot <- data.frame(log_price_m2 = df$log_price_m2_n)
|
model_rent <- lm(log_price_m2 ~ month_num + centreDistance +
|
||||||
ggplot(df, aes(x = log_price_m2_n)) +
|
squareMeters +
|
||||||
geom_histogram(aes(y = after_stat(density)),
|
age +
|
||||||
bins = 50,
|
floor_ratio +
|
||||||
fill = "lightblue",
|
city +
|
||||||
color = "white") +
|
hasElevator +
|
||||||
facet_wrap(~ offer_type)
|
hasBalcony +
|
||||||
|
hasSecurity +
|
||||||
|
condition,
|
||||||
|
data = rent, na.action = na.exclude)
|
||||||
|
|
||||||
qqnorm(rent$log_price_m2_n)
|
par(mfrow = c(2,2))
|
||||||
qqline(rent$log_price_m2_n, col = "red")
|
plot(model_rent)
|
||||||
|
|
||||||
qqnorm(apartments$log_price_m2_n)
|
summary(model_rent)
|
||||||
qqline(apartments$log_price_m2_n, col = "red")
|
|
||||||
|
numeric_df <- rent %>%
|
||||||
|
select(price_m2, squareMeters, centreDistance, age, hasElevator,
|
||||||
|
hasBalcony,
|
||||||
|
hasSecurity)
|
||||||
|
|
||||||
|
corr <- cor(numeric_df, use = "complete.obs")
|
||||||
|
|
||||||
|
melted <- melt(corr)
|
||||||
|
|
||||||
|
ggplot(melted, aes(Var1, Var2, fill = value)) +
|
||||||
|
geom_tile() +
|
||||||
|
scale_fill_viridis_c() +
|
||||||
|
theme_minimal()
|
||||||
```
|
```
|
||||||
|
|
||||||
# Model liniowy
|
```{r model liniowy kupna}
|
||||||
```{r linear model}
|
model_apartments <- lm(log_price_m2 ~ month_num + centreDistance +
|
||||||
model_rent <- lm(log_price_m2 ~ centreDistance +
|
|
||||||
squareMeters +
|
squareMeters +
|
||||||
age +
|
age +
|
||||||
floor_ratio +
|
floor_ratio +
|
||||||
@@ -397,51 +482,101 @@ model_rent <- lm(log_price_m2 ~ centreDistance +
|
|||||||
hasBalcony +
|
hasBalcony +
|
||||||
hasSecurity +
|
hasSecurity +
|
||||||
condition,
|
condition,
|
||||||
data = rent)
|
data = apartments, na.action = na.exclude)
|
||||||
|
|
||||||
model_buy <- lm(log_price_m2 ~ centreDistance +
|
par(mfrow = c(2,2))
|
||||||
squareMeters +
|
plot(model_rent)
|
||||||
age +
|
|
||||||
floor_ratio +
|
|
||||||
city +
|
|
||||||
hasElevator +
|
|
||||||
hasBalcony +
|
|
||||||
hasSecurity +
|
|
||||||
condition,
|
|
||||||
data = apartments)
|
|
||||||
|
|
||||||
model_compare <- lm(log_price_m2 ~ offer_type *
|
summary(model_apartments)
|
||||||
(centreDistance +
|
|
||||||
squareMeters +
|
|
||||||
age +
|
|
||||||
city +
|
|
||||||
hasElevator +
|
|
||||||
hasBalcony +
|
|
||||||
hasSecurity +
|
|
||||||
condition) + month_id,
|
|
||||||
data = df, na.action = na.exclude)
|
|
||||||
|
|
||||||
df$pred <- predict(model_compare)
|
numeric_df <- apartments %>%
|
||||||
summary(df$pred)
|
select(price_m2, squareMeters, centreDistance, age, hasElevator,
|
||||||
sum(is.na(df$pred))
|
hasBalcony,
|
||||||
|
hasSecurity)
|
||||||
|
|
||||||
plot_data <- df %>%
|
corr <- cor(numeric_df, use = "complete.obs")
|
||||||
filter(!is.na(pred)) %>%
|
|
||||||
group_by(month_id, offer_type) %>%
|
melted <- melt(corr)
|
||||||
summarise(mean_pred = mean(pred), .groups = "drop")
|
|
||||||
|
ggplot(melted, aes(Var1, Var2, fill = value)) +
|
||||||
|
geom_tile() +
|
||||||
|
scale_fill_viridis_c(option = "plasma") +
|
||||||
|
theme_minimal()
|
||||||
|
```
|
||||||
|
|
||||||
|
## Przewidywania rynku najmu/sprzedaży
|
||||||
|
|
||||||
|
```{r predictions}
|
||||||
|
rent_pred <- cbind(
|
||||||
|
rent,
|
||||||
|
predict(model_rent, interval = "confidence") %>%
|
||||||
|
as.data.frame()
|
||||||
|
)
|
||||||
|
|
||||||
|
apartments_pred <- cbind(
|
||||||
|
apartments,
|
||||||
|
predict(model_apartments, interval = "confidence") %>%
|
||||||
|
as.data.frame()
|
||||||
|
)
|
||||||
|
|
||||||
|
rent_plot <- rent_pred %>%
|
||||||
|
group_by(month_num) %>%
|
||||||
|
summarise(
|
||||||
|
fit = mean(fit, na.rm = TRUE),
|
||||||
|
lwr = mean(lwr, na.rm = TRUE),
|
||||||
|
upr = mean(upr, na.rm = TRUE),
|
||||||
|
.groups = "drop"
|
||||||
|
)
|
||||||
|
|
||||||
|
apartments_plot <- apartments_pred %>%
|
||||||
|
group_by(month_num) %>%
|
||||||
|
summarise(
|
||||||
|
fit = mean(fit, na.rm = TRUE),
|
||||||
|
lwr = mean(lwr, na.rm = TRUE),
|
||||||
|
upr = mean(upr, na.rm = TRUE),
|
||||||
|
.groups = "drop"
|
||||||
|
)
|
||||||
|
|
||||||
|
ggplot(rent_plot,
|
||||||
|
aes(x = month_num, y = fit)) +
|
||||||
|
|
||||||
|
geom_line(color = "darkgreen", linewidth = 1.3) +
|
||||||
|
geom_point(color = "darkgreen", size = 2) +
|
||||||
|
|
||||||
|
geom_ribbon(aes(ymin = lwr, ymax = upr),
|
||||||
|
alpha = 0.2,
|
||||||
|
fill = "green") +
|
||||||
|
|
||||||
ggplot(plot_data, aes(x = month_id, y = mean_pred, color = offer_type)) +
|
|
||||||
geom_line(linewidth = 1.2) +
|
|
||||||
geom_point() +
|
|
||||||
theme_minimal() +
|
theme_minimal() +
|
||||||
labs(title = "Predykowane ceny: rent vs apartments",
|
|
||||||
y = "log(price m²)")
|
|
||||||
|
|
||||||
|
labs(
|
||||||
|
title = "Trend przewidywanych cen – wynajem",
|
||||||
|
x = "Miesiąc",
|
||||||
|
y = "log(price/m²)"
|
||||||
|
)
|
||||||
|
|
||||||
|
ggplot(apartments_plot,
|
||||||
|
aes(x = month_num, y = fit)) +
|
||||||
|
|
||||||
|
geom_line(color = "purple", linewidth = 1.3) +
|
||||||
|
geom_point(color = "purple", size = 2) +
|
||||||
|
|
||||||
|
geom_ribbon(aes(ymin = lwr, ymax = upr),
|
||||||
|
alpha = 0.2,
|
||||||
|
fill = "purple") +
|
||||||
|
|
||||||
|
theme_minimal() +
|
||||||
|
|
||||||
|
labs(
|
||||||
|
title = "Trend przewidywanych cen – sprzedaż mieszkań",
|
||||||
|
x = "Miesiąc",
|
||||||
|
y = "log(price/m²)"
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
```{r propozycje od chata}
|
## Porównanie rynków
|
||||||
|
|
||||||
|
```{r dywergencja rynków}
|
||||||
monthly_means <- df %>%
|
monthly_means <- df %>%
|
||||||
group_by(month_id, offer_type) %>%
|
group_by(month_id, offer_type) %>%
|
||||||
summarise(
|
summarise(
|
||||||
@@ -466,4 +601,8 @@ ggplot(wide, aes(x = month_id, y = divergence, group = 1)) +
|
|||||||
y = "Dywergencja (log price m²)"
|
y = "Dywergencja (log price m²)"
|
||||||
) +
|
) +
|
||||||
theme(axis.text.x = element_text(angle = 45, hjust = 1))
|
theme(axis.text.x = element_text(angle = 45, hjust = 1))
|
||||||
|
|
||||||
|
trend_model <- lm(divergence ~ as.numeric(month_id), data = wide)
|
||||||
|
|
||||||
|
summary(trend_model)
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user