Hocking-Lab / cocanal-turtles

Files related to analysis of turtle data from the Chesapeake and Ohio Canal
0 stars 0 forks source link

Creating behavior model #9

Closed djhocking closed 5 years ago

djhocking commented 5 years ago

issue with creating the Cik matrix for the behavioral model.

djhocking commented 5 years ago

fixed it with the following code

# make Cij with 1 if a recap and 0 otherwise
C_obs <- BM_less %>%
  expand(ind, day) %>%
  left_join(BM_less) %>%
  group_by(ind) %>%
  mutate(behav = ifelse(is.na(behav), 0, behav),
         cumu = cumsum(behav)) %>%
  mutate(cij = ifelse(cumu > 0, 1, 0)) %>% # if you stop it here you can see what it's doing 
  select(ind, day, cij) %>%
  spread(key = day, value = cij, sep = "_") %>% # stop here if you want to see individual ID before dropping it
  ungroup %>%
  select(-ind)

# augment unobserved individuals
C_unobs <- as.data.frame(matrix(0, nrow = M-nrow(C_obs), ncol = 4))
colnames(C_unobs) <- colnames(C_obs)
C <- bind_rows(C_obs, C_unobs)

and pushed change to github

djhocking commented 5 years ago

The JAGS model is still giving the same error. Check that over and create a new issue. Double check the indexing in matrices and arrays and otherwise maybe could try creating a logit function yourself rather than using the build-in logit function on the left side of the equation.