# Predicting binary variable from time series data

A student questionnaire contained the question "Are you currently an active user of the on-campus gym?" (Yes/No).

Time series about gym use over the last 2 years are available for each student.

Some students answered "yes", although there was no evidence from the 2-year data, whereas others said no despite the data showing they used the gym very recently.

I want to see how well the usage data predicts the binary responses (logistic regression model).

So I derived the following possibly relevant variables:

• The number of uses in the last 1 year (n)
• The duration (d) since the most recent use could be a good predictor. But it can be 0 if the gym was used in the same day of self-report, or missing if the data doesn't have usage records for the student.

response ~ d + n

Is there any methodological and/or statistical problems with this approach?

Do you think other more relevant variables can be derived from the usage data, or other methods that better utilizes the time series nature of the usage data?

I'd recommend creating a dataset that contains one record per student. For each record, you have the target variable (aka the label): 1/0 to indicate whether they responded 'Yes' or 'No' to the survey question. Then you can do some feature negineering to create attributes for each student.

The model would take the following form: $$logit\ E(Y_i)=\alpha+\beta*X_i\$$

Where $$i$$ represents a student.

There's no methodical/statistical problem with this approach. I am assuming that the survey was taken at the end of the "observation window" (of 2 years). This way, all variables/attributes in the model serve as "leading indicators", aka they represent all information that's available at the time when the survey was taken.

In addition to the two variables you mentioned here are a few more examples of variables you can create:

1. Days since the first gym visit (this would be capped at ~730 days because only two years' worth of data is available)
2. Average days between gym visits
3. Number of gym visits per month
4. Number of gym visits during weekdays (Note: 4-12 assume that you have the time-stamp of each gym visit.)
5. Number of gym visits during weekends
6. % of gym visits during weekends
7. Number of gym visits during office hours
8. Number of gym visits during mornings
9. Number of gym visits during afternoons
10. Number of gym visits during evenings
11. Number of gym visits during nights
12. % of gym visits for attributes 8-11
13. If you have the duration of each visits, you can create a bunch of attributes from that

Here are a few ideas:

I think that maybe the problem lies in the formulation of the question, and what is an active user. What comes to mind when hearing active user might be more linked to frequency and regularity.

Thus you have 4 kinds of positives: the loyal users with regularity, the loyal users without regularity, the churners, and the new active users.

For loyal users there might be some regularity. I would look at variables like at what cardinality the visits to the gym happen on each day of the week — of the month. E.g. n_monday_usages compared to all_usages etc.

This one is simple and identifies loyal users with regularity.

Your feature of time since last Gym usage might be good for churners.

If I spot samples with regularity (loyal users) I would put them aside from the dataset before going through the next steps.

The overall use of the gym by non active users must follow a law akin to a Poisson process, and thus the time between 2 uses must follow an exponential law.

Fit a poisson distribution to the number of gym uses (first check that variance ~1.5 * mean, else perform a Negative Binomial fit). Look at the goodness of fit. If the fit is good, then an observation you can derive can be "being very above the central tendency" (here you choose whatever performs the best). Or else you go non parametric if you have enough samples and a fat enough tail and use high percentiles. This feature should help you spot intensive users with no regularity.

About the period between 2 gym usages: You can remove samples if the sample used the Gym once or never, else use the average period between 2 uses. Then fit the cdf of an exponential distribution to this data. An observation you can derive could be "being very under the central tendency". If you have enough samples here you go non parametric as well and use the low percentiles. This feature should help you spot new active users.

Your approach seems fine. Though you could define $$n$$ as the number of uses in the full 2-year time period, no need to restrict it to 1 year.