-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTeilC_modell1.R
47 lines (26 loc) · 1.02 KB
/
TeilC_modell1.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
setwd(dirname(rstudioapi::getActiveDocumentContext()$path))
list.files()
RealEstate_California_adapted <- read.csv("RealEstate_California-adapted-new.csv")
names(RealEstate_California_adapted)
attach(RealEstate_California_adapted)
library(tidyr)
newWithoutNull <- RealEstate_California_adapted %>%
mutate_all(~ifelse(. %in% c("N/A", "null", ""), NA, .))
View(newWithoutNull)
summary(newWithoutNull)
nrow(newWithoutNull)
realEstateData <- newWithoutNull[complete.cases(newWithoutNull$price),]
summary(realEstateData)
realEstateData$price <- as.integer(realEstateData$price)
# Datensatz ohne Price welche einen Null wert haben
nrow(realEstateData)
priceEstateModel = lm(price ~ bathrooms + bedrooms, data = realEstateData)
summary(priceEstateModel)
#geteilt durch 10'000 für bessere Lesbarkeit
resids <- priceEstateModel$residuals/10000
price <- realEstateData$price/10000
plot(price ~ realEstateData$bedrooms)
plot(price ~ realEstateData$bathrooms)
plot(resids~price)
mo1 <- lm(resids~price)
abline(mo1, col="red")