{"action":"created","issue":{"url":"https://api.github.com/repos/paul-buerkner/brms/issues/518","repository_url":"https://api.github.com/repos/paul-buerkner/brms","labels_url":"https://api.github.com/repos/paul-buerkner/brms/issues/518/labels{/name}","comments_url":"https://api.github.com/repos/paul-buerkner/brms/issues/518/comments","events_url":"https://api.github.com/repos/paul-buerkner/brms/issues/518/events","html_url":"https://github.com/paul-buerkner/brms/issues/518","id":359429253,"node_id":"MDU6SXNzdWUzNTk0MjkyNTM=","number":518,"title":"summary() output with custom_family","user":{"login":"singmann","id":1902102,"node_id":"MDQ6VXNlcjE5MDIxMDI=","avatar_url":"https://avatars0.githubusercontent.com/u/1902102?v=4","gravatar_id":"","url":"https://api.github.com/users/singmann","html_url":"https://github.com/singmann","followers_url":"https://api.github.com/users/singmann/followers","following_url":"https://api.github.com/users/singmann/following{/other_user}","gists_url":"https://api.github.com/users/singmann/gists{/gist_id}","starred_url":"https://api.github.com/users/singmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/singmann/subscriptions","organizations_url":"https://api.github.com/users/singmann/orgs","repos_url":"https://api.github.com/users/singmann/repos","events_url":"https://api.github.com/users/singmann/events{/privacy}","received_events_url":"https://api.github.com/users/singmann/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-09-12T11:03:39Z","updated_at":"2018-09-12T13:31:13Z","closed_at":"2018-09-12T13:26:37Z","author_association":"NONE","body":"the `summary` method for `brmsfit` object does not print all parameters for models using a `custom_family`. This is easy to see when renaming a parameter from the vignette.\r\n\r\nIf we just use the code from the vignette, all is well:\r\n\r\n```\r\nlibrary(\"brms\")\r\ndata(\"cbpp\", package = \"lme4\")\r\n\r\nbeta_binomial2 <- custom_family(\r\n  \"beta_binomial2\", dpars = c(\"mu\", \"phi\"),\r\n  links = c(\"logit\", \"log\"), lb = c(NA, 0),\r\n  type = \"int\", vars = \"trials[n]\"\r\n)\r\nstan_funs <- \"\r\n  real beta_binomial2_lpmf(int y, real mu, real phi, int T) {\r\n    return beta_binomial_lpmf(y | T, mu * phi, (1 - mu) * phi);\r\n  }\r\n\"\r\nstanvars <- stanvar(as.integer(cbpp$size), name = \"trials\")\r\n\r\n\r\nfit2 <- brm(\r\n  incidence ~ period + (1|herd), data = cbpp, \r\n  family = beta_binomial2, stan_funs = stan_funs,\r\n  stanvars = stanvars, \r\n  chains = 4, cores = 4\r\n)\r\nsummary(fit2)\r\n# Group-Level Effects: \r\n# ~herd (Number of levels: 15) \r\n#               Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat\r\n# sd(Intercept)     0.38      0.26     0.02     0.97        909 1.00\r\n# \r\n# Population-Level Effects: \r\n#           Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat\r\n# Intercept    -1.36      0.26    -1.90    -0.86       2636 1.00\r\n# period2      -1.01      0.43    -1.90    -0.20       3282 1.00\r\n# period3      -1.27      0.46    -2.24    -0.43       3093 1.00\r\n# period4      -1.55      0.52    -2.63    -0.59       3058 1.00\r\n# \r\n# Family Specific Parameters: \r\n#     Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat\r\n# phi    16.89     13.78     5.42    55.36        932 1.00\r\n# \r\n# Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample \r\n# is a crude measure of effective sample size, and Rhat is the potential \r\n# scale reduction factor on split chains (at convergence, Rhat = 1).\r\n```\r\n\r\nIf we rename the scale/precision parameter `phi` to something else (e.g., `foobar`), two things happen. First, we need to specify a prior for the parameter. It appears that for parameters with certain names, some default prior is used. I am not sure if this is documented somewhere, but at least I did not find it. I think it would be great to know which names receive which default priors.\r\nSecond and more importantly, the `summary` method does not show the new parameter `foobar`:\r\n\r\n```\r\nbeta_binomial3 <- custom_family(\r\n  \"beta_binomial3\", dpars = c(\"mu\", \"foobar\"),\r\n  links = c(\"logit\", \"log\"), lb = c(NA, 0),\r\n  type = \"int\", vars = \"trials[n]\"\r\n)\r\nstan_funs3 <- \"\r\n  real beta_binomial3_lpmf(int y, real mu, real foobar, int T) {\r\n    return beta_binomial_lpmf(y | T, mu * foobar, (1 - mu) * foobar);\r\n  }\r\n\"\r\nprior <- prior(gamma(0.01, 0.01), class = foobar)\r\n\r\nfit3 <- brm(\r\n  incidence ~ period + (1|herd), data = cbpp, \r\n  family = beta_binomial3, stan_funs = stan_funs3,\r\n  stanvars = stanvars, prior = prior,\r\n  chains = 4, cores = 4\r\n)\r\nsummary(fit3)\r\n# Group-Level Effects: \r\n# ~herd (Number of levels: 15) \r\n#               Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat\r\n# sd(Intercept)     0.39      0.27     0.02     1.01        970 1.01\r\n# \r\n# Population-Level Effects: \r\n#           Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat\r\n# Intercept    -1.35      0.26    -1.88    -0.86       4000 1.00\r\n# period2      -1.00      0.41    -1.83    -0.20       4000 1.00\r\n# period3      -1.27      0.46    -2.20    -0.42       3603 1.00\r\n# period4      -1.57      0.51    -2.62    -0.62       3135 1.00\r\n# \r\n# Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample \r\n# is a crude measure of effective sample size, and Rhat is the potential \r\n# scale reduction factor on split chains (at convergence, Rhat = 1).\r\n```\r\n\r\nIt would be great if the summary methods showed all parameters of the `custom_family`."},"comment":{"url":"https://api.github.com/repos/paul-buerkner/brms/issues/comments/420648740","html_url":"https://github.com/paul-buerkner/brms/issues/518#issuecomment-420648740","issue_url":"https://api.github.com/repos/paul-buerkner/brms/issues/518","id":420648740,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMDY0ODc0MA==","user":{"login":"paul-buerkner","id":12938496,"node_id":"MDQ6VXNlcjEyOTM4NDk2","avatar_url":"https://avatars3.githubusercontent.com/u/12938496?v=4","gravatar_id":"","url":"https://api.github.com/users/paul-buerkner","html_url":"https://github.com/paul-buerkner","followers_url":"https://api.github.com/users/paul-buerkner/followers","following_url":"https://api.github.com/users/paul-buerkner/following{/other_user}","gists_url":"https://api.github.com/users/paul-buerkner/gists{/gist_id}","starred_url":"https://api.github.com/users/paul-buerkner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paul-buerkner/subscriptions","organizations_url":"https://api.github.com/users/paul-buerkner/orgs","repos_url":"https://api.github.com/users/paul-buerkner/repos","events_url":"https://api.github.com/users/paul-buerkner/events{/privacy}","received_events_url":"https://api.github.com/users/paul-buerkner/received_events","type":"User","site_admin":false},"created_at":"2018-09-12T13:31:13Z","updated_at":"2018-09-12T13:31:13Z","author_association":"OWNER","body":"I think the existing parameters are somewhat documented in `?brmsformula`. You may also look at `brms:::def_dprior`."}}
{"actor":{"display_login":"paul-buerkner"}}