Coder Social home page Coder Social logo

Comments (6)

paul-buerkner avatar paul-buerkner commented on August 17, 2024

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.

EmmanuelCharpentier avatar EmmanuelCharpentier commented on August 17, 2024

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.

paul-buerkner avatar paul-buerkner commented on August 17, 2024

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.

paul-buerkner avatar paul-buerkner commented on August 17, 2024

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.

EmmanuelCharpentier avatar EmmanuelCharpentier commented on August 17, 2024

[ 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.

paul-buerkner avatar paul-buerkner commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.