You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've recently gotten a converged with large gradients (>0.05) warning after fitting a concurrent ordination.
# Fit the model ####
model <- gllvm(Y,
X, # Contains three variables: 2 categorical, 1 numeric
family = 'negative.binomial',
num.lv.c = 2,
offset = offset,
gradient.check = T,
control = list(reltol = 1e-16),
control.start = list(n.init = 5))
# Extract the gradient values and parameter names ####
gradient.check <- data.frame(gradient = model$TMBfn$gr() %>% .[1, ],
par = model$TMBfn$par |> names())
# Plot the values ####
gradient.check |>
ggplot(aes(x = par, y = gradient)) +
geom_jitter(alpha = 0.25,
width = 0.1) +
scale_y_continuous(n.breaks = 8) +
xlab("\nParameter") +
ylab("Gradient\n") +
theme_classic() +
base.theme
It looks like b_lv is the offending parameter, and I assume that this is related to the slope estimates for each taxon and each LV.
I do have have some slightly rare taxa (around a third occurring in 5 out of nearly 2000 samples, another third in 10-100 samples, and the last third in > 100 samples), but I've already whittled my cast down to 28 taxa, so I'm somewhat loathe to trim any more, but I'm prepared to do so if this is what might be contributing to the large gradient issues.
I also think it might make sense to use the randomB option, as Bert's vignette mentions:
In general, it has the potential to stabilize model fitting and reduce variance of the parameter estimates.
Given that large gradient warning looks like it's coming from b_lv (which I understand to be a LV slope estimate), this seems to suggest that randomB = 'P' might be best, as this assumes "that the random slopes per latent variable come from the same distribution". By assuming b_lv estimates come from the same distribution for a given LV, I would expect that this should help with fitting, correct?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi there,
I've recently gotten a
converged with large gradients (>0.05)
warning after fitting a concurrent ordination.It looks like
b_lv
is the offending parameter, and I assume that this is related to the slope estimates for each taxon and each LV.I do have have some slightly rare taxa (around a third occurring in 5 out of nearly 2000 samples, another third in 10-100 samples, and the last third in > 100 samples), but I've already whittled my cast down to 28 taxa, so I'm somewhat loathe to trim any more, but I'm prepared to do so if this is what might be contributing to the large gradient issues.
I also think it might make sense to use the
randomB
option, as Bert's vignette mentions:Given that large gradient warning looks like it's coming from
b_lv
(which I understand to be a LV slope estimate), this seems to suggest thatrandomB = 'P'
might be best, as this assumes "that the random slopes per latent variable come from the same distribution". By assumingb_lv
estimates come from the same distribution for a given LV, I would expect that this should help with fitting, correct?Curious to hear everyone's input!
Beta Was this translation helpful? Give feedback.
All reactions