Question: I'm trying to calculate 14-day trends in COVID-19 infections and deaths (as shown on the NYTimes homepage). I want to do this on a state level and have access to each state's population and daily data about the covid infections/ deaths in that state <https://docs.google.com/spreadsheets/u/2/d/e/2PACX-1vRwAqp96T9sYYq2-i7Tj0pvTf6XVHjDSMIKBdZHXiCGGdNC0ypEU9NbngS8mxea55JuCFuua1MUeOj5/pubhtml#>

What's the best way to calculate these 14-day trends? And is a 14-day trend the same as a rate?
[![i](https://i.stack.imgur.com/a0JUN.png)](https://i.stack.imgur.com/a0JUN.png)

Answer: 
First, recognize that logistic regression does not impose a decision boundary. It provides probabilities of class memberships. What you show as a "decision boundary" is presumably based on a cutoff of 0.5 in predicted probability for converting the probabilities into class assignments. Other cutoffs can be better if false-positive and false-negative assignments have different costs. That's very important to remember as you are learning about this.

Second, it doesn't look like a simple linear model based on $x\_1$ and $x\_2$ alone will do a good job of distinguishing these classes. You have 2 clusters of different classes around $x\_1 = 0$, distinguished by their $x\_2$ values. You have 3 clusters around $x\_2 = -0.2$, with only the cluster also having $x\_1 \approx 0$ in the blue class. In that case, even an interaction term between $x\_1$ and $x\_2$ wouldn't work to distinguish the 2 classes in the 3 lower clusters, as one lower red cluster would still be on the opposite side of the blue class from the other lower red cluster.

You need a more complex model. As @Dave notes in a comment on another answer, a $x\_1^2$ term might well help, providing a way to distinguish the 2 lower red clusters from the blue cluster. You might also consider approaches other than logistic regression. For example [ISLR](https://faculty.marshall.usc.edu/gareth-james/ISL/) in Chapter 9 shows how choices of kernels in support vector machines can help distinguish classes that have non-linear boundaries, as yours do in this plot.
I realise this is a little late to the party, but I just had a similar issue with a logistic regression model of my own and wanted to understand why it wasn't at least orienting the decision plane to include more data-points and/or basing the minimum misclassification boundary more favourably. I was using iterated reweighted least squares fitting (Rubin, 1983) but where I had implemented this myself.

For me, I was getting very similar results to Raz (with a different arrangement of data-points). Namely, the decision plane didn't seem best oriented and the minimum misclassification boundary (at posterior probability 0.5) wasn't in the best position (I could change the threshold at which I drew the boundary and improve the accuracy). These strange characteristics seemed to arise because I had forgotten to include a bias term in my model (or a constant bias column in my data). Adding this in I began to see the anticipated results.

If anyone sees this behaviour themselves, I suggest you check to see that your bias term is properly included.

**References**

D. B. Rubin, Iteratively Reweighted Least Squares , Encycl. Stat. Sci. 33 (1983), 7–17.