micresh / data-analytics-2019-KubSTU

0 stars 2 forks source link

LR-2 #55

Open micresh opened 4 years ago

micresh commented 4 years ago

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

AndreySIS 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("C:/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)