library(readxl)
## Warning: package 'readxl' was built under R version 4.0.5
df_Mice = Datos_Tarea_Julio_9 <- read_excel("D:/Users/Usuario/Desktop/Trabajos Diseno/Datos Tarea Julio 9.xlsx");df_Mice
## # A tibble: 36 x 5
## Fertilizante MO Proteína y x
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 D15 2.24 4.15 1 1
## 2 D5 1.99 4.76 2 1
## 3 D5 1.82 5.10 3 1
## 4 D0 2.36 4.99 4 1
## 5 D5 2.32 5.14 5 1
## 6 D5 2.38 5.19 6 1
## 7 D10 2.56 5.70 1 2
## 8 D5 2.59 5.44 2 2
## 9 D0 2.62 5.73 3 2
## 10 D10 2.73 5.76 4 2
## # ... with 26 more rows
Fertilizante=df_Mice$Fertilizante
MO=df_Mice$MO
Proteína=df_Mice$Proteína
X=df_Mice$x
Y=df_Mice$y
#N/A total en la base de datos
sum(is.na(df_Mice))
## [1] 5
#Omitir NA (filas)
df_COV <- na.omit(df_Mice);df_COV
## # A tibble: 31 x 5
## Fertilizante MO Proteína y x
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 D15 2.24 4.15 1 1
## 2 D5 1.99 4.76 2 1
## 3 D5 1.82 5.10 3 1
## 4 D0 2.36 4.99 4 1
## 5 D5 2.32 5.14 5 1
## 6 D5 2.38 5.19 6 1
## 7 D10 2.56 5.70 1 2
## 8 D5 2.59 5.44 2 2
## 9 D0 2.62 5.73 3 2
## 10 D10 2.73 5.76 4 2
## # ... with 21 more rows
#NA por columna
colSums(is.na(df_Mice))
## Fertilizante MO Proteína y x
## 0 0 5 0 0
library(mice)
## Warning: package 'mice' was built under R version 4.0.5
##
## Attaching package: 'mice'
## The following object is masked from 'package:stats':
##
## filter
## The following objects are masked from 'package:base':
##
## cbind, rbind
Columnas <- c("Proteína","MO")
DATOS <- mice(df_Mice[,names(df_Mice) %in% Columnas],m = 1,
maxit = 1, method = "mean",print=F)
Datos_Completos <- mice::complete(DATOS)
Proteína_2=Datos_Completos$Proteína
Análisis Exploratorio \[y_1 = \beta_0 + \beta_1x_i+\epsilon\]
\[P_1 = \beta_0 + \beta_1MO_i+\epsilon\]
\[E[P_1 |MO_i]= \beta_0 + \beta_1MO_i\]
\[\widehat{P_1} = \beta_0 + \beta_1MO_i\]
Minimos Cuadrados Oridnarios
mod_1 = lm(Proteína~MO)
summary(mod_1)
##
## Call:
## lm(formula = Proteína ~ MO)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.10399 -0.27435 0.09673 0.23745 0.76812
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.6768 0.3822 9.619 1.58e-10 ***
## MO 0.7050 0.1250 5.642 4.27e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4003 on 29 degrees of freedom
## (5 observations deleted due to missingness)
## Multiple R-squared: 0.5233, Adjusted R-squared: 0.5069
## F-statistic: 31.83 on 1 and 29 DF, p-value: 4.269e-06
coef = round(mod_1$coefficients, 2)
\[Piˆ=3.68+0.7MO\]
shapiro.test(mod_1$residuals)
##
## Shapiro-Wilk normality test
##
## data: mod_1$residuals
## W = 0.97525, p-value = 0.6723
hist(mod_1$residuals)
plot(mod_1$residuals, pch = 14)
mod_2 = aov(Proteína_2 ~ MO + Fertilizante)
summary(mod_2)
## Df Sum Sq Mean Sq F value Pr(>F)
## MO 1 4.712 4.712 35.706 1.32e-06 ***
## Fertilizante 3 0.944 0.315 2.383 0.0883 .
## Residuals 31 4.091 0.132
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
boxplot(Proteína_2 ~ Fertilizante)