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.
> 
> why logistic regression classifies them wrongly and at least does not involve one of the small clusters?
> 
> 
> 

The center clusters (red and blue) have a wide spread on x2.

Adding regularization will also be better.

> 
> How should I rearrange the red clusters to reduce the misclassification?
> 
> 
> 

This means we can change our data to make the performance better. I think this is cheating in real world. But for learning purposes, it is a perfect question.

My answer is if we move one of the small red clusters higher (say, make the red cluster on right side to be centered around 0,0.25), it will definitely fix the problem.