Com base em duas variáveis contínuas:
o banco de dados utilizado foi o ‘mtcars’
car1<- ggplot(mtcars) +
geom_point(aes(x = cyl, y = wt,color= carb),shape = 11,size=3)
ggplotly(car1)
cars2<- mtcars %>%
select(wt, cyl)
M<-cor(cars2)
cor(cars2)
## wt cyl
## wt 1.0000000 0.7824958
## cyl 0.7824958 1.0000000
corrplot(M, method="circle")
Modelo <- lm(wt ~ cyl, data = cars2)
summary(Modelo)
##
## Call:
## lm(formula = wt ~ cyl, data = cars2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.8243 -0.4293 -0.1518 0.3031 1.4297
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.56462 0.40062 1.409 0.169
## cyl 0.42871 0.06228 6.883 1.22e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6193 on 30 degrees of freedom
## Multiple R-squared: 0.6123, Adjusted R-squared: 0.5994
## F-statistic: 47.38 on 1 and 30 DF, p-value: 1.218e-07
car4<- ggplot(mtcars) +
geom_point(aes(x = cyl, y = wt,color= carb),shape = 11,size=3)+
geom_smooth(aes(y=wt,x=cyl))
ggplotly(car4)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : pseudoinverse used at 3.98
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : neighborhood radius 4.02
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : reciprocal condition number 2.0055e-016
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : There are other near singularities as well. 16.16
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
## 3.98
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius 4.02
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
## number 2.0055e-016
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : There are other near
## singularities as well. 16.16
hist(residuals(Modelo))
par(mfrow = c(2, 2))
plot(Modelo)
# Créditos Material criado por ADRIANA GAÍVA.