data(iris)
summary(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width
## Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100
## 1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300
## Median :5.800 Median :3.000 Median :4.350 Median :1.300
## Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199
## 3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800
## Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500
## Species
## setosa :50
## versicolor:50
## virginica :50
##
##
##
Se observa que la variable Sepal.Length tiene un valor promedio de 5.843.
hist(iris$Sepal.Length, col="red")
hist(iris$Sepal.Width, col="blue")
hist(iris$Petal.Length, col="green")
hist(iris$Petal.Width, col="skyblue")
En la siguiente Figura se observa que encontramos datos atípicos en las variables Sepal.Width.
par(mfrow=c(2,2))
boxplot(iris$Sepal.Length, col="red", main="Sepal.Length")
boxplot(iris$Sepal.Width, col="skyblue" , main="Sepal.Width")
boxplot(iris$Petal.Length, col="blue", main="Petal.Length")
boxplot(iris$Petal.Width, col="green", main="Petal.Width")
Se observa que en la matriz de correlacion las variables más correlacionadas son Petal.Length y Petal.Width, con una correlación \(r=0.96\).
r=cor(iris[,-5])
r
## Sepal.Length Sepal.Width Petal.Length Petal.Width
## Sepal.Length 1.0000000 -0.1175698 0.8717538 0.8179411
## Sepal.Width -0.1175698 1.0000000 -0.4284401 -0.3661259
## Petal.Length 0.8717538 -0.4284401 1.0000000 0.9628654
## Petal.Width 0.8179411 -0.3661259 0.9628654 1.0000000
plot(iris[,-5] , col=iris$Species)
mod = lm(Sepal.Length ~ Petal.Length, data=iris)
summary(mod)
##
## Call:
## lm(formula = Sepal.Length ~ Petal.Length, data = iris)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.24675 -0.29657 -0.01515 0.27676 1.00269
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.30660 0.07839 54.94 <2e-16 ***
## Petal.Length 0.40892 0.01889 21.65 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4071 on 148 degrees of freedom
## Multiple R-squared: 0.76, Adjusted R-squared: 0.7583
## F-statistic: 468.6 on 1 and 148 DF, p-value: < 2.2e-16
Con base en los resultados del modelo se observa que el \(R^{2}=0.72\), lo cuál indica que es el porcentaje de varianza explicado de Sepal.Length a travez del modelo.
Table Header | Second Header |
---|---|
Table Cell | Cell 2 |
Cell 3 | Cell 4 |