Stan_glmer with family=mgcv::betar(link="logit") posterior_linpred error

Please also provide the following information in addition to your question:

  • Operating System: Windows 10
  • rstanarm Version: 2.19.2

I updated R and rstanarm today and now I am running into an error with posterior_linpred on a stan_glmer model with family=mgcv::betar(link=“logit”).

I was not having this problem before the update. I was re-running some code with the previously fitted model to re-do a graph with higher resolution.

I tried class(fit) <- c(class(fit), “betareg”) and also reran the model with the updated package, and did the class thing again. This is the error:

Error in (function (optimizer = “nloptwrap”, restart_edge = TRUE, boundary.tol = 1e-05, :
unused arguments (tolPwrss = 1e-07, compDev = TRUE, nAGQ0initStep = TRUE, checkControl = list(“ignore”, “ignore”, “ignore”, “stop”, “ignore”, “message+drop.cols”, “warning”, “stop”, “ignore”), checkConv = list(list(“ignore”, 0.001, NULL), list(“ignore”, 1e-04), list(“ignore”, 1e-06)))

Hi, sorry to hear you are having problems. Unfortunately I don’t think we can help you much without more information about your problem - could you send us an R script you use to fit your model as well as example data (subset/fake/simulated) where the problem manifests? Basically we are looking for a minimal reproducible example of your problem.

SColType.GPA.Beta.Zero.disc.13 <- stan_glmer(GPA.std.beta ~ sumnobldg.0  [test.csv|attachment](upload://x7RUMOUVZGl1NtLeva2YbAa9Obe.csv) (6.1 KB) + log2.sumnobldg + CollAvg_GPA.std +                                       (1|College.Type) + (sumnobldg.0  + log2.sumnobldg|discipline.Type), 
family=mgcv::betar(link="logit"), adapt_delta=0.99, data=GPAuse,  seed = SEED, QR=TRUE)

P <- posterior_linpred(mfit, newdata=ndd, transform=TRUE)

ndd is the data attached for running posterior_linpred

Posterior_linpred did work with a logistic regression model, but it was much, much slower than it was with the previous version of rstanarm

Sorry, the upload of the CSV seems to have been mangled - could you upload it once more?

test.csv (6.3 KB)

Hope this works! (I realized I needed to redo this again, my mistake!)

So, I can get the model to work and predict well, but I am not using the newdata parameter (as I don’t have anything to put there). I also neede to change mfit to SColType.GPA.Beta.Zero.disc.13 as mfit is not defined in your script. Are you sure you are not mixing up multiple models or something? If you are sure, could you please send a full script that starts with reading the data and ends with the error, that would produce the error in a fresh R session (without any previous data)?

Here is what I ran on my side:

library(rstanarm)
library(readr)
GPAuse <- read_csv("test.csv")
options(mc.cores = parallel::detectCores())

SEED <- 12354
SColType.GPA.Beta.Zero.disc.13 <- stan_glmer(GPA.std.beta ~ sumnobldg.0  + log2.sumnobldg + CollAvg_GPA.std +                                       (1|College.Type) + (sumnobldg.0  + log2.sumnobldg|discipline.Type), 
family=mgcv::betar(link="logit"), adapt_delta=0.99, data=GPAuse,  seed = SEED, QR=TRUE)

P <- posterior_linpred(SColType.GPA.Beta.Zero.disc.13, transform=TRUE)

Which works neatly.

Thank you for taking a look at it. I won’t be able to send the full script until next week, since I am off. However, the data (test.csv) was a subset of the data I used to fit the model, and I use subsets of the data in the newdata argument to run in posterior_linpred
to produce plots.

Can you run posterior_linpred with newdata= the test data set? Does that work for you? It used to work before I updated rstanarm and R.

mfit is indeed SColType.GPA.Beta.Zero.disc.13, sorry
I forgot to mention that

Here is the reproducible example, with example data uploaded test.csv (6.3 KB) :


test <- read.csv("test.csv")

SEED=101
GPA.Beta <- stan_glmer(GPA.std.beta ~ sumnobldg.0 + log2.sumnobldg + CollAvg_GPA.std + (1|College.Type) + (sumnobldg.0  + log2.sumnobldg|discipline.Type), family=mgcv::betar(link="logit"), adapt_delta=0.95, data=test, seed = SEED, QR=TRUE)

ndd <- test[which(test$discipline.Type=="Ag & Life Sciences.Graduate"),]

P <- posterior_linpred(GPA.Beta, newdata=ndd, transform=TRUE)

OK, so I can replicate. This is almost certainly a bug in rstanarm - I filed it under https://github.com/stan-dev/rstanarm/issues/407

In the meantime, you can use the brms package to estimate beta regression models (this requires fully installing rstan though).

Hope that helps!

Thank you, I suspected it was a bug and I also added it in
https://github.com/stan-dev/rstanarm/issues/406

image001.jpg