I have crime event data rows:

dayofweek1, region1, hour1, crimetype1
dayofweek2, region2, hour2, crimetype2 ...

and I want to use them as factors to model crime rates/probabilities at the region level.

I also want to use the resulting model to be able to input factor values to produce crime probabilities. e.g. on Sunday, in region1 there is a .03 chance of burglary at 3pm.

I think I should use a multilevel model, but everything I have found assumes a y value at the individual data row level which I do not have. All the row data are crimes.

Does anyone have an example of such a model (obviously not necessarily crime data, and preferably using python)?

Can the prediction bit be done?


1 Answer 1


I think what you're looking for is Survival analysis.

From Wikipedia:

Survival analysis is a branch of statistics for analyzing the expected duration of time until one or more events happen, such as death in biological organisms and failure in mechanical systems.

In your case, you'd like to predict the time a crime will occur in a given region.

Hope this helps!


As of the 'per group prediction': your problem is this:

everything I have found assumes a y value at the individual data row level

There's no such thing as an algorithm to predict a target variable per group. You have to transform your data so it has a 'y' value per group, and then train some model based on that. It may be seen as a regression problem, or maybe as some kind of survival analysis. But you can't escape from the fact that you'll need one target value per group to start doing stuff.

  • $\begingroup$ Thanks. My question is about predicting at the group level with data at the individual level, which I do not think your answer addresses. $\endgroup$
    – schoon
    Nov 3, 2019 at 7:56
  • $\begingroup$ @schoon you're right. Just updated my answer trying to make clearer the approach you should take. $\endgroup$
    – 89f3a1c
    Nov 3, 2019 at 12:46

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.