> 4. mailto:sciruby-dev+unsub...@googlegroups.com
> 5. https://groups.google.com/d/optout
--
> > 4. mailto:[10]sciruby-dev+unsub...@googlegroups.com
> > 5. [11]https://groups.google.com/d/optout
>
> --
>
> --
> You received this message because you are subscribed to the Google Groups
> "SciRuby Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [12]sciruby-dev...@googlegroups.com.
> For more options, visit [13]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. http://cran.r-project.org/web/packages/lme4/vignettes/lmer.pdf
> 2. https://github.com/agisga/MixedModels.git
> 3. https://github.com/SciRuby/nmatrix/pull/366
> 4. https://github.com/SciRuby/nmatrix/pull/365
> 5. javascript:
> 6. https://groups.google.com/d/optout
> 7. https://github.com/agisga/MixedModels.git
> 8. https://github.com/SciRuby/nmatrix/pull/366
> 9. https://github.com/SciRuby/nmatrix/pull/365
> 10. javascript:
> 11. https://groups.google.com/d/optout
> 12. mailto:sciruby-dev+unsub...@googlegroups.com
> 13. https://groups.google.com/d/optout
--
Hi Pjotr,
Right now I am thinking about how to parse an R-like formula in Ruby. An example of what I want is:
Say, I have a data frame dat_frm with n rows corresponding to n patients, and p columns "Drug_effectiveness", "Age", "Weight", "Height", "Dose", "Clinic", etc. I want to model the drug effectiveness as a linear function of the drug dose, patient age, weight and height, while assuming that there is a random fluctuation of the effect of each parameter due to the clinic that a patient is treated in. Then I have several ways to represent it in a formula (each formula defines a slightly different correlation structure between the random effects):
(1) "Effect ~ Age + Weight + Dose + (Age + Weight + Dose | Clinic)"
(2) "Effect ~ Age + Weight + Dose + (Age | Clinic) + (0 + Weight + Dose | Clinic)"
(3) "Effect ~ Age + Weight + Dose + (1 | Clinic) + (0 + Age | Clinic) + (0 + Weight + Dose | Clinic)"
(4) "Effect ~ Age + Weight + Dose + (1 | Clinic) + (0 + Age | Clinic) + (0 + Weight | Clinic) + (0 + Dose | Clinic)"
(5) ...
In any case, the algorithm needs to build the design matrix X out of columns "Age", "Weight", "Dose", and construct the appropriate random effects matrix Z according to the group structure given in the column "Clinic" of dat_frm.
Additionally, I might want to consider interaction effects, say between "Weight" and "Dose", which can be expressed as:
(5) "Effect ~ Age + Weight + Dose + Weight:Dose + (Age + Weight + Dose | Clinic)"
(6) "Effect ~ Age + Weight * Dose + (Age + Weight + Dose | Clinic)"
(7) ...
Do you have an idea how I can begin with setting up such a formula parsing module (I have no experience with parsing strings in Ruby or similar languages).
Also, I will look if I can use daru for the input data frames. What to you think?
I have also thought about the output module. Since I don't know in what context users will fit LMMs in Ruby, I decided not to worry about nice presentation of the output in fancy tables (like in R), but instead to give outputs as Hashes. For example, #fix_ef would return a Hash with all information about the estimated fixed effects coefficients; something like:
> model _ fit.fix_ef # => { "Intercept" => 3.32, "Intercept: SD" => 0.2, "Intercept: TS" => 2.54, "Intercept: p-value" => 0.02, "Intercept: 95%CI" => [3.13, 3.45], "Age" => 2.2, "Age: SD" => 1.13, "Age: TS" => 1.54, "Age: p-value" => 0.24, "Age: 95%CI" => [1.13, 3.45], ................. }
Do you think that's okay?
Alexej
> > 4. mailto:[10]sciruby-dev...@googlegroups.com
> > 5. [11]https://groups.google.com/d/optout
>
> --
>
> --
> You received this message because you are subscribed to the Google Groups
> "SciRuby Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [12]sciruby-dev...@googlegroups.com.
> For more options, visit [13]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. http://cran.r-project.org/web/packages/lme4/vignettes/lmer.pdf
> 2. https://github.com/agisga/MixedModels.git
> 3. https://github.com/SciRuby/nmatrix/pull/366
> 4. https://github.com/SciRuby/nmatrix/pull/365
> 5. javascript:
> 6. https://groups.google.com/d/optout
> 7. https://github.com/agisga/MixedModels.git
> 8. https://github.com/SciRuby/nmatrix/pull/366
> 9. https://github.com/SciRuby/nmatrix/pull/365
> 10. javascript:
> 11. https://groups.google.com/d/optout
> 12. mailto:sciruby-dev...@googlegroups.com
> 13. https://groups.google.com/d/optout
--
Maybe I am overcomplicating things. Effect is a vector, right? And the
rest is basically matrix notation. What do the NMatrix people say?
#<LMM_expression:0x007f09bbedf960 @content=[[:z], [:x, :mult, :y], [:one, :pipe, :u]]>
Finally, I could pass formula.content into LMM#from_daru.--
You received this message because you are subscribed to the Google Groups "SciRuby Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sciruby-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
It is no accident you have 2x speedup. It can probably be explained
by your laptop using hyperthreading (so 2 cores look like 4). For CPU
intensive tasks hyperthreading usually gives a 10-20% speedup
depending on IO requirements.