spline.prep {AHMbook} | R Documentation |

## Prepare input for BUGS model when fitting a spline for a covariate

### Description

Function chooses knots and creates design matrices for fixed and random-effects parts of a spline model for a chosen covariate. Based on code by Crainiceanu et al. (2005) and Zuur et al. (2012). Allows you to choose number of knots or else uses it by the rule given in Crainiceanu et al. (2005). Prepares fixed part of covariate as a quadratic polynomial.

### Usage

```
spline.prep(cov, nknot = NA)
```

### Arguments

`cov` |
the covariate, a numeric vector |

`nknot` |
optional, number of knots |

### Value

A list with the following elements:

`cov` |
The input covariate |

`knots` |
The values of the knots |

`X` |
The fixed-effects design matrix |

`Z` |
The random-effects design matrix |

### Author(s)

Marc Kéry & Andy Royle

### References

Crainiceanu, C.M., Ruppert, D., & Wand, M.P. (2005) Bayesian analysis for penalized spline regression using WinBUGS. *Journal of Statistical Software*, 14.

Zuur, A.F., Saveliev, A.A., Ieno, E.N. (2012) *Zero-inflated Models and Generalized Linear Mixed Models with R*. Highlands Statistics

Kéry, M. & Royle, J.A. (2016) *Applied Hierarchical Modeling in Ecology* AHM1 - 10.14.

*AHMbook*version 0.2.9 Index]