-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
[Feature request] Specify models with mathematical notation #1731
Comments
Interesting idea. I agree that having a closer fit between the notation in math vs brms could be helpful for teaching. On the other hand, I don't see the value in making it a one-of for just a covariate-free gaussian, since that's knowledge that won't generalize and it will just confuse them anyway when they have to switch to an entirely different notation down the line. I think extending that notation to a normal linear model is easy enough, something like: bf(
y ~ Gaussian(mu, sigma),
mu = 1 + x1 + x2
) If we can have that, then it would also be great to extend it to GLMs: bf(
y ~ Poisson(lambda),
log(lambda) = 1 + x1 + x2
) But I'm not sure that R will play nicely with something that looks like a function call to the left of |
You might want to look at bbmle which did something like this... |
@lunafazio It is true that it doesn't generalise, but pedagogically that worries me less because as soon as I introduce a regression proper ( Not saying it wouldn't be nice to be able to use math notation for all models, but it might be overkill to implement. rethinking does do that and it goes all the way down by also specifying coefficients, not just variables/terms (following code just for illustration, not working): ulam(
alist(
log_gdp_std ~ dnorm(mu, sigma),
mu <- a[cid] + b[cid] * (rugged_std - 0.215),
a[cid] ~ dnorm(1, 0.1),
b[cid] ~ dnorm(0, 0.3),
sigma ~ dexp(1)
)
) |
not out-of-the box, but because R uses lazy evaluation of function arguments, it can be done using some standard R tools for diffusing arguments and parsing the diffused expressions |
When introducing simple Gaussian models like$y \sim Gaussian(\mu, \sigma)$ , students get confused by the R syntax/specification
because regression models proper (with one predictor) are introduced after (at least in the approach I take).
It would be nice (and pedagogically easier) if one could specify a Gaussian model like so:
I assume it wouldn't be trivial to do this for all types of models, so would be awesome to have this even for just a simple Gaussian model with no predictors (or maybe also for
y ~ x
?)The text was updated successfully, but these errors were encountered: