Skip to content

Issue with plotting using visreg_delta each model #354

Answered by seananderson
LSupatcha asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks, I can confirm that issue. It's related to the predict code always iterating over building the model matrices for both linear predictors but visreg prepares a data frame here based only on the 2nd linear predictor. I.e., it's going to happen if the 2 linear predictors have different formulas.

Here's an example of making a conditional effects plot yourself:

library(sdmTMB)
library(ggplot2)
library(dplyr)
df <- pcod
df$fyear <- as.factor(df$year)
df$cov1 <- df$depth
df$cov2 <- df$year

fit <- sdmTMB(
  list(density ~ poly(cov1, 2) + poly(cov2, 2),
    density ~ poly(cov2, 2)),
  data = df,
  time = "year",
  family = delta_gamma(),
  spatiotemporal = "off",
  spatial = "off"
)

nd <-

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@LSupatcha
Comment options

@seananderson
Comment options

Answer selected by LSupatcha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants