EDA-3

1、两个变量之间存在关系,可以先提出下面的问题:关系是偶然的吗?如何描述?关系强弱?受其他变量的影响吗?查看子群,变量之间的关系会变化吗?

2、

library(modelr)

mod <- lm(log(price)~log(carat),data=diamonds)

view(dfSummary(diamonds))


diamonds3 <- diamonds %>%

  add_residuals(mod) %>%

  mutate(resid=exp(resid))


ggplot(data=diamonds3)+

  geom_point(mapping=aes(x=carat,y=resid))


ggplot(data=diamonds3)+

  geom_boxplot(mapping=aes(x=cut,y=resid))+

  coord_cartesian(ylim=c(0,2))

#观察残差有什么用?

你可能感兴趣的:(EDA-3)