Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Adding new covariates

Jim Thorson edited this page Mar 31, 2016 · 8 revisions

How to add new covariates:

Does your variable affect the density of the species, or increase/decrease the proportion of fish that are caught within a given arae?

  • If it affects density, then it is a "spatial variable"
  • If it increases/decreases the proportion of fish caught within the area swept, then its a "catchability variable"
  • See Glossary for more details

If it's a "catchability variable", then adding it is easy!

  • Just change Q_ik in the input to Data_Fn()
  • Q_ik should have rows equal to the number of observation, and columns equal to the number of catchability variables that you want to include
  • For example, if you have a data set with two gears (and data to estimate the ratio of catchability between the two), then Q_ik should be a design matrix have 1 column, with 0 for the reference gear, and 1 for the different gear. It can be calculated by using the function vector_to_design_matrix(), but removing one of the columns.

If it's a "density variable", then it takes a bit more work

  • It depends on whether its constant over time, or varies for each time period

If the covariate is constant over time...

  • ... then you input X_xj to Data_Fn()
  • To calculate X_xj, you must obtain the value of the covariate at each knot x for each covariate j (if you have only one covariate, then X_xj is a matrix with 1 column)
  • For many variables (e.g., surface water temperature), the value of the covariate varies at a finer spatial scale than the scale of knots. In this case, the value for knot x is generally the average value of the covariate for all locations that are closest to knot x. This can be calculated using a nearest neighbors algorithm to associate every location with a covariate measure with the set of knots.

If the covariate varies over time...

  • ... then you input X_xtp to Data_Fn()
  • X_xtp is an array where X_xtp[x,t,p] is the value of the covariate for knot x at time t and covariate p (if you have only one covariate, then X_xtp is an array with 3rd dimension equal to one)
  • For each time period, you calculate the value at knot x using the same method as for covariates that are constant over time