Esse relatório mostra a relação dos salarios dos gerentes em comparação com os anos de experiencia. Utilizando análise de regressão univariada.
## # A tibble: 27 x 2
## Salario Experiencia
## <dbl> <dbl>
## 1 1931. 0
## 2 3177. 17
## 3 2277. 8
## 4 3131. 15
## 5 2777. 9
## 6 3092. 15
## 7 2654. 8
## 8 2223 5
## 9 2854. 13
## 10 3231. 20
## # ... with 17 more rows
## Salario Experiencia
## Min. :1908 Min. : 0.00
## 1st Qu.:2612 1st Qu.: 8.00
## Median :3092 Median :13.00
## Mean :3228 Mean :14.11
## 3rd Qu.:4092 3rd Qu.:21.00
## Max. :4746 Max. :29.00
## [1] 736696.8
## [1] 858.3104
## [1] 0.9704137
Testando a Correlação
##
## Pearson's product-moment correlation
##
## data: gerentes$Experiencia and gerentes$Salario
## t = 20.096, df = 25, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.9353175 0.9865989
## sample estimates:
## cor
## 0.9704137
Verificando se o X responde Y
O valor deve estar entre o intervalo 95
##
## Pearson's product-moment correlation
##
## data: gerentes$Experiencia and gerentes$Salario
## t = 20.096, df = 25, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.9353175 0.9865989
## sample estimates:
## cor
## 0.9704137
Verificando o p-valeu
##
## Welch Two Sample t-test
##
## data: gerentes$Experiencia and gerentes$Salario
## t = -19.457, df = 26.005, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -3553.593 -2874.495
## sample estimates:
## mean of x mean of y
## 14.11111 3228.15556
OBS normalidade é para ver se a maioria dos dados estão perto da média
Modelo de regressão o Y sempre vem no lugar do X
Summary do Ajuste
##
## Call:
## lm(formula = gerentes$Salario ~ gerentes$Experiencia)
##
## Residuals:
## Min 1Q Median 3Q Max
## -590.82 -89.40 57.55 155.71 270.78
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1806.330 81.610 22.13 <2e-16 ***
## gerentes$Experiencia 100.759 5.014 20.10 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 211.3 on 25 degrees of freedom
## Multiple R-squared: 0.9417, Adjusted R-squared: 0.9394
## F-statistic: 403.8 on 1 and 25 DF, p-value: < 2.2e-16
Tirando o Intercept
Não remover pode gerar residuo na sua analise, e alterar o resultado
##
## Call:
## lm(formula = gerentes$Salario ~ gerentes$Experiencia - 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -966.1 -274.2 293.2 1106.4 1930.7
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## gerentes$Experiencia 196.97 11.12 17.71 4.96e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 940.5 on 26 degrees of freedom
## Multiple R-squared: 0.9235, Adjusted R-squared: 0.9205
## F-statistic: 313.7 on 1 and 26 DF, p-value: 4.965e-16
Ajustando o coeficiante
## (Intercept) gerentes$Experiencia
## 1806.3303 100.7593
## 1 2 3 4 5 6 7 8
## 1806.330 3519.238 2612.404 3317.719 2713.164 3317.719 2612.404 2310.127
## 9 10 11 12 13 14 15 16
## 3116.201 3821.516 2914.682 1907.090 2410.886 2511.645 4123.793 3821.516
## 17 18 19 20 21 22 23 24
## 3619.997 4526.831 2914.682 2813.923 4728.349 4123.793 2209.367 4023.034
## 25 26 27
## 4325.312 2713.164 4325.312
Visualização do ajuste
Como podemos observar, existe uma correlação entre os salários dos gerentes e os anos de experiencia. Nessa análise, foquei em mostrar como é feita uma regressão univariada.