url <- 'https://raw.githubusercontent.com/ankita1112/House-Prices-Advanced-Regression/master/train.csv'
Datosparcial <- read.csv(url)
# Descripción general
Datosparcial %>% summarise(filas = n(), columnas = ncol(.))
## filas columnas
## 1 1460 81
La base de datos cuenta con 1460 filas y 81 columnas.
colSums(is.na(Datosparcial))
## Id MSSubClass MSZoning LotFrontage LotArea
## 0 0 0 259 0
## Street Alley LotShape LandContour Utilities
## 0 1369 0 0 0
## LotConfig LandSlope Neighborhood Condition1 Condition2
## 0 0 0 0 0
## BldgType HouseStyle OverallQual OverallCond YearBuilt
## 0 0 0 0 0
## YearRemodAdd RoofStyle RoofMatl Exterior1st Exterior2nd
## 0 0 0 0 0
## MasVnrType MasVnrArea ExterQual ExterCond Foundation
## 8 8 0 0 0
## BsmtQual BsmtCond BsmtExposure BsmtFinType1 BsmtFinSF1
## 37 37 38 37 0
## BsmtFinType2 BsmtFinSF2 BsmtUnfSF TotalBsmtSF Heating
## 38 0 0 0 0
## HeatingQC CentralAir Electrical X1stFlrSF X2ndFlrSF
## 0 0 1 0 0
## LowQualFinSF GrLivArea BsmtFullBath BsmtHalfBath FullBath
## 0 0 0 0 0
## HalfBath BedroomAbvGr KitchenAbvGr KitchenQual TotRmsAbvGrd
## 0 0 0 0 0
## Functional Fireplaces FireplaceQu GarageType GarageYrBlt
## 0 0 690 81 81
## GarageFinish GarageCars GarageArea GarageQual GarageCond
## 81 0 0 81 81
## PavedDrive WoodDeckSF OpenPorchSF EnclosedPorch X3SsnPorch
## 0 0 0 0 0
## ScreenPorch PoolArea PoolQC Fence MiscFeature
## 0 0 1453 1179 1406
## MiscVal MoSold YrSold SaleType SaleCondition
## 0 0 0 0 0
## SalePrice
## 0
Datosparcial_limpia <- Datosparcial %>%
select(SalePrice, GrLivArea, GarageArea, OverallQual, Neighborhood) %>%
na.omit()
Datosparcial_limpia %>%
summarise(
Media = mean(SalePrice),
Mediana = median(SalePrice),
Desviación_Estandar = sd(SalePrice)
)
## Media Mediana Desviación_Estandar
## 1 180921.2 163000 79442.5
Interpretación:
La media (180921.2) es mayor que la mediana (163000), lo que indica una
distribución asimétrica positiva.
Datosparcial_limpia %>% summarise(Media_GrLivArea = mean(GrLivArea))
## Media_GrLivArea
## 1 1515.464
Conclusión:
La media del precio de venta es considerablemente mayor que la del área
habitable. Esto sugiere que los precios tienden a ser altos,
especialmente para viviendas más grandes.
range(Datosparcial_limpia$GarageArea)
## [1] 0 1418
var(Datosparcial_limpia$GarageArea)
## [1] 45712.51
Conclusión:
La variable GarageArea es heterogénea,
debido al amplio rango y alta varianza (45712.51), lo que indica gran
variabilidad.
summary(Datosparcial_limpia)
## SalePrice GrLivArea GarageArea OverallQual
## Min. : 34900 Min. : 334 Min. : 0.0 Min. : 1.000
## 1st Qu.:129975 1st Qu.:1130 1st Qu.: 334.5 1st Qu.: 5.000
## Median :163000 Median :1464 Median : 480.0 Median : 6.000
## Mean :180921 Mean :1515 Mean : 473.0 Mean : 6.099
## 3rd Qu.:214000 3rd Qu.:1777 3rd Qu.: 576.0 3rd Qu.: 7.000
## Max. :755000 Max. :5642 Max. :1418.0 Max. :10.000
## Neighborhood
## Length:1460
## Class :character
## Mode :character
##
##
##
ggplot(Datosparcial_limpia, aes(x = SalePrice)) +
geom_histogram(fill = "steelblue", color = "black", bins = 30) +
ggtitle("Distribución del precio de venta") +
theme_minimal()
Interpretación:
La distribución es asimétrica positiva, con muchos
precios bajos y pocos precios altos.
ggplot(Datosparcial_limpia, aes(x = factor(OverallQual), y = SalePrice)) +
geom_boxplot(fill = "tomato") +
ggtitle("Precio de venta según calidad general") +
xlab("Calidad general") +
ylab("Precio de venta") +
theme_minimal()
Conclusión:
A mayor OverallQual, mayor precio de
venta. Hay varios valores atípicos.
Datosparcial_limpia %>%
group_by(Neighborhood) %>%
summarise(PrecioPromedio = mean(SalePrice)) %>%
ggplot(aes(x = reorder(Neighborhood, -PrecioPromedio), y = PrecioPromedio)) +
geom_bar(stat = "identity", fill = "darkgreen") +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
ggtitle("Precio promedio por barrio")
Conclusión:
El barrio con precio más alto es
NoRidge y el de precio más bajo es
MeadowV.
ggplot(Datosparcial_limpia, aes(x = GrLivArea, y = SalePrice)) +
geom_point(color = "purple", alpha = 0.5) +
ggtitle("Relación entre área habitable y precio de venta") +
theme_minimal()
Conclusión:
Existe una relación positiva entre el área habitable y
el precio de venta.
OverallQual es una variable
ordinal.
No es completamente correcto calcular su media, aunque se hace con
frecuencia para análisis exploratorios.