BACKGROUND
certain infectious diseases and disease events occur in a cyclic or rhythmic pattern related to climate or other factors that allows for modeling and prediction of future outbreaks.
by understanding when a future outbreak may occur, preventative steps can be taken to minimize its impact.
examples of such preventive steps include vector control, public health messaging to avoid high-risk behaviors or areas, and raising clinician awareness for early diagnosis and treatment.
for such prevention to take place, timely and accurate prediction of outbreaks is critical.
more than two thirds of emerging infectious diseases in recent decades are zoonotic in origin   <cit> .
an example is the recent emergence of highly pathogenic avian influenza.
therefore, an important application of new, improved predictive models should be related to the emergence of zoonotic disease outbreaks in animals that could constitute health risk to nearby human populations.
h5n <dig> was first detected in poultry populations in egypt in february of  <dig> and was shortly afterward found in  <dig> governorates around the country.
outbreaks of h5n <dig> among small farming operations have remained prevalent over time, despite control measures  <cit> .
these outbreaks have caused the death of millions of birds due to illness or due to culling to prevent further spread of the disease.
in addition to bird cases,  <dig> humans in egypt have been confirmed as infected with h5n <dig> as of august,  <dig>  and  <dig> of those cases resulted in death due to the disease  <cit> .
along with being a menace to human health, the continued presence of the pathogen in egypt impacts the country’s protein sources, farmer’s livelihoods, the economy as a whole.
furthermore, continued transmission of the pathogen between birds  to humans has the potential to drive virus evolution with the possibility of increased virulence, and human-to-human transmission.
these events may increase the likelihood global pandemic among humans  <cit> .
in egypt, it has been reported that h5n <dig> outbreaks in bird populations occur in close temporal proximity to human h5n <dig> cases, with human cases generally occurring within  <dig> days of an initial bird outbreak.
it has also been reported that daily temperature could affect the risk of disease transmission  <cit> .
as a result, by tracking and predicting the number of bird outbreaks we hope to predict increases in risk for the zoonotic  transmission of the virus.
therefore, development of better prediction models for avian influenza outbreaks in egypt could aid efforts to control and prevent disease in both birds and humans.
for diseases that occur in cyclic or repeating patterns, time series models have been used to predict future outbreaks.
traditionally, time series predictions are performed using the autoregressive integrated moving average  models, which attempt to filter out high-frequency noise in the data to detect local trends based on linear dependence in observations in the series.
these models have two distinct advantages.
first, they can be easily interpreted in retrospective studies.
like ordinary least-square regressions the relationship between the independent variables and the dependent variables are easily understood based on the assumptions of the model.
this allows a user to understand not only the relationship between the current state as a function of the past states, commonly referred to as endogenous variables, but also the influence of inputs outside the state of the series, also called exogenous variables.
the second advantage of arima models is that model selection can be performed over a time series in an automated fashion to maximize prediction accuracy.
for some systems the relationships governing dynamic behavior change over time.
as a result, prediction parameters in the model must be recalibrated to accurately predict future observations in the face of these changing relationships.
the arima model accommodates these dynamic relationships, updating the model based on recent events to predict the future state of the system.
the arima model was originally conceived for economics applications but has seen widespread use in the area of infectious disease for a number of different time varying events.
these include leptospirosis and its relationship to rainfall and temperature  <cit> , the role of el niño southern oscillation  climate events on malaria case incidence  <cit> , and the relationship between changes in national alcohol policies and suicide incidence  <cit> .
arima models have also been used in a number of influenza studies.
these studies include associating climatological factors with influenza outbreaks in two different climates  <cit> , and to compare all-cause mortality with influenza epidemics  <cit> .
surprisingly, for reasons that are not clear, they have not previously been applied to challenge of predicting recurrent avian influenza outbreaks in poultry.
although it has become a standard tool for time series, the arima model does suffer from two drawbacks.
first, it assumes linear relationships between independent and dependent variables.
real-world relationships are often non-linear and therefore more complex than the assumptions built into the model.
as a result the arima model often does not perform well where data has structure but the structure is complex.
second, the arima model assumes a constant standard deviation in errors in the model over time.
this assumption can be removed when the arima is used in conjunction with a generalized autoregressive conditional heteroskedasticity  model  <cit> , which attempts to characterize a model’s heteroskedasticity or non-constant standard deviations in a time series.
however, the garch model comes with its own challenges and optimizing the garch model parameters for a time series can be problematic.
more recently a new class of regression models have been developed to address the challenges associated with the classic models.
this paper makes use of random forest regression  <cit> , which starts by creating decision trees.
decision trees recursively partition data in the regression space until the amount of variation in the subspace is small.
a predictor for the subspace can then be created simply by taking the average value of the dependent data corresponding to the independent data in the subspace.
the recursive partitioning step can be visualized as a tree; hence the name.
predictions for new data are obtained by finding the predictor corresponding the partition where the new input variable resides.
the partition process for random forest is greedy and, as a result, does not generally converge to the globally optimal tree.
to compensate for this a collection or ensemble of locally optimal trees, each tree is generated by sampling uniformly at random from the original subset, a procedure termed bagging.
furthermore, after creating the resampled version of the data set, all but a small number of features are sampled.
with the sampling procedure complete a new tree is trained.
the collection or ensemble of trees is termed a forest.
predictions can then be made based on an aggregate of the individual predictions made by each of the trees, a procedure termed “voting”.
an aggregate prediction obtains better accuracy than any of the constituent trees.
random forests in particular and the multiple-predictor approach in general, also referred to as ensemble methods, tend to be the most accurate classification and regression tools currently at the disposal of data scientists  <cit> .
while random forest models often provide superior prediction accuracy, they are often challenging to interpret, with  <cit>  referring to to “algorithmic models”, including random forests as a “black box”.
for random forests specifically, each of the constituent trees trains on a potentially non-linear regression space and is then combined with others.
as a result they do not encode the simple and easy-to-understand results provided by classical linear models.
diagnostics for random forests models tend to focus on variable importance.
this technique removes regressor variables from an ensemble and measures the effect on prediction accuracy.
this approach provides a functional measure of the influence that each variable has on accuracy without providing an interpretable measure of how the variable helps to determine the prediction.
the random forest approach has been used in a number of public health studies such as to predict deer mouse population dynamics  <cit>  and the effect of seasonality on wastewater quality  <cit> .
in the area of predicting avian influenza, random forests have been successfully applied to spatial challenges such as  <cit> , which provides the first global-scale model of low-pathogenicity avian influenza in wild birds.
as with the arima model though, this approach has not been applied to time-series data for predicting avian influenza outbreaks.
in this paper, we compared the performance of an arima model with the random forest model in the prediction of outbreaks of avian influenza h5n <dig> in egypt over the period of 2005– <dig> in order to identify optimal qualities of a prediction model for use by public health and agricultural agencies in the control and prevention of future outbreaks in poultry.
methods
weather and bird outbreak data acquisition
avian influenza outbreak data were obtained from the online empres-i global animal disease information system  <cit> .
empres records contain verified reports of viral infection in animal populations including data on avian influenza h5n <dig>  individual cases of h5n <dig> are confirmed by the food and agricultural organization of the united nations.
for this study, an “outbreak” is defined by at least a single, confirmed case of h5n <dig> in a domestic bird  at a given location.
it should be noted that this means an outbreak at a large facility has the same significance or weight as a case at a small one.
this decision was justified for two reasons.
first, while the confirmation of a case of avian influenza is carefully recorded the total number of cases at a location is not.
for some locations, the number of cases was the same for multiple outbreaks indicating either that the same number of birds were confirmed to have h5n <dig> or there was a recording error.
as a result, the data may do not reflect the actual number of cases at a given location.
second, in egypt, birds are often cultivated in small, unregulated farms and enclosures.
it is conceivable, if not likely, that outbreaks at these small facilities are underreported.
by defining an outbreak as at least a single, confirmed case our analysis is not sensitive to case-count discrepancies presented by the first challenge.
at the same time, we are placing more emphasis on underreported facilities thereby addressing the second challenge.
the new “outbreak” variable was constructed from the empress data and is used throughout this study.
daily temperature and relative humidity data were obtained from the weather underground  <cit> .
the site provides publicly available historical data from weather stations around the world.
we identified weather stations located in each governorate in egypt with avian influenza cases that had consistent daily readings, from 2005-12- <dig> to the 2012-10- <dig>
the data were merged into a single set with variables corresponding to date of the beginning of a week, number of bird outbreaks, average temperature for all governorates, and humidity.
retrospective arima and random forest model
a retrospective analysis was performed on the data using both an arima model as well as a random forests.
in both cases the entire data set, and all associated variables were used to train the model.
the arima model was selected using the forecast package  <cit> , which is available for the r programming environment  <cit> .
model selection was automated, using the auto.arima function, which performs a stepwise regression on the data and selects the best model based on the bayesian inference criteria .
the order of the autoregressive, integral, and moving average parameters of the model were limited to five or less to make the computation tractable.
the random forest model was created using the randomforest package  <cit> , also available for the r programming environment.
as with the arima model, all variables were included and time lags of up to five steps were trained.
the random forests model used  <dig> trees, sampling all rows of the data set with replacement, and sampling  <dig> variables at random in each of the trees.
the importance of each variable was then calculated by finding how much of a reduction each variable provides when added to the model.
simulated prospective arima and random forest model
the retrospective analysis establishes the relationships between outbreaks and the regressor variables for  <dig> to the present.
however, it is well known that models based on retrospective relationships do not always imply good predictive models.
to investigate the predictive power of the arima and the random forest models, a simulated prospective analysis was performed.
the simulation begins by using data from the last  <dig> weeks of data from  <dig> to predict the outbreak for the week of  <dig> .
the simulation proceeds by iteratively adding a new week of data, training a new model based on the updated data, and predicting the number of outbreaks for the following week.
the procedure for creating the arima and random forest model was otherwise the same as in the retrospective analysis.
validating the prospective random forest model
the results from the simulated prospective analyses showed that the random forest model is a more accurate predictor of future outbreaks, in terms of mean square error.
two procedures were used to show that the random forest model additionally provides predictive power, thereby validating the model.
first, a confusion matrix was constructed with summarizing the model ability to predict upticks and downticks for each week.
a test was then constructed to see if the predicted upticks happen at the same rate as if up and downticks were random distributed with the same probability as the proportion of up and downticks in the actual outbreaks.
this test verifies that the random forest model can predict the direction of change in actual outbreak.
to show that the magnitudes of the predictions predict actual outbreak magnitude, the predictions were examined graphically and a quantile plot was constructed to better understand the distribution of the residuals.
RESULTS
retrospective arima
table  <dig> shows the summary of the retrospective arima model.
using the optimization described earlier, the autoregressive component of the model was of order  <dig>  the integrated portion of the model was of order zero, and the moving average component was of order  <dig>  the table also includes the p-values for the coefficients using the standard t-test.
the variance of the residuals was  <dig> .
it should be noted that the effect of temperature and humidity were studied similarly but did not yield significant results.
temperature and humidity each had a small  negative effect when added to the model both individually and together.
figures  <dig> and  <dig> give graphical representation of the retrospective arima and random forests model.
the figures show that there tend to be sharp increases in outbreak frequency in the winter months and that the residuals corresponding to these drastic upticks tend to be larger.
furthermore, 2010– <dig> tended to have higher outbreak counts along with more drastic up and downticks through the entire period.
the corresponding residuals over this period tend to be larger.table  <dig>
summary of the retrospective arima model
the retrospective predictions.
the retrospective predictions for the arima model and the random forest model along with the actual outbreak counts.
the retrospective residuals.
the retrospective residuals for the arima and random forest model.
retrospective random forest
table  <dig> shows the variable importance for each of the regressors in the random forest model as defined in  <cit> .
figures  <dig> and  <dig> also show the performance for the retrospective random forest model.
as in the case of the arima, the random forest model has trouble predicting sharp increases and decreases in outbreaks and has more trouble predicting the time series over the volatile period of 2010– <dig>  however, the overall variance for the retrospective random forest model is considerable smaller with a mean square error of  <dig>  compared to  <dig>  for the arima model.table  <dig>
retrospective random forest variable importance
prospective arima and random forest
figures  <dig> and  <dig> and show the performance of the prospective arima and random forests models respectively.
as with the retrospective models, the high frequency shocks that correspond to steep increases in outbreak near the beginning of the year are difficult to predict.
the period of 2010– <dig> is associated with higher volatility in the residuals.
as in the retrospective case, the predictive arima makes predictions less than zero.
the simulated prospective models also do not tend to make predictions for large magnitude changes.
finally, the random forest model’s mse, at  <dig>  is smaller than the arima’s simulated prospective mse  as well as the retrospective arima’s mse .figure  <dig>
the simulated prospective predictions.
the simulated prospective predictions for the arima model and the random forest model along with the actual outbreak counts.
the simulated prospective residuals.
the simulated prospective residuals for the arima and random forest model.
comparing the mse of the models
table  <dig> shows the mean square error of the residuals for each of the four models for the prediction period of 2007-01- <dig> to 2012-10- <dig>  the retrospective models perform better than their simulated prospective counter parts and the random forest simulated prospective model outperforms both the retrospective and simulated prospective arima model.table  <dig>
comparing the mse of the models
validating the prospective random forest model
the prospective random forest model outperforms the arima over the specified time period, measured by means square error.
however, this fact alone does not guarantee that the random forest model is able to anticipate upticks or downticks in outbreak.
to show that it does have this capability, a confusion matrix was created that shows the proportions of predicted increases and decreases in outbreak with actual increases and decreases in outbreak.
from the data we know that the proportion of actual increases was  <dig>  and the proportion of predicted increases was  <dig> .
if we assume that, as a null hypothesis, that the predicted and actual increases and decreases happen independently of each other, then under the null we would have the confusion matrix shown in table  <dig> table  <dig>
the confusion matrix under the null
actual
a χ <dig> test was performed to find the probability that the confusion matrix in table  <dig> could be generated under the null in table  <dig> and the result was numerically zero.
we can therefore conclude that the prospective random forest model has the ability to predict increases and decreases in outbreaks.
figure  <dig> shows the actual and predicted changes in outbreak for each day of the simulated prospective study.
points in the first and third quadrant correspond to cases where the direction of a prediction coincided with the actual outbreak change.
points near the diagonal red line correspond to predictions that were accurate.
figure  <dig> shows the normal quantile plot of the residuals between the predicted and actual changes.
the plot is roughly linear from - <dig> to approximately  <dig> , corresponding to a normal distribution.
from  <dig>  to  <dig> the plot curves upward, corresponding to the steep increases in outbreaks that were not well predicted.
based on this information we can surmise that the noise process is skewed right.table  <dig>
simulated prospective random forest confusion matrix
actualthe actual and predicted changes for the random forest model.
the actual and predicted changes in outbreak for each day of the simulated prospective study using the random forest model.
quantile plot of the residuals for the simulated prospective analysis using random forests.
the normal quantile plot of the differences between the predicted changes and the actual changes using the random forest model.
discussion
these analyses indicate that the random forest model has advantages over the arima approach to time series modeling of avian influenza outbreaks in poultry in egypt.
at the same time, it clear that both retrospective models have deficiencies when trying to fit the time series of outbreaks.
for example, the arima model provides some estimates that are actually less than zero, which is impossible given the nature of outbreaks.
furthermore, there are times, like the end of  <dig> where the model is consistently biased with respect to the signal.
the random forest model is also consistently biased at the end of  <dig>  as well as the middle of  <dig>  however, it performs an order of magnitude better than arima in terms of mean square error.
these periods where both retrospective models are biased in their predictions may indicate that the distribution of the noise process is itself changing over the course of the almost five years that were examined.
there are many possible factors that could influence the distribution such as changes in the data collection procedure, changes in regulation related to the handling of outbreaks, or changes in disease dynamics.
however, this clearly needs to be taken into account when proposing a predictive model.
the choice to use 25-week windows when performing predictions was an effective means for handling distribution changes in the prospective setting.
assuming that the distribution changes occur slowly over time allows us to assume quasi-stationarity of the process and the models can be trained to filter out this type of noise much more easily.
as a result of this windowing procedure the prospective arima’s performance is competitive with the retrospective arima.
the prospective random forest model performed better than both arima models making it the best choice for-out-of sample prediction.
the prospective random forest model likely outperformed the prospective arima model for two distinct reasons.
first, the relationship between the lagged outbreaks and the predicted outbreak may not be linear.
from table  <dig>  where the importance for each of the variable used by the random forest model is shown we know that the  <dig> week lagged outbreak is one of the most important variables used by the model to predict outbreaks.
however no corresponding term appears in the arima model, which assumes linear relationships between the predicted outbreak and lagged outbreak values.
the arima’s inability to incorporate non-linear relationships may have contributed to poorer performance.
second, from figure  <dig> we know that upward shocks in outbreak are not well predicted and, as a result, the noise process of the time series is not normal, which is one of the basic assumptions made by the arima model.
this fact may have also contributed to poorer performance.
CONCLUSIONS
the random forest approach offers advantages over the arima approach for prediction of h5n <dig> avian outbreaks in birds in egypt.
further research is warranted to explore the utility of such novel time series models in other settings, including as part of a concerted effort by agricultural and public health agencies to control and prevent this disease.
competing interests
the authors declare that they have no competing interests.
authors’ contributions
mjk conceived, designed, and implemented the comparison between the two models.
np collected weather data from the weather underground and the empres-i web pages.
ms and pr helped to shape in the conceptual development of the study, and evaluate the results.
all authors contributed to the writing of the manuscript.
all authors read and approved the final manuscript.

 certain infectious diseases and disease events occur in a cyclic or rhythmic pattern related to climate or other factors that allows for modeling and prediction of future outbreaks. by understanding when a future outbreak may occur, preventative steps can be taken to minimize its impact. examples of such preventive steps include vector control, public health messaging to avoid high-risk behaviors or areas, and raising clinician awareness for early diagnosis and treatment. for such prevention to take place, timely and accurate prediction of outbreaks is critical. more than two thirds of emerging infectious diseases in recent decades are zoonotic in origin. an example is the recent emergence of highly pathogenic avian influenza. therefore, an important application of new, improved predictive models should be related to the emergence of zoonotic disease outbreaks in animals that could constitute health risk to nearby human populations. h5n was first detected in poultry populations in egypt in february of and was shortly afterward found in governorates around the country. outbreaks of h5n among small farming operations have remained prevalent over time, despite control measures. these outbreaks have caused the death of millions of birds due to illness or due to culling to prevent further spread of the disease. in addition to bird cases, humans in egypt have been confirmed as infected with h5n as of august, and of those cases resulted in death due to the disease. along with being a menace to human health, the continued presence of the pathogen in egypt impacts the country’s protein sources, farmer’s livelihoods, the economy as a whole. furthermore, continued transmission of the pathogen between birds to humans has the potential to drive virus evolution with the possibility of increased virulence, and human-to-human transmission. these events may increase the likelihood global pandemic among humans. in egypt, it has been reported that h5n outbreaks in bird populations occur in close temporal proximity to human h5n cases, with human cases generally occurring within days of an initial bird outbreak. it has also been reported that daily temperature could affect the risk of disease transmission. as a result, by tracking and predicting the number of bird outbreaks we hope to predict increases in risk for the zoonotic transmission of the virus. therefore, development of better prediction models for avian influenza outbreaks in egypt could aid efforts to control and prevent disease in both birds and humans. for diseases that occur in cyclic or repeating patterns, time series models have been used to predict future outbreaks. traditionally, time series predictions are performed using the autoregressive integrated moving average models, which attempt to filter out high-frequency noise in the data to detect local trends based on linear dependence in observations in the series. these models have two distinct advantages. first, they can be easily interpreted in retrospective studies. like ordinary least-square regressions the relationship between the independent variables and the dependent variables are easily understood based on the assumptions of the model. this allows a user to understand not only the relationship between the current state as a function of the past states, commonly referred to as endogenous variables, but also the influence of inputs outside the state of the series, also called exogenous variables. the second advantage of arima models is that model selection can be performed over a time series in an automated fashion to maximize prediction accuracy. for some systems the relationships governing dynamic behavior change over time. as a result, prediction parameters in the model must be recalibrated to accurately predict future observations in the face of these changing relationships. the arima model accommodates these dynamic relationships, updating the model based on recent events to predict the future state of the system. the arima model was originally conceived for economics applications but has seen widespread use in the area of infectious disease for a number of different time varying events. these include leptospirosis and its relationship to rainfall and temperature, the role of el niño southern oscillation climate events on malaria case incidence, and the relationship between changes in national alcohol policies and suicide incidence. arima models have also been used in a number of influenza studies. these studies include associating climatological factors with influenza outbreaks in two different climates, and to compare all-cause mortality with influenza epidemics. surprisingly, for reasons that are not clear, they have not previously been applied to challenge of predicting recurrent avian influenza outbreaks in poultry. although it has become a standard tool for time series, the arima model does suffer from two drawbacks. first, it assumes linear relationships between independent and dependent variables. real-world relationships are often non-linear and therefore more complex than the assumptions built into the model. as a result the arima model often does not perform well where data has structure but the structure is complex. second, the arima model assumes a constant standard deviation in errors in the model over time. this assumption can be removed when the arima is used in conjunction with a generalized autoregressive conditional heteroskedasticity model, which attempts to characterize a model’s heteroskedasticity or non-constant standard deviations in a time series. however, the garch model comes with its own challenges and optimizing the garch model parameters for a time series can be problematic. more recently a new class of regression models have been developed to address the challenges associated with the classic models. this paper makes use of random forest regression, which starts by creating decision trees. decision trees recursively partition data in the regression space until the amount of variation in the subspace is small. a predictor for the subspace can then be created simply by taking the average value of the dependent data corresponding to the independent data in the subspace. the recursive partitioning step can be visualized as a tree; hence the name. predictions for new data are obtained by finding the predictor corresponding the partition where the new input variable resides. the partition process for random forest is greedy and, as a result, does not generally converge to the globally optimal tree. to compensate for this a collection or ensemble of locally optimal trees, each tree is generated by sampling uniformly at random from the original subset, a procedure termed bagging. furthermore, after creating the resampled version of the data set, all but a small number of features are sampled. with the sampling procedure complete a new tree is trained. the collection or ensemble of trees is termed a forest. predictions can then be made based on an aggregate of the individual predictions made by each of the trees, a procedure termed “voting”. an aggregate prediction obtains better accuracy than any of the constituent trees. random forests in particular and the multiple-predictor approach in general, also referred to as ensemble methods, tend to be the most accurate classification and regression tools currently at the disposal of data scientists. while random forest models often provide superior prediction accuracy, they are often challenging to interpret, with referring to to “algorithmic models”, including random forests as a “black box”. for random forests specifically, each of the constituent trees trains on a potentially non-linear regression space and is then combined with others. as a result they do not encode the simple and easy-to-understand results provided by classical linear models. diagnostics for random forests models tend to focus on variable importance. this technique removes regressor variables from an ensemble and measures the effect on prediction accuracy. this approach provides a functional measure of the influence that each variable has on accuracy without providing an interpretable measure of how the variable helps to determine the prediction. the random forest approach has been used in a number of public health studies such as to predict deer mouse population dynamics and the effect of seasonality on wastewater quality. in the area of predicting avian influenza, random forests have been successfully applied to spatial challenges such as, which provides the first global-scale model of low-pathogenicity avian influenza in wild birds. as with the arima model though, this approach has not been applied to time-series data for predicting avian influenza outbreaks. in this paper, we compared the performance of an arima model with the random forest model in the prediction of outbreaks of avian influenza h5n in egypt over the period of 2005– in order to identify optimal qualities of a prediction model for use by public health and agricultural agencies in the control and prevention of future outbreaks in poultry. methods weather and bird outbreak data acquisition avian influenza outbreak data were obtained from the online empres-i global animal disease information system. empres records contain verified reports of viral infection in animal populations including data on avian influenza h5n individual cases of h5n are confirmed by the food and agricultural organization of the united nations. for this study, an “outbreak” is defined by at least a single, confirmed case of h5n in a domestic bird at a given location. it should be noted that this means an outbreak at a large facility has the same significance or weight as a case at a small one. this decision was justified for two reasons. first, while the confirmation of a case of avian influenza is carefully recorded the total number of cases at a location is not. for some locations, the number of cases was the same for multiple outbreaks indicating either that the same number of birds were confirmed to have h5n or there was a recording error. as a result, the data may do not reflect the actual number of cases at a given location. second, in egypt, birds are often cultivated in small, unregulated farms and enclosures. it is conceivable, if not likely, that outbreaks at these small facilities are underreported. by defining an outbreak as at least a single, confirmed case our analysis is not sensitive to case-count discrepancies presented by the first challenge. at the same time, we are placing more emphasis on underreported facilities thereby addressing the second challenge. the new “outbreak” variable was constructed from the empress data and is used throughout this study. daily temperature and relative humidity data were obtained from the weather underground. the site provides publicly available historical data from weather stations around the world. we identified weather stations located in each governorate in egypt with avian influenza cases that had consistent daily readings, from 2005-12- to the 2012-10- the data were merged into a single set with variables corresponding to date of the beginning of a week, number of bird outbreaks, average temperature for all governorates, and humidity. retrospective arima and random forest model a retrospective analysis was performed on the data using both an arima model as well as a random forests. in both cases the entire data set, and all associated variables were used to train the model. the arima model was selected using the forecast package, which is available for the r programming environment. model selection was automated, using the auto.arima function, which performs a stepwise regression on the data and selects the best model based on the bayesian inference criteria. the order of the autoregressive, integral, and moving average parameters of the model were limited to five or less to make the computation tractable. the random forest model was created using the randomforest package, also available for the r programming environment. as with the arima model, all variables were included and time lags of up to five steps were trained. the random forests model used trees, sampling all rows of the data set with replacement, and sampling variables at random in each of the trees. the importance of each variable was then calculated by finding how much of a reduction each variable provides when added to the model. simulated prospective arima and random forest model the retrospective analysis establishes the relationships between outbreaks and the regressor variables for to the present. however, it is well known that models based on retrospective relationships do not always imply good predictive models. to investigate the predictive power of the arima and the random forest models, a simulated prospective analysis was performed. the simulation begins by using data from the last weeks of data from to predict the outbreak for the week of. the simulation proceeds by iteratively adding a new week of data, training a new model based on the updated data, and predicting the number of outbreaks for the following week. the procedure for creating the arima and random forest model was otherwise the same as in the retrospective analysis. validating the prospective random forest model the results from the simulated prospective analyses showed that the random forest model is a more accurate predictor of future outbreaks, in terms of mean square error. two procedures were used to show that the random forest model additionally provides predictive power, thereby validating the model. first, a confusion matrix was constructed with summarizing the model ability to predict upticks and downticks for each week. a test was then constructed to see if the predicted upticks happen at the same rate as if up and downticks were random distributed with the same probability as the proportion of up and downticks in the actual outbreaks. this test verifies that the random forest model can predict the direction of change in actual outbreak. to show that the magnitudes of the predictions predict actual outbreak magnitude, the predictions were examined graphically and a quantile plot was constructed to better understand the distribution of the residuals.  retrospective arima table  shows the summary of the retrospective arima model. using the optimization described earlier, the autoregressive component of the model was of order the integrated portion of the model was of order zero, and the moving average component was of order the table also includes the p-values for the coefficients using the standard t-test. the variance of the residuals was. it should be noted that the effect of temperature and humidity were studied similarly but did not yield significant results. temperature and humidity each had a small negative effect when added to the model both individually and together. figures  and give graphical representation of the retrospective arima and random forests model. the figures show that there tend to be sharp increases in outbreak frequency in the winter months and that the residuals corresponding to these drastic upticks tend to be larger. furthermore, 2010– tended to have higher outbreak counts along with more drastic up and downticks through the entire period. the corresponding residuals over this period tend to be larger.table summary of the retrospective arima model the retrospective predictions. the retrospective predictions for the arima model and the random forest model along with the actual outbreak counts. the retrospective residuals. the retrospective residuals for the arima and random forest model. retrospective random forest table  shows the variable importance for each of the regressors in the random forest model as defined in. figures  and also show the performance for the retrospective random forest model. as in the case of the arima, the random forest model has trouble predicting sharp increases and decreases in outbreaks and has more trouble predicting the time series over the volatile period of 2010– however, the overall variance for the retrospective random forest model is considerable smaller with a mean square error of compared to for the arima model.table retrospective random forest variable importance prospective arima and random forest figures  and and show the performance of the prospective arima and random forests models respectively. as with the retrospective models, the high frequency shocks that correspond to steep increases in outbreak near the beginning of the year are difficult to predict. the period of 2010– is associated with higher volatility in the residuals. as in the retrospective case, the predictive arima makes predictions less than zero. the simulated prospective models also do not tend to make predictions for large magnitude changes. finally, the random forest model’s mse, at is smaller than the arima’s simulated prospective mse as well as the retrospective arima’s mse.figure the simulated prospective predictions. the simulated prospective predictions for the arima model and the random forest model along with the actual outbreak counts. the simulated prospective residuals. the simulated prospective residuals for the arima and random forest model. comparing the mse of the models table  shows the mean square error of the residuals for each of the four models for the prediction period of 2007-01- to 2012-10- the retrospective models perform better than their simulated prospective counter parts and the random forest simulated prospective model outperforms both the retrospective and simulated prospective arima model.table comparing the mse of the models validating the prospective random forest model the prospective random forest model outperforms the arima over the specified time period, measured by means square error. however, this fact alone does not guarantee that the random forest model is able to anticipate upticks or downticks in outbreak. to show that it does have this capability, a confusion matrix was created that shows the proportions of predicted increases and decreases in outbreak with actual increases and decreases in outbreak. from the data we know that the proportion of actual increases was and the proportion of predicted increases was. if we assume that, as a null hypothesis, that the predicted and actual increases and decreases happen independently of each other, then under the null we would have the confusion matrix shown in table  table the confusion matrix under the null actual a χ test was performed to find the probability that the confusion matrix in table  could be generated under the null in table  and the result was numerically zero. we can therefore conclude that the prospective random forest model has the ability to predict increases and decreases in outbreaks. figure  shows the actual and predicted changes in outbreak for each day of the simulated prospective study. points in the first and third quadrant correspond to cases where the direction of a prediction coincided with the actual outbreak change. points near the diagonal red line correspond to predictions that were accurate. figure  shows the normal quantile plot of the residuals between the predicted and actual changes. the plot is roughly linear from - to approximately, corresponding to a normal distribution. from to the plot curves upward, corresponding to the steep increases in outbreaks that were not well predicted. based on this information we can surmise that the noise process is skewed right.table simulated prospective random forest confusion matrix actualthe actual and predicted changes for the random forest model. the actual and predicted changes in outbreak for each day of the simulated prospective study using the random forest model. quantile plot of the residuals for the simulated prospective analysis using random forests. the normal quantile plot of the differences between the predicted changes and the actual changes using the random forest model. discussion these analyses indicate that the random forest model has advantages over the arima approach to time series modeling of avian influenza outbreaks in poultry in egypt. at the same time, it clear that both retrospective models have deficiencies when trying to fit the time series of outbreaks. for example, the arima model provides some estimates that are actually less than zero, which is impossible given the nature of outbreaks. furthermore, there are times, like the end of where the model is consistently biased with respect to the signal. the random forest model is also consistently biased at the end of as well as the middle of however, it performs an order of magnitude better than arima in terms of mean square error. these periods where both retrospective models are biased in their predictions may indicate that the distribution of the noise process is itself changing over the course of the almost five years that were examined. there are many possible factors that could influence the distribution such as changes in the data collection procedure, changes in regulation related to the handling of outbreaks, or changes in disease dynamics. however, this clearly needs to be taken into account when proposing a predictive model. the choice to use 25-week windows when performing predictions was an effective means for handling distribution changes in the prospective setting. assuming that the distribution changes occur slowly over time allows us to assume quasi-stationarity of the process and the models can be trained to filter out this type of noise much more easily. as a result of this windowing procedure the prospective arima’s performance is competitive with the retrospective arima. the prospective random forest model performed better than both arima models making it the best choice for-out-of sample prediction. the prospective random forest model likely outperformed the prospective arima model for two distinct reasons. first, the relationship between the lagged outbreaks and the predicted outbreak may not be linear. from table  where the importance for each of the variable used by the random forest model is shown we know that the week lagged outbreak is one of the most important variables used by the model to predict outbreaks. however no corresponding term appears in the arima model, which assumes linear relationships between the predicted outbreak and lagged outbreak values. the arima’s inability to incorporate non-linear relationships may have contributed to poorer performance. second, from figure  we know that upward shocks in outbreak are not well predicted and, as a result, the noise process of the time series is not normal, which is one of the basic assumptions made by the arima model. this fact may have also contributed to poorer performance.  the random forest approach offers advantages over the arima approach for prediction of h5n avian outbreaks in birds in egypt. further research is warranted to explore the utility of such novel time series models in other settings, including as part of a concerted effort by agricultural and public health agencies to control and prevent this disease. competing interests the authors declare that they have no competing interests. authors’ contributions mjk conceived, designed, and implemented the comparison between the two models. np collected weather data from the weather underground and the empres-i web pages. ms and pr helped to shape in the conceptual development of the study, and evaluate the results. all authors contributed to the writing of the manuscript. all authors read and approved the final manuscript. 
we applied arima and random forest time series models to incidence data of outbreaks of highly pathogenic avian influenza in egypt, available through the online empres-i system. we found that the random forest model outperformed the arima model in predictive ability. furthermore, we found that the random forest model is effective for predicting outbreaks of h5n in egypt. incidence data can be used to predict the future occurrence of disease events. developments in modeling approaches provide an opportunity to compare different time series models for predictive power. this result, along with those showing the concordance between bird and human outbreaks, provides a new approach to predicting these dangerous outbreaks in bird populations based on existing, freely available data. time series models can play an important role in disease prediction. random forest time series modeling provides enhanced predictive ability over existing time series models for the prediction of infectious disease outbreaks.
 time series models can play an important role in disease prediction. incidence data can be used to predict the future occurrence of disease events. developments in modeling approaches provide an opportunity to compare different time series models for predictive power.  we applied arima and random forest time series models to incidence data of outbreaks of highly pathogenic avian influenza in egypt, available through the online empres-i system. we found that the random forest model outperformed the arima model in predictive ability. furthermore, we found that the random forest model is effective for predicting outbreaks of h5n in egypt.  random forest time series modeling provides enhanced predictive ability over existing time series models for the prediction of infectious disease outbreaks. this result, along with those showing the concordance between bird and human outbreaks, provides a new approach to predicting these dangerous outbreaks in bird populations based on existing, freely available data. our analysis uncovers the time-series structure of outbreak severity for highly pathogenic avain influenza in egypt. issue-copyright-statement© the author 2014 