-
Notifications
You must be signed in to change notification settings - Fork 48
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
ReMat type that holds "raw" matrix #77
Comments
I just pushed a new version 0.7.7 incorporating your changes on the Some of the code has been simplified, which might be good news or bad news. I have eliminated the distinction between
For a LMM the only methods used to evaluate the log-likelihood are Evaluating the Laplace approximation to the deviance of a GLMM requires evaluating I am open to ideas of how to abstract these operations to accomodate your model. |
Thanks, I'll take a look at the master branch now (I just started to dig into this today). For the sake of being concrete about what I'm after, I'm looking to do crossed random effects models for fMRI data. The basic structure of this data is that there are a number of events that occur at distinct points in time, but the brain response to them is smeared out in time, and in many designs the responses to individual stimuli/trials overlaps substantially. The "standard" analysis is to run a linear model with one column in your design matrix per condition (say, faces vs. houses), where the predictor is constructed by convolving the brain response kernel with the even time series for each condition. Typically, you run one model per subject (per brain area), and then do some second-level analysis on the t-statistics for each subject. This doesn't account for the fact that the items presented in each condition aren't unique (e.g., three different faces repeated 10 times each), so you really ought to do use a linear mixed model with crossed random effects for subjects and items. The complications come from the fact that you can't do the usual trick of splitting up the model matrix by rows, since multiple items might be contributing to the predictor at each time point because the brain responses to each event (trial) are spread out over multiple time points. From what I could tell reading the last released version, it would be possible do deal with this by using a ReMat that has the full random effects matrix, at some cost of the efficiency that comes from the compact ScalarReMat/VectorReMat and the specialized linear algebra they allow. The motivation for this is Jake Westfall's paper on this. They ended up using Bayesian mixed models in PyMC, which is slow and puts real constraints on the number of models you can estimate and hence the spatial resolution you get out of your data. But conceptually their model is just a crossed item/subject ranef model. |
I have been thinking about refactoring the Essentially I plan to define an abstract type, say These changes will be over the next several weeks. In the short term I will make a 0.8.0 release based on the
This is for a workshop I will teach on Friday (see https://github.com/dmbates/NESS2017) |
Workshop looks cool! I'll hold off digging into this for a few weeks then if the internals are likely to change. It sounds like that refactoring would make the sort of extension I'm thinking of much easier. |
@kleinschmidt The first cut at refactoring the representation of random-effects terms is now in the This version doesn't pass its tests yet, which is partly because the code is incomplete or wrong and partly because some of the the tests are not correct. More to come. |
The type change proposed here has actually been implemented. The application is still relevant and related to a particular way of using smooths in rERP, but that's probably something for a worked example. @kleinschmidt Feel free to reopen if I'm wrong. |
Yes that's more or less what I had in mind (for fMRI but same idea). Let's talk this over in person. |
The current implementation does store the expanded model matrix (in transposed/adjoint form as the I see two possibilities about how to address this. One would be to make A second possibility would be to have some kind of type parameter on I guess I'd lean slightly towards the |
I have a preference for |
Is there any possibility of adding an additional ReMat subtype that wraps an AbstractMatrix? I'm interested in fitting mixed effects models that have random effects structure which isn't a strict partitioning of the full design matrix by row (they're events convolved with a temporal kernel, separate instances of which might overlap)
I'm also open to the possibility of extending the ReMat type in my own package but I'm not entirely clear on which methods I'd need to implement to make that work (since there's a lot of specialization for scalar/vector).
The text was updated successfully, but these errors were encountered: