Zum Hauptinhalt springen

306  saratoga-cor2

Schlüsselwörter

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

Importieren Sie den Datensatz saratoga.

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

Hinweise:

306.0.1 Setup

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

306.0.2 Gruppieren

d2 <-
  SaratogaHouses |> 
  group_by(bedrooms)

306.0.3 Statistiken

d2 |> 
  summarise(korrelation = cor(livingArea, price))
## # A tibble: 7 × 2
##   bedrooms korrelation
##      <int>       <dbl>
## 1        1       0.115
## 2        2       0.510
## 3        3       0.636
## 4        4       0.687
## 5        5       0.721
## 6        6       0.882
## 7        7       0.791

306.0.4 Visualisierung

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

Aufgabenname: saratoga-cor2