1
$\begingroup$

I am trying to predict the likelihood of violent incidents as a function of time in hour in r. Its a binomial classification problem.

glm(formula = "violent ~ Timehr", family = binomial(link = "logit"), 
data = incidents). 

Here are beta estimates along with significance level. Time0 is taken as reference level. So the rate of violent incidents goes up significantly at Time1 relative to Time0 by 0.4388

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -1.5167     0.1414 -10.728  < 2e-16 ***
Timehr1:      0.4388     0.2176   2.016 0.043750 *  
Timehr10     -0.4069     0.2531  -1.608 0.107902    
Timehr11     -0.6142     0.2510  -2.447 0.014411 *  
Timehr12     -0.7828     0.2309  -3.390 0.000699 ***
Timehr13     -0.8227     0.2562  -3.211 0.001324 ** 
Timehr14     -0.8465     0.2560  -3.306 0.000946 ***
Timehr15     -0.4719     0.2271  -2.078 0.037712 *  
Timehr16     -0.4056     0.2160  -1.878 0.060368 .  
Timehr17     -0.6618     0.2256  -2.933 0.003356 ** 
Timehr18     -0.5030     0.2182  -2.305 0.021155 *  
Timehr19     -0.5071     0.2249  -2.255 0.024152 *  
Timehr2:      0.3689     0.2448   1.507 0.131804    
Timehr20     -0.2151     0.2176  -0.988 0.322931    
Timehr21     -0.1230     0.2250  -0.547 0.584552    
Timehr22     -0.3839     0.2176  -1.764 0.077689 .  
Timehr23     -0.4551     0.2235  -2.036 0.041743 *  
Timehr3:      0.5204     0.2776   1.875 0.060802 .  
Timehr4:      0.2391     0.3086   0.775 0.438426    
Timehr5:     -0.5469     0.4011  -1.364 0.172658    
Timehr6:     -0.8024     0.4505  -1.781 0.074914 .  
Timehr7:     -0.6368     0.3253  -1.957 0.050293 .  
Timehr8:     -0.5433     0.2517  -2.158 0.030894 *  
Timehr9:     -0.5842     0.2623  -2.227 0.025915 *

But on plot it is at time0 when violent crimes are at its peak and based on model summary interpretation is at Time1 it goes up as compared to Time0.

Am I interpreting the two output model summary and plot correctly?

enter image description here

$\endgroup$
3
  • 4
    $\begingroup$ The model and the plot are in agreement: The logistic regression models the probability of a violent event dependent on the time. So in the plot, it would be the proportion of violent events, i.e. the counts of the green bars divided by the total counts. At time 1, the proporion of violent events in relation to the total events is higher compared to time 0. Your interpretation of the coefficient is not quite right. Normally, people exponentiate the coefficients to get odds ratios. $\endgroup$ Mar 13, 2019 at 13:00
  • 1
    $\begingroup$ @COOLSerdash your answer is very much to the point. The proportion of violent crimes at Time1 is 25% as compared to Time0 where it is 17%. I missed that insight. Thanks a ton $\endgroup$
    – joy_1379
    Mar 13, 2019 at 14:05
  • 4
    $\begingroup$ The plot gets the times in the wrong order. Use ordered or the equivalent to put them in the right order. Then create a plot that is appropriate for the regression: it should show the proportions of violent crimes per hour. $\endgroup$
    – whuber
    Mar 13, 2019 at 14:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.