baboj
This commit is contained in:
+37
@@ -214,3 +214,40 @@ summary(model_apartments)
|
|||||||
par(mfrow = c(2,2))
|
par(mfrow = c(2,2))
|
||||||
plot(model_apartments)
|
plot(model_apartments)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#porównanie dystrybuanty empirycznej z teoretyczną
|
||||||
|
```{r dyst empi vs dyst teor}
|
||||||
|
install.packages("ggplot2")
|
||||||
|
library(ggplot2)
|
||||||
|
x<-log(rent$price_m2)
|
||||||
|
z <- seq(min(x), max(x), length.out = 20000)
|
||||||
|
dystrybuanta_empiryczna<-ecdf(x)
|
||||||
|
dystrybuanta_teoretyczna<-pnorm(z, mean=mean(x), sd=sd(x))
|
||||||
|
ggplot() +
|
||||||
|
# Dystrybuanta empiryczna
|
||||||
|
geom_step(
|
||||||
|
aes(x = z, y = dystrybuanta_empiryczna(z), color = "Empiryczna"),
|
||||||
|
linewidth = 1,
|
||||||
|
linetype = "solid"
|
||||||
|
) +
|
||||||
|
# Dystrybuanta teoretyczna
|
||||||
|
geom_line(
|
||||||
|
aes(x = z, y = dystrybuanta_teoretyczna, color = "Teoretyczna"),
|
||||||
|
linewidth = 1,
|
||||||
|
linetype = "dashed"
|
||||||
|
) +
|
||||||
|
# Dodanie legendy i dostosowanie kolorów
|
||||||
|
scale_color_manual(
|
||||||
|
values = c("Empiryczna" = "blue", "Teoretyczna" = "red"),
|
||||||
|
labels = c("Empiryczna", "Teoretyczna")
|
||||||
|
) +
|
||||||
|
# Etykiety i tytuł
|
||||||
|
labs(
|
||||||
|
title = "Porównanie dystrybuanty empirycznej i teoretycznej",
|
||||||
|
x = "Wartość",
|
||||||
|
y = "Prawdopodobieństwo skumulowane",
|
||||||
|
color = "Typ dystrybuanty" # Tytuł legendy
|
||||||
|
) +
|
||||||
|
theme_minimal() +
|
||||||
|
theme(plot.title = element_text(hjust = 0.5))
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user