stan-dev / stan-dev/rstanarm

posterior_predict() fails with newdata for models estimated with family = mgcv::betar

Open
#407 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
401
Forks
136
PR merge metrics
No merged PRs in 30d

Description

Summary:

Similar to #324, I can run posterior_predict and posterior_linpred for betareg models, but as soon as I specify newdata = XX I get an error.

Description:

Running posterior_linpred with newdata (even if the newdata argument is the same as the data used to estimate the model) results in the following 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)))

The workaround mentioned in #324 (adding class) does not help.

Reproducible Steps:
library(rstanarm)
test <- data.frame(y = c(0.1, 0.3), x = c(TRUE, FALSE))

SEED=101
res <- stan_glmer(y ~ (1|x), family=mgcv::betar(link="logit"), data=test, seed = SEED, iter = 200)

class(res) <- c(class(res), "betareg") #Workaround from issue 324
P <- posterior_linpred(res, newdata=test)
RStanARM Version:

2.19.2

R Version:

3.6.0

Operating System:

Windows 10

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the posterior_linpred and posterior_predict entry points and reproduce the reported mgcv::betar case using the supplied data and model. Trace why passing newdata produces the unused-arguments error; done means both prediction calls accept newdata for this model without requiring the class workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.