Comments (6)
The last error you encountered appears to be a bug in the formula parsing. I will try to fix this later on today.
The moment you use the nonlinear
argument, the formula
argument will be interpreted completely different than it usually is in the sense that it now describes a non-linear model. That is you have to explicitely write down every parameter in the predictor part of the model. All variables on the right hand side of ~
that are not labled as parameters in the nonlinear
argument are considered as data. There is no need to put an intercept column into your data, because you defined the Intercept as a parameter (not as data).
My suggestion would be to write the model as follows:
formula = log(Duree) ~ b0 + b1*Classe + b2*Arcade + b3*ReTt + b4*NoTf + b5*NoWO + log(km+(1-km)*exp(-betaExp*Exp))
nonlinear = list(b0 ~ (1|Etudiant), b1 ~ 1, b2 ~ 1, b3 ~ 1, b4 ~ 1, b5 ~ 1, km ~ 1, betaExp ~ 1)
Don't forget to set priors on all non-linear parameters. However, this won't work until I fixed the formula parsing. I will write again as soon as I have fixed it
from brms.
Le dimanche 21 février 2016 à 06:34 -0800, Paul-Christian Bürkner a
écrit :
The last error you encountered appears to be a bug in the formula
parsing. I will try to fix this later on today.
The moment you use the nonlinear argument, the formula argument will be
interpreted completely different than it usually is in the sense that
it now describes a non-linear model. That is you have to explicitely
write down every parameter in the predictor part of the model.
This is not readily apparent at the reading of the vignette or the
documentation of the "brm" function...
All variables on the right hand side of ~ that are not labled as
parameters in the nonlinear argument are considered as data. There is
no need to put an intercept column into your data, because you defined
the Intercept as a parameter (not as data).My suggestion would be to write the model as follows:
formula> > => log(> Duree> ) > ~> > b0> > +> > b1> *> Classe> > +> > b2> *> Arcade> > +> > b3> *> ReTt> > +> > b4> *> NoTf> > +> > b5> *> NoWO> > +> log(> km> +> (> 1> -> km> )> *<
/span>exp(> -> betaExp> *> Exp> ))nonlinear> > => > list> (> b0> > ~> (> 1> |> Etudiant> ), > b1> > ~> > 1> , > b2> > ~> > 1> , > b3> > ~> > 1> , > b4> > ~> > 1> , > b5> > ~> > 1> , > km> > ~> > 1> , > betaExp> > ~> > 1> )
Real close to writing the code in Stan, IIUYC. Almost another way to
specify a model (a. k. a. a new modeling (mini-)language)...
Will this code manage to recognize that Classe is a 3-level factor ?
And recode it as a base level confounded with the intercept and two
boolean variables (hence a two-dimensional b1) ?
Should I declare the standard deviations ("Etudiant" random effect and
residual) ? If so, how ?Don't forget to set priors on all non-linear parameters. However, this won't work until I fixed the formula parsing. I will write again as soon as I have fixed it
Thanks a lot ! This level of responsiveness is unusual (to say the
least...).Sincerely,
Emmanuel Charpentier
—
Reply to this email directly or view it on GitHub.
from brms.
You are right, the documentation needs some improvements here.
All formulas in nonlinear
are treated as ordinary formulas so no need to declare the standard deviation of Etudiant
. Also the residual SD does not need to be defined as it is not part of any formula anyway but a "property" of the gaussian family.
The way brms
handles non-linear formulas is very similar to what the nlme
package does. A few minutes ago, Alex Forrence posted some examples in #37, maybe this can help you getting more familiar with the syntax.
I wouldn't call it a mini-language, but rather an explicit way of writing a model. You cannot treat parts of the formula as usual and the other as "non-linear". If you look at the Stan code via stancode(model)
after fitting your model (or via directly calling make_stancode
), you will see that there is more going on other than writing the predictor part of the model.
Currently, a 3-level factor will not be allowed in a non-linear formula (you will recieve an error message before the model is compiled), but it's allowed to put it in nonlinear
.
In fact, as I think about it, you can greatly simplify your model by writing:
formula = log(Duree) ~ b + log(km+(1-km)*exp(-betaExp*Exp))
nonlinear = list(b ~ Classe+Arcade+ReTt+NoTf+NoWO+(1|Etudiant), km ~ 1, betaExp ~ 1)
Your linear predictor will be plugged in for b
in the non-linear formula and the actual non-linear part log(km+(1-km)*exp(-betaExp*Exp))
is added.
from brms.
The fix for the formula parsing issue is now on github. You can install the latest dev version of brms via
library(devtools)
install_github("paul-buerkner/brms")
Hopefully, this will allow your model to be fitted.
from brms.
[ Sorry for tjhe (non-maskable) interruption : RealLife(TM) happens...
]
Yes, that works : I have been able to recompile my test case and to get
sensible results (close, but not identical, to a hand-made rstan fit).
I'm still a bit confused about the expression of the models and the
priors. But that's a documentation problem...
Again, thank you very much !
Emmanuel Charpentier
Le dimanche 21 février 2016 à 07:28 -0800, Paul-Christian Bürkner a
écrit :
The fix for the formula parsing issue is now on github. You can
install the latest dev version of brms via
library(devtools)
install_github("paul-buerkner/brms")
Hopefully, this will allow your model to be fitted.
—
Reply to this email directly or view it on GitHub.
from brms.
Ok great! The documentation will be improved with the next version. Also, I am currently writing a vignette about non-linear models (see #37).
Thanks for opening this issue and helping me to improve brms!
from brms.
Related Issues (20)
- Possible bug in brms/emmeans integration HOT 20
- R2D2 does not account for scale of the data HOT 3
- car example uses deprecated formula
- feature request: alternative approach for censored data HOT 2
- brms::log_lik creating zombies if cmdstanr is loaded HOT 13
- feature request: mixtures over groups / participants
- Potential breaking change for brms 3.0: no special treatment for mu
- Use draws from pathfinder posterior as inits HOT 1
- Code for threaded categorical outcome models does not work HOT 4
- More documentation for loo(reloo_args)
- Error in fcor() for nonlinear model
- Error in x$terms HOT 3
- misleading wording in multivariate model vignette?
- post-hoc test for multinomial logistic regression brm model (categorical responce) HOT 1
- "Global state has changed" warning HOT 1
- conditional_effects plot for monotonic predictors - lineplot vs catergorial plot HOT 1
- `lprior` not available if `normalize = FALSE` HOT 2
- Include Pathfinder in brm documentation? HOT 1
- Support moment matching LOO for LOO predictions
- R2D2 help file request HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from brms.