model_iterations/model-1/first_model.md

First Model

Will Jones December 8, 2015

Introduction

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.

Some Numbers about the Data

There are 1515 rides in the data set, with 238 (15.709571%) rides with no rating.

What variables will we include?

Length

Weather

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.

Traffic / Daily Trends

We would like to incorporate traffic, but to simplify our model, we may simple use time of day as a proxy.

The Models

Classical Model

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). ]

Just Rider Random Effects

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). ]

Add Time of Day Effects

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. ]

All Effects

Our last model will take the rider intercepts and day effects and add the terms we had in our first regression with variables.

Table of coefficients

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.length-0.288***-0.377*** (0.097)(0.105) rainfall.4h-0.001-0.018 (0.026)(0.027) mean.wind.speed0.0370.008 (0.038)(0.038) hour0.2270.288 (0.192)(0.203) I(hour2)-0.0970.049 (0.249)(0.262) I(hour3)-0.038-0.087 (0.108)(0.117) I(hour4)-0.034-0.062 (0.060)(0.068) Constant-1.980***-2.783***-2.640***-2.792*** (0.249)(0.957)(0.952)(0.980) Observations890890890890 Log Likelihood-367.220-316.641-313.213-306.525 Akaike Inf. Crit.742.440637.281638.426631.050 Bayesian Inf. Crit.646.864667.173674.171 Note:*p<0.1; **p<0.05; ***p<0.01

Rider Intercepts

Hourly Trends

Model Accuracy and Fit

Separation Plots

Were there new levels? FALSE.



wjones127/thesis documentation built on May 4, 2019, 7:34 a.m.