Closed seananderson closed 1 year ago
Hi @NathanHebertMSVU I've moved this to an issue because that shouldn't happen. However, I can't reproduce it. Can you try to reproduce it with with some version of the following? First, make sure you're on the latest sdmTMB (GitHub or CRAN should be fine). Second, maybe take a look at the str()
of your data frame and check if there's anything funny with the time column 'year'?
library(sdmTMB)
fit <- sdmTMB(
present ~ depth_scaled,
data = pcod_2011,
mesh = pcod_mesh_2011,
family = binomial(),
time = "year",
spatial = "off",
spatiotemporal = "ar1"
)
visreg::visreg(fit, "depth_scaled", partial = FALSE, rug = 1)
Created on 2023-02-01 with reprex v2.0.2
I appreciate the very prompt reply! I updated to the current version.
It looks like "year" is of type int, which I assume should be okay? I unfortunately can't reproduce it with your code.
If you can't get it to happen with the pcod dataset, can you email me the data set you have (maybe as an .rds) along with some reproducible code? It would be nice to get to the bottom of it.
The issue is that visreg breaks (removes extra columns of data, i.e., removes the time column) if the response is of class logical. I have no idea why and haven't dug into their code. For now I added a warning:
library(sdmTMB)
pcod_2011$present_logical <- as.logical(pcod_2011$present)
fit <- sdmTMB(
present_logical ~ depth_scaled,
data = pcod_2011,
mesh = pcod_mesh_2011,
family = binomial(),
spatial = "off",
spatiotemporal = "iid",
time = "year"
)
#> Warning: We recommend against using `TRUE`/`FALSE` response values if you are going to
#> use the `visreg::visreg()` function after. Consider converting to integer with
#> `as.integer()`.
visreg::visreg(fit, "depth_scaled")
#> Error: Specified `time` column is missing from `data`.
Created on 2023-02-01 by the reprex package (v2.0.1)
Discussed in https://github.com/pbs-assess/sdmTMB/discussions/171