Zum Hauptinhalt springen

305  saratoga-cor1

Schlüsselwörter

Aufgaben, Statistik, Prognose, Modellierung, R, Datenanalyse, Regression

Importieren Sie den Datensatz saratoga.

Gruppieren Sie den Datensatz in die Quartile für livingArea.

Berechnen Sie dann den Zusammenhang zwischen price und bedrooms pro Quartil von livingArea.

Hinweise:

305.0.1 Setup

library(tidyverse)
library(ggpubr)
data("SaratogaHouses", package = "mosaicData")

305.0.2 Gruppieren

d2 <-
  SaratogaHouses |> 
  mutate(q = ntile(livingArea, 4)) |> 
  group_by(q)

305.0.3 Statistiken

d2 |> 
  summarise(korrelation = cor(bedrooms, price))
## # A tibble: 4 × 2
##       q korrelation
##   <int>       <dbl>
## 1     1      0.126 
## 2     2      0.0781
## 3     3     -0.143 
## 4     4     -0.0478

305.0.4 Visualisierung

ggscatter(d2, 
          x = "bedrooms",
          y = "price",
          facet.by = "q",
          add = "reg.line")

Aufgabenname: saratoga-cor1