8.2 Prepare the plankton data

We will prepare the data by z-scoring. The original data lakeWAplanktonTrans were already z-scored, but we changed the mean when we subsampled the years so we need to z-score again.

# z-score the response variables
the.mean <- apply(dat, 1, mean, na.rm = TRUE)
the.sigma <- sqrt(apply(dat, 1, var, na.rm = TRUE))
dat <- (dat - the.mean) * (1/the.sigma)

Next we set up the covariate data, temperature and total phosphorous. We z-score the covariates to standardize and remove the mean.

the.mean <- apply(covariates, 1, mean, na.rm = TRUE)
the.sigma <- sqrt(apply(covariates, 1, var, na.rm = TRUE))
covariates <- (covariates - the.mean) * (1/the.sigma)
Time series of Green and Bluegreen algae abundances in Lake Washington along with the temperature and total phosporous covariates.

Figure 8.1: Time series of Green and Bluegreen algae abundances in Lake Washington along with the temperature and total phosporous covariates.