rmcelreath / rethinking

Statistical Rethinking course and book package
2.14k stars 601 forks source link

Matrix notation? #12

Open joelgombin opened 9 years ago

joelgombin commented 9 years ago

Hi,

thanks for this package, which seems really great. I also enjoyed the book a lot.

I wondered if there is a way in map2stan to use matrix notation, as is possible in stan. Suppose for example I have a matrix of covariates X and a vector of parameters B, such that y ~ XB, is there anyway to indicate it in map2stan?

Thanks!

rmcelreath commented 9 years ago

Hi, Joel.

If there is a way to specify the design matrix style linear model, it's not really supported. The Stan team has told me that it's not any faster to do it that way, so I haven't invested any time in it.

But it might not be much work to add it, really. I'll add it to the wish list.

On Fri, Sep 11, 2015 at 10:03 PM, Joel Gombin notifications@github.com wrote:

Hi,

thanks for this package, which seems really great. I also enjoyed the book a lot.

I wondered if there is a way in map2stan to use matrix notation, as is possible in stan. Suppose for example I have a matrix of covariates X and a vector of parameters B, such that y ~ XB, is there anyway to indicate it in map2stan?

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/rmcelreath/rethinking/issues/12.

vasishth commented 9 years ago

Hi Richard,

take a look at our tutorial. I think the matrix notation does tend to be faster, and it is certainly easier to generalize, as far as LMMs go:

http://www.ling.uni-potsdam.de/~vasishth/statistics/BayesLMMs.html

Also see the example KB07 using Stan in RePsychLing:

https://github.com/dmbates/RePsychLing

Shravan Vasishth Professor for Psycholinguistics and Neurolinguistics Department of Linguistics University of Potsdam, Germany http://www.ling.uni-potsdam.de/~vasishth

On Mon, Sep 14, 2015 at 10:40 AM, Richard McElreath < notifications@github.com> wrote:

Hi, Joel.

If there is a way to specify the design matrix style linear model, it's not really supported. The Stan team has told me that it's not any faster to do it that way, so I haven't invested any time in it.

But it might not be much work to add it, really. I'll add it to the wish list.

On Fri, Sep 11, 2015 at 10:03 PM, Joel Gombin notifications@github.com wrote:

Hi,

thanks for this package, which seems really great. I also enjoyed the book a lot.

I wondered if there is a way in map2stan to use matrix notation, as is possible in stan. Suppose for example I have a matrix of covariates X and a vector of parameters B, such that y ~ XB, is there anyway to indicate it in map2stan?

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/rmcelreath/rethinking/issues/12.

— Reply to this email directly or view it on GitHub https://github.com/rmcelreath/rethinking/issues/12#issuecomment-140001629 .