##Generar regresion (modelo lineal)
regresion <- lm(rentas_totales ~ hora + dia+ mes + anio + estacion + dia_de_la_semana + asueto + temperatura + sensacion_termica + humedad + velocidad_del_viento, data=base_de_datos)
summary(regresion)
##
## Call:
## lm(formula = rentas_totales ~ hora + dia + mes + anio + estacion +
## dia_de_la_semana + asueto + temperatura + sensacion_termica +
## humedad + velocidad_del_viento, data = base_de_datos)
##
## Residuals:
## Min 1Q Median 3Q Max
## -305.52 -93.64 -27.70 61.85 649.10
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.661e+05 5.496e+03 -30.217 < 2e-16 ***
## hora 7.735e+00 2.070e-01 37.368 < 2e-16 ***
## dia 3.844e-01 2.482e-01 1.549 0.12150
## mes 9.996e+00 1.682e+00 5.943 2.89e-09 ***
## anio 8.258e+01 2.732e+00 30.225 < 2e-16 ***
## estacion -7.774e+00 5.177e+00 -1.502 0.13324
## dia_de_la_semana 4.393e-01 6.918e-01 0.635 0.52545
## asueto -4.864e+00 8.365e+00 -0.582 0.56089
## temperatura 1.582e+00 1.038e+00 1.524 0.12752
## sensacion_termica 4.748e+00 9.552e-01 4.971 6.76e-07 ***
## humedad -2.115e+00 7.884e-02 -26.827 < 2e-16 ***
## velocidad_del_viento 5.582e-01 1.809e-01 3.086 0.00203 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 141.7 on 10874 degrees of freedom
## Multiple R-squared: 0.3891, Adjusted R-squared: 0.3885
## F-statistic: 629.6 on 11 and 10874 DF, p-value: < 2.2e-16
##Evaluar y en caso necesario, ajustar la regresion
regresion <- lm(rentas_totales ~ hora + mes + anio + sensacion_termica + humedad + velocidad_del_viento, data=base_de_datos)
##Construir un modelo de prediccion
datos_nuevos <- data.frame (hora=12, mes=1:12, anio=2013, sensacion_termica=24, humedad=62, velocidad_del_viento=13)
predict(regresion,datos_nuevos)
## 1 2 3 4 5 6 7 8
## 279.1478 286.7215 294.2952 301.8690 309.4427 317.0164 324.5901 332.1638
## 9 10 11 12
## 339.7375 347.3112 354.8849 362.4587