# Chapter 6 Univariate state-space models

This chapter will show you how to fit some basic univariate state-space models using the MARSS package, the StructTS() function, and JAGS code. This chapter will also introduce you to the idea of writing AR(1) models in state-space form.

A script with all the R code in the chapter can be downloaded here. The Rmd for this chapter can be downloaded here.

### Data and packages

All the data used in the chapter are in the MARSS package. The other required packages are stats (normally loaded by default when starting R), datasets and forecast. Install the packages, if needed, and load:

library(stats)
library(datasets)