Will Jones December 8, 2015
As our first steps in modeling ride rating, we will start to model without route data. Instead we will focus on other question in the modeling as a start for our model:
We actually expect a fair amount of the variance in ride rating to be explained by these variables, based on tests of a smaller sample.
There are 6798 rides in the data set, with 3430 (50.4560165%) rides with no rating.
We also want to consider patterns with weather. We have data on daily weather, including wind speed, temperature highs and lows, and rain data. But we also have hourly rain data from a local fire station.
We would like to incorporate traffic, but to simplify our model, we may simple use time of day as a proxy.
First, we consider how a classical logistic regression model compares to a model with a random intercept for riders. So we will model:
[ Y = \text{logit}^{-1} \left( \alpha + \beta_1 \cdot \text{log.length} + \beta_2 \cdot \text{log.wind speed} + \beta_3 \cdot \text{log.rainfall.4h} \right). ]
Now we want to explore how we can capture variance with and between riders. So we will use the basic model
[ Y \sim \text{Bernoulli} (\text{logit}^{-1}(\alpha_{j[i]})), \quad \alpha_{j[i]} \sim \text{Normal}(\mu_\alpha, \sigma^2_\alpha). ]
Now we want to add effects based on time of day. We will try using polynomial regression to do this first, by adding to our regression the terms,
[ \beta_1 \cdot \text{hour} + \beta_2 \cdot \text{hour}^2 + \beta_3 \cdot \text{hour}^3 + \beta_4 \cdot \text{hour}^4. ]
Our last model will take the rider intercepts and day effects and add the terms we had in our first regression with variables.
For now, we will compute these models using maximum likelihood. Later, we might do Bayesian inference with STAN.
results Dependent variable: stressful logisticgeneralized linear mixed-effects (1)(2)(3)(4) log.length0.0960.167* (0.072)(0.090) rainfall.4h0.018***0.019*** (0.005)(0.006) mean.wind.speed-0.00020.00001 (0.018)(0.019) hour0.303**0.274* (0.154)(0.154) I(hour2)-0.046-0.086 (0.161)(0.163) I(hour3)-0.153**-0.144* (0.076)(0.076) I(hour4)-0.043-0.035 (0.037)(0.037) Constant-1.910***-2.569***-2.503***-2.577*** (0.133)(0.250)(0.271)(0.299) Observations2,2622,2622,2622,262 Log Likelihood-902.967-768.043-762.117-755.048 Akaike Inf. Crit.1,813.9341,540.0861,536.2331,528.096 Bayesian Inf. Crit.1,551.5341,570.5771,579.612 Note:*p<0.1; **p<0.05; ***p<0.01Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.