\\\\(
\nonumber
\newcommand{\bevisslut}{$\blacksquare$}
\newenvironment{matr}[1]{\hspace{-.8mm}\begin{bmatrix}\hspace{-1mm}\begin{array}{#1}}{\end{array}\hspace{-1mm}\end{bmatrix}\hspace{-.8mm}}
\newcommand{\transp}{\hspace{-.6mm}^{\top}}
\newcommand{\maengde}[2]{\left\lbrace \hspace{-1mm} \begin{array}{c|c} #1 & #2 \end{array} \hspace{-1mm} \right\rbrace}
\newenvironment{eqnalign}[1]{\begin{equation}\begin{array}{#1}}{\end{array}\end{equation}}
\newcommand{\eqnl}{}
\newcommand{\matind}[3]{{_\mathrm{#1}\mathbf{#2}_\mathrm{#3}}}
\newcommand{\vekind}[2]{{_\mathrm{#1}\mathbf{#2}}}
\newcommand{\jac}[2]{{\mathrm{Jacobi}_\mathbf{#1} (#2)}}
\newcommand{\diver}[2]{{\mathrm{div}\mathbf{#1} (#2)}}
\newcommand{\rot}[1]{{\mathbf{rot}\mathbf{(#1)}}}
\newcommand{\am}{\mathrm{am}}
\newcommand{\gm}{\mathrm{gm}}
\newcommand{\E}{\mathrm{E}}
\newcommand{\Span}{\mathrm{span}}
\newcommand{\mU}{\mathbf{U}}
\newcommand{\mA}{\mathbf{A}}
\newcommand{\mB}{\mathbf{B}}
\newcommand{\mC}{\mathbf{C}}
\newcommand{\mD}{\mathbf{D}}
\newcommand{\mE}{\mathbf{E}}
\newcommand{\mF}{\mathbf{F}}
\newcommand{\mK}{\mathbf{K}}
\newcommand{\mI}{\mathbf{I}}
\newcommand{\mM}{\mathbf{M}}
\newcommand{\mN}{\mathbf{N}}
\newcommand{\mQ}{\mathbf{Q}}
\newcommand{\mT}{\mathbf{T}}
\newcommand{\mV}{\mathbf{V}}
\newcommand{\mW}{\mathbf{W}}
\newcommand{\mX}{\mathbf{X}}
\newcommand{\ma}{\mathbf{a}}
\newcommand{\mb}{\mathbf{b}}
\newcommand{\mc}{\mathbf{c}}
\newcommand{\md}{\mathbf{d}}
\newcommand{\me}{\mathbf{e}}
\newcommand{\mn}{\mathbf{n}}
\newcommand{\mr}{\mathbf{r}}
\newcommand{\mv}{\mathbf{v}}
\newcommand{\mw}{\mathbf{w}}
\newcommand{\mx}{\mathbf{x}}
\newcommand{\mxb}{\mathbf{x_{bet}}}
\newcommand{\my}{\mathbf{y}}
\newcommand{\mz}{\mathbf{z}}
\newcommand{\reel}{\mathbb{R}}
\newcommand{\mL}{\bm{\Lambda}}
\newcommand{\mnul}{\mathbf{0}}
\newcommand{\trap}[1]{\mathrm{trap}(#1)}
\newcommand{\Det}{\operatorname{Det}}
\newcommand{\adj}{\operatorname{adj}}
\newcommand{\Ar}{\operatorname{Areal}}
\newcommand{\Vol}{\operatorname{Vol}}
\newcommand{\Rum}{\operatorname{Rum}}
\newcommand{\diag}{\operatorname{\bf{diag}}}
\newcommand{\bidiag}{\operatorname{\bf{bidiag}}}
\newcommand{\spanVec}[1]{\mathrm{span}{#1}}
\newcommand{\Div}{\operatorname{Div}}
\newcommand{\Rot}{\operatorname{\mathbf{Rot}}}
\newcommand{\Jac}{\operatorname{Jacobi}}
\newcommand{\Tan}{\operatorname{Tan}}
\newcommand{\Ort}{\operatorname{Ort}}
\newcommand{\Flux}{\operatorname{Flux}}
\newcommand{\Cmass}{\operatorname{Cm}}
\newcommand{\Imom}{\operatorname{Im}}
\newcommand{\Pmom}{\operatorname{Pm}}
\newcommand{\IS}{\operatorname{I}}
\newcommand{\IIS}{\operatorname{II}}
\newcommand{\IIIS}{\operatorname{III}}
\newcommand{\Le}{\operatorname{L}}
\newcommand{\app}{\operatorname{app}}
\newcommand{\M}{\operatorname{M}}
\newcommand{\re}{\mathrm{Re}}
\newcommand{\im}{\mathrm{Im}}
\newcommand{\compl}{\mathbb{C}}
\newcommand{\e}{\mathrm{e}}
\\\\)
Use the Kalman filter to make maximum likelihood estimation of parameters in a state-space model.
See the exercise_estimation1.R script to get started. You find a solution suggestion here exercise_estimation1_solution.R
In the script a simulation of the falling body, see Example 10.2 and 10.4 in the book.
The objective of the exercise is to end up with a script for maximum likelihood estimation of parameters in the model.
In the script are several tasks
Write the missing parts where the likelihood is calculated
You must insert the calculation of the likelihood. See Section 10.6 in the Book. Instead of writing the normal distribution pdf, you can use the dnorm() function in R.
End up with a calculation of the negative log-likelihood for the data and finally wrap that in the function, which can be used for parameter estimation.
Use an optimizer to estimate the B matrix
The B matrix holds the coefficients which are multiplied to the inputs (in this case the input is simply the constant g, but usually we write the input u and it is a time series which is changing). Try to estimate B.
Note, that optimizers in R take a vector with parameter to be optimized as their first argument, so the B parameter must be made back into a matrix.
Use the optim() function (read about it with ?optim) to calculate the maximum likelihood parameters.
Can B be estimated?
Try running the simulation and estimation many times to see how the estimation behaves.
Play around with estimation
In the script exercise_estimation2.R is an implementation, where you easily can estimate different parameters of the model.
Try for example:
- Estimate the process noise covariance Sigma1 matrix (or part of it)
- Estimate the observation noise Sigma2
- Calculate confidence intervals for the parameters
- Are the confidence intervals coverage (i.e. 95% CL should catch the parameter 95% of the times) correct? (simulate many times)
- Model validation should of course be carried out by analyzing the one-step prediction residuals…but not implmented yet in the script, so you can do that.