HAVO1 <- read.csv("VisitationbyMonth3.csv")
head(HAVO1)
Getting a wide data set into a long data set
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.2.1 --
## v ggplot2 2.2.1 v purrr 0.2.4
## v tibble 1.4.2 v dplyr 0.7.4
## v tidyr 0.8.0 v stringr 1.2.0
## v readr 1.1.1 v forcats 0.2.0
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
HAVO2 <- HAVO1 %>%
gather(year, visitors, contains("X"))
## Warning: attributes are not identical across measure variables;
## they will be dropped
head(HAVO2)
send it out to combine with the flight passenger data.
write.csv(HAVO2,file = "HAVO4.csv")
This is a file that contains all of the passenger info from Kona and Hilo Airports as well as the visitor counts from HAVO.
HAVO5 <- read.csv("HAVO5.csv")
Histogram of total incoming passengers per month at both Kona and Hilo Airports, a fairly normal distribution.
hist(HAVO5$HILOKONAtotal)
Histogram of total visitors per month for HAVO, a fairly normal distribution
hist(HAVO5$visitors)
Scatter plot showing total inbound passengers per month at Hilo and Kona on the X-axis and Y-axis the total visitors per month at HAVO. Then called a method to fit a linear model (blue line) with the confidence interval in grey. Data from 2002 - 2017.
library(ggplot2)
p <- ggplot(HAVO5, aes(x=HAVO5$HILOKONAtotal, y=HAVO5$visitors)) + geom_point() + geom_smooth(method = lm)
p + labs(x = "Inbound Passengers per Month at Hilo & Kona", y = "Visitors Per Month at HAVO")
here is a simple pearson’s correlation calc, positive linear association between passengers and visitors
cor(HAVO5$visitors,HAVO5$HILOKONAtotal)
## [1] 0.6050953
fit1<-lm(HAVO5$visitors~HAVO5$HILOKONAtotal)
summary(fit1)
##
## Call:
## lm(formula = HAVO5$visitors ~ HAVO5$HILOKONAtotal)
##
## Residuals:
## Min 1Q Median 3Q Max
## -57116 -15971 -355 13257 92063
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.946e+04 1.444e+04 -1.348 0.179
## HAVO5$HILOKONAtotal 8.545e-01 8.451e-02 10.111 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 23410 on 177 degrees of freedom
## Multiple R-squared: 0.3661, Adjusted R-squared: 0.3626
## F-statistic: 102.2 on 1 and 177 DF, p-value: < 2.2e-16
This analysis is based on monthly inbound passenger data and monthly visitor data from October 2002 - August 2017. Based on this result, for every 1 additional passenger on inbound flights to the island, we would expect to see a 0.85 visitor increase at HAVO for that month on average. The p value of the passenger explanatory variable is very tiny which means we can reject the null hypothesis and say that the 0.85 is statistically significant. The null hypothesis in this case would be that as inbound passengers to the island changes, the change in visitors at HAVO could not be distinguished from random. The residual standard error of the model is pretty high at 23410 which means that the linear model is either under or over predicting visitors to HAVO per month by that amount. The R-squared result of this model can be interpereted as 36% of the variation in the visitors per month at HAVO can be explained by variation in the amount of inbound passengers per month at Kona and Hilo airports combined.