Hello, I want to make projection of cases using the incidence package. the follow is the code.
new_i<-incidence(Choleradata$date, interval ="day")
plot(new_i)
# step 2 # fit a model, over a given period of time
fit(new_i) # creates fit for entire period
plot(new_i)%>% add_incidence_fit(fit(new_i)) ## plot with fit added
plot(new_i)%>% add_incidence_fit(fit_optim_split(new_i)$fit)## splits it into tow time frames
## looking at the recent 3 weeks period
duration2<-new_i$timespan# how long is the data for
fit_recent<-fit(new_i[(duration2-21):duration2]) ## create a fit for last 3 weeks.
at first the code was working after month it stop working.
the first code line is producing the error messages
Error in incidence() : x
must be a data frame.
yet the data is in data frame.
I have no ideal what is happening, any one to help.
the following the data frame I was work on.
structure(list(date = structure(c(1666742400, 1666742400, 1666915200,
1666915200, 1666915200, 1666915200, 1666915200, 1667001600, 1667001600,
1667001600, 1667001600, 1667260800, 1667260800, 1667260800, 1667260800,
1667347200, 1667347200, 1667433600, 1667433600, 1667433600, 1667433600,
1667433600, 1667520000, 1667520000, 1667520000, 1667520000, 1667952000,
1668038400, 1668038400, 1668038400, 1668038400, 1668038400, 1668124800,
1668124800, 1668124800, 1668124800, 1668124800, 1668124800, 1668211200,
1668211200, 1668211200, 1668211200, 1668211200, 1668211200, 1668211200,
1668211200, 1668211200, 1668211200, 1668211200, 1668211200, 1668211200,
1668211200, 1668211200, 1668297600, 1668297600, 1668297600, 1668297600,
1668297600, 1668384000, 1668384000, 1668384000, 1668384000, 1668384000,
1668470400, 1668556800, 1668643200, 1668643200, 1668643200, 1668643200,
1668643200, 1668816000, 1668816000, 1669248000, 1669248000, 1669507200,
1669766400, 1669766400, 1669766400, 1669852800, 1669852800, 1669939200,
1670112000, 1670112000, 1670112000, 1670198400, 1670198400, 1670284800,
1673222400, 1673395200, 1674259200, 1674864000, 1714435200, 1714435200
), class = c("POSIXct", "POSIXt"), tzone = "UTC"), district = c("chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa", "chitipa", "chitipa", "chitipa", "chitipa",
"chitipa", "chitipa")), class = "data.frame", row.names = c(NA,
93L))