I have data from 2016 to 2021, I used multiple regression model lm()
to achieve that.
What I like to have is continuing the trend to 2022 in a different line type and colour
I used prophet but the equation it uses is different from the model thus the results are different and will affect the assignment the question is there another way to complete the trend line putting in mind the equation of the model? `
ggplot(data=df, mapping = aes(x=Date)) +
geom_line(mapping= aes(y=observed,
color='ObservedCases'))+
geom_point(mapping= aes(y=observed,
color='ObservedCases')) +
geom_line(mapping=aes(y=predicted,
color='PredictedCases'), size=1) +
geom_point(mapping=aes(y=predicted,
color='PredictedCases'), size=1) +
scale_x_date('Time',date_breaks='1 year',
date_labels="%Y") +
labs(y='Number of Cases', colour='Trend Lines')
#Sample of data
df <- data.frame(
Date = structure(c(16801, 16832, 16861, 16892, 16922, 16953), class = "Date"),
observed = c(1793, 2708, 1834, 1015, 1195, 809),
predicted = c(3946.87980311387, 2603.21225568186, 1582.70357908881, 2788.41468480798, 862.923305922486, 268.345471468495))