구별 대여량이 가장 많은 마포구의 따릉이 시간대별 따릉이 수요 예측을 통한 따릉이 관리 및 재배치 인력의 효율성 제고
[서울 빅데이터 캠퍼스]
2017년 4-6월 서울시 내 따릉이 대여일시, 대여정류소, 반납정류소 정보가 있음
구정보 또한 ’numeric vector’으로 되어있으므로
| Dependent Variable | Description |
|---|---|
| Count | 특정한 구의 정류소를 이용한 수 |
데이터량을 고려하여 2017년 전체가 아닌 2017년 2분기를 연구 범위로 설정 #### 기간 설정 이유 1년을 기준으로 1년 중 2분기가 특히 기후 변화의 영향을 크게 받을 것으로 예상
‘날씨’,’따릉이 수요량’간의 관계를 파악하기 용이함
station.merge <- read.csv("Data/station_merge.csv", header = TRUE, sep = ",",fileEncoding = 'UTF-8')
ggplot2:: ggplot(data = station.merge, aes(x= station.no, user_count)) +ggtitle("Station numbers and rent frequency of Seoul") +geom_point(aes(size=user_count), shape=21, fill="#02B58A",color="#dadada") +guides(fill=guide_legend(title=NULL)) +geom_text(aes(y=user_count),label=station.merge$gu,vjust=-1.1,size=4) +xlab("Station #") +ylab("Rented") +theme(panel.background = element_rect(fill = "#F6F1EB",size=2),panel.grid.major = element_line(colour = "#DADADA",linetype = "dashed"),panel.grid.minor = element_line(colour = "#F6F1EB"),legend.title = element_blank(),legend.justification = "bottom",legend.key = element_rect(fill = "white"),legend.background=element_rect(colour = '#dadada',size=0.01),plot.title = element_text(colour="#706f6f", size=22,hjust=0.5,vjust=3,face="bold"),axis.title=element_text(colour = "#706f6f",size=15),axis.text = element_text(colour="#706f6f"))
‘서울시 구별 따릉이 대여소 수와 대여량’ 분석 결과, 마포구의 대여량이 가장 많은 것으로 나타남
구별 대여량이 많기에 자전거 수작업 재배치는 물론, 관련 기반시설 관리 인력이 많이 필요할 것으로 추측해볼 수 있음
##### i) 데이터 정제
mapo_na <- mapo
for(i in 1:nrow(mapo_na)){
if(is.na(mapo_na[i, "ozone"])){
mapo_na[i, "ozone"] <- mapo_na[i+1, "ozone"]
}
if(is.na(mapo_na[i, "pm10"])){
mapo_na[i, "pm10"] <- mapo_na[i+1, "pm10"]
}
if(is.na(mapo_na[i, "pm2.5"])){
mapo_na[i, "pm2.5"] <- mapo_na[i+1, "pm2.5"]
}
}
##
## Call:
## lm(formula = count ~ weekend + time.1 + time.2 + time.3 + time.4 +
## time.5 + temperature + precipitation + windspeed + humidity +
## visibility + ozone + pm10 + pm2.5, data = mapo_na.train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -202.405 -31.830 -4.369 26.491 221.875
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.345111 20.522905 -0.114 0.90904
## weekend 9.587975 3.221205 2.977 0.00297 **
## time.1 46.913748 5.149246 9.111 < 2e-16 ***
## time.2 15.783697 5.960103 2.648 0.00819 **
## time.3 60.314693 6.651077 9.068 < 2e-16 ***
## time.4 159.089302 5.803366 27.413 < 2e-16 ***
## time.5 68.356519 5.084665 13.444 < 2e-16 ***
## temperature 5.018325 0.331569 15.135 < 2e-16 ***
## precipitation -67.014390 8.305186 -8.069 1.63e-15 ***
## windspeed 8.855408 1.455688 6.083 1.56e-09 ***
## humidity -0.670134 0.132923 -5.042 5.29e-07 ***
## visibility -0.005348 0.004893 -1.093 0.27455
## ozone 0.269196 102.992142 0.003 0.99791
## pm10 -0.303868 0.071935 -4.224 2.57e-05 ***
## pm2.5 0.120484 0.159356 0.756 0.44975
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 51.21 on 1264 degrees of freedom
## Multiple R-squared: 0.6777, Adjusted R-squared: 0.6741
## F-statistic: 189.8 on 14 and 1264 DF, p-value: < 2.2e-16
## [1] 2777.69
##
## Shapiro-Wilk normality test
##
## data: mapo.final$residuals
## W = 0.97347, p-value = 1.405e-14
## lag Autocorrelation D-W Statistic p-value
## 1 0.3810735 1.237521 0
## Alternative hypothesis: rho != 0
## Non-constant Variance Score Test
## Variance formula: ~ fitted.values
## Chisquare = 139.623 Df = 1 p = 3.218537e-32
##
## Call:
## lm(formula = count ~ weekend + time.1 + time.2 + time.3 + time.4 +
## time.5 + temperature + precipitation + windspeed + humidity +
## visibility + pm10, data = mapo_na.train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -202.747 -31.850 -4.341 26.177 221.897
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.920757 17.573764 0.280 0.77952
## weekend 9.454271 3.206714 2.948 0.00325 **
## time.1 46.889730 5.026584 9.328 < 2e-16 ***
## time.2 16.123478 5.928393 2.720 0.00662 **
## time.3 60.882266 6.520420 9.337 < 2e-16 ***
## time.4 159.795389 5.718248 27.945 < 2e-16 ***
## time.5 68.738760 5.053046 13.603 < 2e-16 ***
## temperature 4.985080 0.320228 15.567 < 2e-16 ***
## precipitation -68.125650 8.153869 -8.355 < 2e-16 ***
## windspeed 8.679329 1.381247 6.284 4.54e-10 ***
## humidity -0.691589 0.126387 -5.472 5.36e-08 ***
## visibility -0.007265 0.004078 -1.781 0.07512 .
## pm10 -0.287664 0.068622 -4.192 2.96e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 51.18 on 1266 degrees of freedom
## Multiple R-squared: 0.6775, Adjusted R-squared: 0.6745
## F-statistic: 221.7 on 12 and 1266 DF, p-value: < 2.2e-16
##
##
## ASSESSMENT OF THE LINEAR MODEL ASSUMPTIONS
## USING THE GLOBAL TEST ON 4 DEGREES-OF-FREEDOM:
## Level of Significance = 0.05
##
## Call:
## gvlma::gvlma(x = mapo.final)
##
## Value p-value Decision
## Global Stat 290.50 0.000e+00 Assumptions NOT satisfied!
## Skewness 72.72 0.000e+00 Assumptions NOT satisfied!
## Kurtosis 69.35 1.110e-16 Assumptions NOT satisfied!
## Link Function 134.93 0.000e+00 Assumptions NOT satisfied!
## Heteroscedasticity 13.51 2.376e-04 Assumptions NOT satisfied!
## weekend time.1 time.2 time.3 time.4
## 1.018713 1.712127 2.354639 3.009038 2.173863
## time.5 temperature precipitation windspeed humidity
## 1.704080 1.658911 1.219278 1.614306 3.195380
## visibility pm10
## 2.803297 1.698957
## Weights
## pm2.5 0.3772272
## weekend 0.4133684
## time.1 0.9679139
## pm10 1.2656510
## time.5 1.9862820
## time.2 1.9971855
## visibility 2.5441255
## precipitation 3.6582674
## time.3 5.1599312
## ozone 5.1996888
## humidity 7.1397981
## windspeed 8.7470220
## temperature 20.8720952
## time.4 39.6714437