# Linear or logistic regression with aggregated data

I'm kind of stuck on a simple question:

I have aggregated data over 15 years for each year how many people in a patient group have received a certain medication X (1105 with X from 2566 patients total in 2016...). The question is now is there a trend? In a similar paper, a logistic regression was calculated and an odds ratio reported. I'm not sure how to calculate a logistic regression from this aggregated data?!? I would have simply calculated a simple linear regression over the relative frequencies (the total number of patients treated varies from year to year)? What would be a correct handling of this kind of data?

| drug X .   | All Patients|     year     |
|------------|-------------|--------------|
| 1394       |        1491 |     2001     |
| 1463       |        1544 |     2002     |
| 1492       |        1585 |     2003     |
| 1511       |        1587 |     2004     |
| 2041       |        2146 |     2005     |
| 2271       |        2383 |     2006     |


## 1 Answer

If the outcome is binary, category 1 did not receive medicine x and category 2 did receive medicine x. Then I do not understand why you cannot run a logistic regression. If the variable you want to predict is whether someone will receive the medicine, I think logistic regression is the most appropriate for the data. The question is do you have predictors? what are your predictors because regression models require at least one predictor and at least one outcome. I cannot see if you have a predictor or not in your question.

In any case logistic regression can handle both categorical and continuous predictors, however the outcome must always be binary.

• Thanks for your quick answer. There are no predictors. I only have the data: year, total number of patients by year, patients treated with drug X by year. I have calculated logistic regressions so far only in such a way that I had single cases with predictors never with already aggregated numbers. – Gurkenkönig Jun 27 '18 at 11:56
• It might help if you clarify the question you're trying to answer -- are you just interested in determining whether the proportion of individuals receiving the treatment is increasing/decreasing by year? If so, it might be worth considering what other methods will best address that point -- perhaps a simple line plot with proportion on the Y axis and year on the X axis would ultimately be more useful. – dlid Jun 27 '18 at 12:13
• If there are no variables than can serve as predictors then I am not sure how I would proceed with this problem. I managed to see your dataset above and I can see that every year there is a different amount of patients. What I would do would be to standardize the values. i.e. determine the percentage of patients taking the drug and then I would proceed with time series analysis – Dimitrios Zacharatos Jun 27 '18 at 12:56
• A different solution is: Think your data as a graph on y axis you have the percentage of patients taking the drug and on x axis year. In that case time in years can be your predictor but now the outcome is a continuous variable so linear regression may be advised. If you are interested in a trend you may check the slope of the line y=a*x+b in that case a provides the trend – Dimitrios Zacharatos Jun 27 '18 at 13:00
• the predictor is the year, and in r you can input the counts of positive and negative examples as 'target variable'. in python scikit-learn, you may be able to use sample weights to specify counts of positive and negative examples – seanv507 Jun 27 '18 at 13:41