Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spread_draws() with rstanarm glmer? #308

Closed
potash opened this issue Feb 2, 2023 · 4 comments
Closed

spread_draws() with rstanarm glmer? #308

potash opened this issue Feb 2, 2023 · 4 comments

Comments

@potash
Copy link

potash commented Feb 2, 2023

I am having trouble applying spread_draws() to a varying intercept varying slope model fit with the following formula and stan_glmer()

y ~ log(x) + (log(x) | site)

Calling get_variables() returns something like this:

[1] "(Intercept)"                                
[2] "log(x)"                            
[3] "b[(Intercept) site:A]"                
[4] "b[log(x) site:A]"            
[5] "b[(Intercept) site:B]"                     
[6] "b[log(x) site:B]"
...

Is this naming convention compatible with spread_draws()? I'd like to extract a dataframe that looks like this:

.draw, site,(Intercept),log(x)
1,A,...,...
1.B,...,...
...
@potash
Copy link
Author

potash commented Feb 2, 2023

Simply spread_draws(fit, b[i,j]) works. I was backticking b[i,j] and that was breaking it with:

No variables found matching spec: b\[i\,j\]

Is that a bug?

@mjskay
Copy link
Owner

mjskay commented Feb 2, 2023

Yeah b[i, j] should work, and if you want the i as columns b[i, j] | i would do that.

Using backticks like `b[i,j]` doesn't work because that means you are asking for a variable named "b[i,j]" exactly.

@potash potash closed this as completed Feb 2, 2023
@potash
Copy link
Author

potash commented Feb 2, 2023

Ah that explains it, thanks

@mjskay
Copy link
Owner

mjskay commented Feb 2, 2023

great, happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants