loglikCovid | R Documentation |

This function computes -2 times the log-likelihood of the simple model that is used to predict new COVID-19 cases and to estimate the effective reproduction number.

```
loglikCovid(y, par, it = TRUE)
```

`y` |
Univariate numeric time series of new COVID-19 cases |

`par` |
Logarithms of the variance parameters of drift, seasonal component, and error term |

`it` |
A logical value indicating if only the log-likelihood is returned. |

Some multiplicative and additive constants are omitted when the negative log-likelihood is computed. Before computing the log-likelihood, the transformation *y=log(x+a)*, where *a=2*, is applied to the time series. The model is a simple local linear model with local level, drift and seasonal component. The variance parameters of the level and seasonal component are estimated while the variance of the level component is computed as *max(exp(xi[1]) - a, 0.1)/exp(xi[1])^2*, where *xi[1]* is the current estimate of the level. This is based on the assumption that the number of new cases is approximately Poisson distributed, so that the variance equals the level. The *max* operation is taken in order to prevent the exression from being negative. In order to facilitate estimation, a penalty term is added which corresponds to a prior of *N(-9,1)* for the logarithm of the drift variance.

`loglik` |
-2 times the penalized log likelihood apart from some additive constants |

`ll` |
Vector of the increments of the log-likelihood corresponding to individual observations |

`Xi` |
Matrix of one-step predictions of the state vector. The vectors at different time points are given as rows. |

`Xif` |
Matrix of filtered values, where the state vectors are given as rows |

`Pfmat` |
Array of state uncertainty matrices, evaluated at time |

`Q` |
Covariance matrix of the error vector of the state equation |

Arto Luoma <arto.luoma@wippies.com>

Hamilton (1994) *Time Series Analysis*, Princeton University Press, (see Chapter 13 The Kalman Filter).

`covidSmooth`

```
#See examples for covidSmooth.
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.