micresh / data-analytics-2019-KubSTU

0 stars 2 forks source link

LR-2 #34

Open micresh opened 4 years ago

micresh commented 4 years ago

https://github.com/micresh/data-analytics-2019-KubSTU/tree/master/lr2

Litaninek commented 4 years ago

install.packages(c("psych","dplyr","ggplot2","sjPlot")) library("psych")#

library("psych")# library("lmtest")# library("ggplot2")# library("dplyr")# library("MASS")#

train <- read.csv("D:/lr1/train.csv", header = TRUE, sep = ",") d<-train qplot(data=d,Age,Fare)

Задание №2

ggplot ()+geom_point(aes(x=d$Age,y=d$Fare),size=2) + theme_bw(base_size = 18) + xlab("Возраст") + ylab("Fare") + labs(title = "Корреляционное поле")

Задание №3

model <- lm(data = d,Fare~Age) model$coefficients

уравнение регрессии: dist(m,i) = 24.3 + 0.35*Age

Задание №4

model$residuals[1:10] options(digits=3) summary(model) qplot(data = d,Age,Fare) + stat_smooth(method="lm", level = 0.95) + theme_bw(base_size = 18) confint(model,level = 0.95)

Уравнение регрессии получилось значимым.

Задание №5

data.frame nd<-data.frame(Age=c(40,60)) predict(model,nd)

Задание №6

t<-swiss panel.smooth: pairs(swiss,panel = panel.smooth) library("sjPlot") sjp.corr(t) library("GGally") ggpairs(t)

model2 <- lm(data=t,Fertility~Agriculture+Education+Catholic) summary(model2)

Задание №7

nd2 <- data.frame(Agriculture=0.5,Catholic=0.5,Education=20) predict(model2,nd2)