# loglikCovid: Computing the log-likelihood of the covid model In RcmdrPlugin.RiskDemo: R Commander Plug-in for Risk Demonstration

## Description

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.

## Usage

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

## Arguments

 `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.

## Details

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) - a, 0.1)/exp(xi)^2, where xi 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.

## Value

 `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 t. The first array index is for time. `Q` Covariance matrix of the error vector of the state equation

## Author(s)

Arto Luoma <arto.luoma@wippies.com>

## References

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

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