JenniNiku / gllvm

Generalized Linear Latent Variable Models
https://jenniniku.github.io/gllvm/
48 stars 19 forks source link

binomial(link = 'probit'): Error in pnorm(eta) : Non-numeric argument to mathematical function #187

Open gerverska opened 3 months ago

gerverska commented 3 months ago

Hi there,

I'm trying to fit a binomial model and I'm running into an error whenever I try to plot or extract the residuals. The model converges without triggering a large gradient warning (or any other errors/warnings).

# Number of rows / samples ####
# 1983

# Number of columns / taxa ####
# 4

# Proportion of non-zero observations ####
# 4160 / 7932

# Fit the model ####
# Fixed effects: cat.6 is a categorical variable with six levels, cat.2 has two levels, and cont is continuous

# Row effects: cat.898 has 898 levels corresponding to a sampled "subject".
# Some subjects were sampled up to three times, some twice, some once.
> model <- gllvm(Y,
                 X,
                 formula = ~ cat.6 * cat.2 + log(cont),
                 family = binomial('probit'),
                 num.lv = 0,
                 studyDesign = studyDesign,
                 row.eff = ~(1 | cat.898),
                 gradient.check = T,
                 control = list(reltol = 1e-16),
                 control.start = list(n.init = 5))

# Attempt to plot residuals ####
> model |> plot()
Error in pnorm(eta) : Non-numeric argument to mathematical function

I'm not sure what the issue is here, but the summary() function seems to work fine. I'm using the development version that should have all the commits from about a week ago, but I can also try the most recent version and see how that works.

BertvanderVeen commented 3 months ago

I cannot reproduce this error, can you please provide a minimum reproducible example?

gerverska commented 2 months ago

Sorry, for the delay in getting around to this. I do have an update, though--downgrading to the CRAN version resolves this error. I'll have a reprex soon!