I have logs from a user's keyboard, mouse, and a few other things. I am trying to use them in order to do some predictions. Exploring the data and trying some feature engineering, I have discovered that the Hold Time (duration between when a key is pressed and released in milliseconds) seems very promising.

In order to make predictions, the data is aggregated to be in the following form:

__________| keys pressed | mouse clicks | hold time mean |...| label
minute 1  |     X_11     |      X_12    |       X_13     |...| y_1
minute 2  |     X_21     |      X_22    |       X_23     |...| y_2
...              ...             ...             ...      ...  ...
minute N  |     X_N1     |      X_N2    |       X_N3     |...| y_N

The issue is that sometimes, a user would spend a minute without typing and thus computing a Hold Time mean makes no sense and creates a missing value. This obviously only happens when the value for keys pressed is zero.

I do not know how to handle these missing values. I do not want to drop all entries where the user was not typing, because I can rely on other features to do predictions in those cases. I thought that maybe putting the Hold Time mean to zero would make sense, since indeed the amount of time a key was held is zero, but this must bias my model?

Would anybody have any recommendation how to deal with this?


1 Answer 1


In this case, the 0 in keys pressed predicts missing data in hold time mean. Does any other field with data predict hold time mean? That in itself can be an interesting finding. You could also try to reformat your data where time is nested in observations (i.e., from a 'wide' format to a 'long' format), which would allow a longitudinal hierarchical linear model. In these kinds of models, listwise deletion is less deleterious.

  • $\begingroup$ 0 in ´keys pressed´ does indeed predict missing value in ´hold time mean´, but no other value or feature can predict ´hold time mean´. I am not sure how I could convert my data from 'wide' to 'long', or how it could help. Could you please explain? $\endgroup$
    – Brandon LS
    Dec 11, 2017 at 14:31
  • $\begingroup$ It also looks like your data is already formatted for a longitudinal hierarchical model. I like the Raudenbush & Bryk (2002) test for multi-level modelling. $\endgroup$ Dec 11, 2017 at 14:34
  • $\begingroup$ Your model might look like this: $Level 1:$ $hold.time.mean=\beta_0+\beta_1(minute_{ij})+e_{ij}$ $Level 2:$ $\beta_0=\gamma_00+\gamma_01(keys.pressed_j)+\gamma_02(mouse.clicks_j)+U_0$ $\beta_1=\gamma_00+\gamma_01(keys.pressed_j)+\gamma_02(mouse.clicks_j)+U_1$ $\endgroup$ Dec 11, 2017 at 14:41

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.