0
$\begingroup$

I have the following data (the actual dataset is much bigger)

Week    Year    Usd Group
30  2015    435345  1
30  2015    565345  2
31  2015    12332   1
32  2015    4343545 2
33  2015    8775    3
34  2015    8787    4
30  2016    435345  1
31  2016    12332   1
32  2016    4343545 2
32  2016    865434  3
33  2016    8775    3
34  2016    8787    4
30  2017    64555   1
31  2017    945495  1
32  2017     >9539< 2
33  2017    >954<   3
34  2017    8787    4
34  2017    >94596< 7
> < values unknown at the time, to be predicted

USD is the target variable. Year 2015, 2016 have full information with regards to USD. In 2017, the groups with > < values cannot be known in advance, however a few group (in the whole dataset) have known information for 2017. The goal is to get aggregated USD predictions per week for 2017.

How would one go about using a linear regression (lm) to predict the 'missing' values in 2017, while incorporating the available 2017 data into the predictions of the missing values? The available 2017 groups make up about 70% of the USD amount, so I cannot just ignore the available data. I have no problem getting predictions without taking into account Group and just aggregate on the weeks, but that seems to make the predictions wildly inaccurate . Another approach I took was to remove the 2017 available groups from 2015 and 2016 and just use the rest to predict the unknown 2017 values, and then add the known 2017 values to the predicted 2017 yhat values. To make things more complicated, 2017 has 'new' groups, so using it as a variable is a problem to predict. I wish I wouldn't have to use linear regression for this, but alas.

model<- lm(Usd ~ week + year, data= df)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.