18 de noviembre de 2016
sa.lm=lm(Sign.Area~NPI16TOTAL+Sex,data=datosLimpios) summary(sa.lm)
## ## Call: ## lm(formula = Sign.Area ~ NPI16TOTAL + Sex, data = datosLimpios) ## ## Residuals: ## Min 1Q Median 3Q Max ## -16.984 -5.743 -1.614 4.576 25.202 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 24.3982 1.0305 23.676 <2e-16 *** ## NPI16TOTAL 0.2086 0.2001 1.042 0.298 ## SexF -2.0397 0.9472 -2.153 0.032 * ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 8.29 on 321 degrees of freedom ## (6 observations deleted due to missingness) ## Multiple R-squared: 0.02042, Adjusted R-squared: 0.01432 ## F-statistic: 3.346 on 2 and 321 DF, p-value: 0.03647
ggplot(datosLimpios,aes(x=NPI16TOTAL,y=Sign.Area))+ geom_point(aes(col=Sex))+geom_smooth(method="lm",se=F)
ggplot(datosLimpios,aes(x=NPI16TOTAL,y=Sign.Area,col=Sex))+ geom_point()+geom_smooth(method="lm",se=F)
| Nivel sexo | \(x_2x_1\) | \(x_2\) | \(x_1\) | intercepto |
|---|---|---|---|---|
| M | 0 | narcicismo | 0 | si |
| F | narcicismo | narcicismo | 1 | si |
sa.lmi=lm(Sign.Area~NPI16TOTAL*Sex,data=datosLimpios) summary(sa.lmi)
## ## Call: ## lm(formula = Sign.Area ~ NPI16TOTAL * Sex, data = datosLimpios) ## ## Residuals: ## Min 1Q Median 3Q Max ## -17.954 -5.892 -1.577 4.846 24.631 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 26.4911 1.2826 20.654 < 2e-16 *** ## NPI16TOTAL -0.3528 0.2876 -1.227 0.220789 ## SexF -5.6133 1.6247 -3.455 0.000624 *** ## NPI16TOTAL:SexF 1.0694 0.3969 2.694 0.007428 ** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 8.21 on 320 degrees of freedom ## (6 observations deleted due to missingness) ## Multiple R-squared: 0.04215, Adjusted R-squared: 0.03317 ## F-statistic: 4.693 on 3 and 320 DF, p-value: 0.003189
## ## Call: ## lm(formula = Sign.Area ~ NPI16TOTAL * Sex, data = datosLimpios) ## ## Residuals: ## Min 1Q Median 3Q Max ## -17.954 -5.892 -1.577 4.846 24.631 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 26.4911 1.2826 20.654 < 2e-16 *** ## NPI16TOTAL -0.3528 0.2876 -1.227 0.220789 ## SexF -5.6133 1.6247 -3.455 0.000624 *** ## NPI16TOTAL:SexF 1.0694 0.3969 2.694 0.007428 ** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 8.21 on 320 degrees of freedom ## (6 observations deleted due to missingness) ## Multiple R-squared: 0.04215, Adjusted R-squared: 0.03317 ## F-statistic: 4.693 on 3 and 320 DF, p-value: 0.003189
sa.lmi2=lm(Sign.Area~Sex+NPI16TOTAL:Sex,data=datosLimpios) summary(sa.lmi2)
## ## Call: ## lm(formula = Sign.Area ~ Sex + NPI16TOTAL:Sex, data = datosLimpios) ## ## Residuals: ## Min 1Q Median 3Q Max ## -17.954 -5.892 -1.577 4.846 24.631 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 26.4911 1.2826 20.654 < 2e-16 *** ## SexF -5.6133 1.6247 -3.455 0.000624 *** ## SexM:NPI16TOTAL -0.3528 0.2876 -1.227 0.220789 ## SexF:NPI16TOTAL 0.7166 0.2736 2.619 0.009229 ** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 8.21 on 320 degrees of freedom ## (6 observations deleted due to missingness) ## Multiple R-squared: 0.04215, Adjusted R-squared: 0.03317 ## F-statistic: 4.693 on 3 and 320 DF, p-value: 0.003189
sa.lmi3=lm(Sign.Area~NPI16TOTAL+NPI16TOTAL:Sex,data=datosLimpios) summary(sa.lmi3)
## ## Call: ## lm(formula = Sign.Area ~ NPI16TOTAL + NPI16TOTAL:Sex, data = datosLimpios) ## ## Residuals: ## Min 1Q Median 3Q Max ## -15.767 -5.757 -1.559 4.116 26.514 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 22.99259 0.80056 28.721 <2e-16 *** ## NPI16TOTAL 0.30290 0.21973 1.379 0.169 ## NPI16TOTAL:SexF -0.05026 0.23308 -0.216 0.829 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 8.349 on 321 degrees of freedom ## (6 observations deleted due to missingness) ## Multiple R-squared: 0.006414, Adjusted R-squared: 0.0002233 ## F-statistic: 1.036 on 2 and 321 DF, p-value: 0.356
plot(sa.lmi2)
plot(sa.lmi2)
plot(sa.lmi2)
plot(sa.lmi2)
El cociente F, en términos genéricos, se puede escribir como:
\(F=\frac{ \mathrm{Varianza}\quad \mathrm{explicada}}{\mathrm{Varianza}\quad \mathrm{no}\quad \mathrm{explicada}}\)
\(F=1\) o \(F<1\) : Varianza explicada es menor que la no explicada (modelo no ajusta bien)
anova(sa.lm)
## Analysis of Variance Table ## ## Response: Sign.Area ## Df Sum Sq Mean Sq F value Pr(>F) ## NPI16TOTAL 1 141.2 141.19 2.0546 0.15272 ## Sex 1 318.6 318.61 4.6364 0.03204 * ## Residuals 321 22058.5 68.72 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(sa.lm)
## ## Call: ## lm(formula = Sign.Area ~ NPI16TOTAL + Sex, data = datosLimpios) ## ## Residuals: ## Min 1Q Median 3Q Max ## -16.984 -5.743 -1.614 4.576 25.202 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 24.3982 1.0305 23.676 <2e-16 *** ## NPI16TOTAL 0.2086 0.2001 1.042 0.298 ## SexF -2.0397 0.9472 -2.153 0.032 * ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 8.29 on 321 degrees of freedom ## (6 observations deleted due to missingness) ## Multiple R-squared: 0.02042, Adjusted R-squared: 0.01432 ## F-statistic: 3.346 on 2 and 321 DF, p-value: 0.03647
library(car) Anova(sa.lm,type=3)
## Anova Table (Type III tests) ## ## Response: Sign.Area ## Sum Sq Df F value Pr(>F) ## (Intercept) 38520 1 560.5439 < 2e-16 *** ## NPI16TOTAL 75 1 1.0862 0.29811 ## Sex 319 1 4.6364 0.03204 * ## Residuals 22059 321 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(car) Anova(sa.lm,type=2)
## Anova Table (Type II tests) ## ## Response: Sign.Area ## Sum Sq Df F value Pr(>F) ## NPI16TOTAL 74.6 1 1.0862 0.29811 ## Sex 318.6 1 4.6364 0.03204 * ## Residuals 22058.5 321 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(sa.lm)
## ## Call: ## lm(formula = Sign.Area ~ NPI16TOTAL + Sex, data = datosLimpios) ## ## Residuals: ## Min 1Q Median 3Q Max ## -16.984 -5.743 -1.614 4.576 25.202 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 24.3982 1.0305 23.676 <2e-16 *** ## NPI16TOTAL 0.2086 0.2001 1.042 0.298 ## SexF -2.0397 0.9472 -2.153 0.032 * ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 8.29 on 321 degrees of freedom ## (6 observations deleted due to missingness) ## Multiple R-squared: 0.02042, Adjusted R-squared: 0.01432 ## F-statistic: 3.346 on 2 and 321 DF, p-value: 0.03647
## Analysis of Variance Table ## ## Response: Sign.Area ## Df Sum Sq Mean Sq F value Pr(>F) ## NPI16TOTAL 1 141.2 141.19 2.0947 0.148792 ## Sex 1 318.6 318.61 4.7268 0.030428 * ## NPI16TOTAL:Sex 1 489.3 489.27 7.2587 0.007428 ** ## Residuals 320 21569.3 67.40 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Analysis of Variance Table ## ## Response: Sign.Area ## Df Sum Sq Mean Sq F value Pr(>F) ## Sex 1 385.2 385.16 5.7142 0.017406 * ## NPI16TOTAL 1 74.6 74.64 1.1073 0.293454 ## Sex:NPI16TOTAL 1 489.3 489.27 7.2587 0.007428 ** ## Residuals 320 21569.3 67.40 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova()Anova(,type=3)