setwd("~/Dropbox/R Stat")
Análise de regressão simples
# Abrir banco de dados
load("senna.RData")
# Análise da correlação simples entre Notas e Auto gestão
fit <- lm( m_notas~F1.Cons, data=sennav1)
summary(fit)
Call:
lm(formula = m_notas ~ F1.Cons, data = sennav1)
Residuals:
Min 1Q Median 3Q Max
-2.6174 -0.6358 0.0137 0.6415 3.4231
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.9825 0.5480 9.092 4.49e-13 ***
F1.Cons 0.6682 0.1519 4.400 4.27e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.044 on 63 degrees of freedom
(1 observation deleted due to missingness)
Multiple R-squared: 0.235, Adjusted R-squared: 0.2229
F-statistic: 19.36 on 1 and 63 DF, p-value: 4.267e-05
library(sjPlot)
sjt.lm(fit, show.std = TRUE)
sjt.lm(fit, show.std = TRUE)$knitr
Análise de regressão simples padronizando o preditor X, depois Y
library(psych)
describe(sennav1[ , c("m_notas", "F1.Cons")])
vars n mean sd median trimmed mad min max range skew kurtosis se
m_notas 1 65 7.33 1.18 7.33 7.33 1.27 4.67 9.88 5.21 0.00 -0.66 0.15
F1.Cons 2 66 3.50 0.85 3.36 3.51 0.86 1.22 5.00 3.78 -0.17 -0.27 0.11
# Cria novas variáveis mudando a métrica original para para M=0 e DP=1 (escore z)
sennav1$m_notasz <- scale(sennav1$m_notas)
sennav1$F1.Consz <- scale(sennav1$F1.Cons)
describe(sennav1[ , c("m_notasz", "F1.Consz")])
vars n mean sd median trimmed mad min max range skew kurtosis se
m_notasz 1 65 0 1 0.01 0.00 1.07 -2.24 2.15 4.40 0.00 -0.66 0.12
F1.Consz 2 66 0 1 -0.16 0.02 1.01 -2.67 1.76 4.43 -0.17 -0.27 0.12
plot(sennav1$F1.Consz, sennav1$F1.Cons)
# Regressão com a X padronizado.
fit2 <- lm( m_notas ~ F1.Consz , data=sennav1)
sjt.lm(fit2, show.std = TRUE)
summary(fit2)
Call:
lm(formula = m_notas ~ F1.Consz, data = sennav1)
Residuals:
Min 1Q Median 3Q Max
-2.6174 -0.6358 0.0137 0.6415 3.4231
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.3218 0.1295 56.54 < 2e-16 ***
F1.Consz 0.5704 0.1297 4.40 4.27e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.044 on 63 degrees of freedom
(1 observation deleted due to missingness)
Multiple R-squared: 0.235, Adjusted R-squared: 0.2229
F-statistic: 19.36 on 1 and 63 DF, p-value: 4.267e-05
# Regressão com a X e Y padronizado. Note os parâmetros B e Std B
fit3 <- lm( m_notasz ~ F1.Consz , data=sennav1)
sjt.lm(fit3, show.std = TRUE)
summary(fit3)
Call:
lm(formula = m_notasz ~ F1.Consz, data = sennav1)
Residuals:
Min 1Q Median 3Q Max
-2.20991 -0.53682 0.01157 0.54162 2.89017
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.002901 0.109343 -0.027 0.979
F1.Consz 0.481638 0.109472 4.400 4.27e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.8815 on 63 degrees of freedom
(1 observation deleted due to missingness)
Multiple R-squared: 0.235, Adjusted R-squared: 0.2229
F-statistic: 19.36 on 1 and 63 DF, p-value: 4.267e-05
|
|
m_notas
|
|
|
B
|
CI
|
std. Beta
|
CI
|
p
|
(Intercept)
|
|
7.32
|
7.06 – 7.58
|
|
|
<.001
|
F1.Consz
|
|
0.57
|
0.31 – 0.83
|
0.48
|
0.27 – 0.70
|
<.001
|
Observations
|
|
65
|
R2 / adj. R2
|
|
.235 / .223
|
|
|
|
|
|
B
|
CI
|
std. Beta
|
CI
|
p
|
(Intercept)
|
|
-0.00
|
-0.22 – 0.22
|
|
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