-
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
Finding your way around for R users #1
Comments
That was really very useful. whos() is now a "must know" for me. Interesting that my julia version of April 26, was "way too old" and e.g. couldn't get data(.,.) to work... Thank you, Doug! |
In Julia multiple values are returned from a function as a tuple. You can return (a, b) and extract the values a and b with indexes. A common idiom is to assign n, p = size(X) On Wed, Apr 20, 2016 at 12:13 AM Daijiang Li [email protected]
|
Thanks Prof. Bates! I am new to Julia, even though I attended your Julia workshop two years ago... The code is here. Even now, it is >10 times faster than R. But I wonder can you have a look at them and let me know how to improve/profile it? Is it possible to let your mixed model to do such kind of analyses? Thank you for your help! |
First I would suggest creating a package. Secondly don't pass around a On Thu, Apr 21, 2016 at 10:31 AM Daijiang Li [email protected]
|
Tighten code, increase test coverage (#301)
In private email Martin Maechler asked me several questions about using Julia and the MixedModels package. Because the answers to which may be of more general interest, I created this issue for them so that others may see the answers and comment on them.
I am assuming that a recent version of Julia 0.2 devel is installed. The easiest way to do that for Ubuntu users is using the julianightlies PPA and the julia-deps PPA. As of today, the "nightlies" version produces
on startup. There have been too many changes since the 0.1.2 release to try using that. Please ensure that your version string starts with 0.2.0
The system for attaching packages has changed in version 0.2.0. To install this package use
After that, attaching this and other packages is done with the
using
directive.using MixedModels
More than one package can be listed. For testing I often use
using RDatasets, MixedModels
This directive doesn't return instantaneously but the delay is due to the size and complexity of the
DataFrames
package upon which both of these depend.As in
R
, attaching a package also attaches its dependencies but there are distinctions between those packages that are visible from the REPL and those that are visible only inside the package listed inusing
. The equivalent of R'sls()
iswhos()
and it can take an argument which is the name of a Module. (Most packages are organized as a Module - which is a namespace - but you can have Modules that are not separate packages).It happens that
MixedModels
attaches theDataFrames
andDistributions
namespaces in the REPL as well as its own namespace. However is does not theNLopt
namespace in the REPL. I am not sure how to discover this other than by reading the source code or experimenting with names. The directiveusing MixedModels
evaluates the source filewhich, in turn, has several calls to
include
The fact that this driver file has the directive
using DataFrames, Distributions
both before and after the directive
module MixedModels
means that these namespaces will be visible in the REPL (because of the first
using
) and withing the module itself, because of the secondusing
.You can always try evaluating a name in the namespace to see if it is visible in the REPL.
The fully qualified name will be accessible
Martin asked about the equivalent of R's
installed.packages()
which iswhich is a hash or Dict
A more readable display is returned by
I will be adding an
lmer()
function soon. Right now the package has two user-defined types for simple linear mixed models,LMMsimple
andLMMsplit
because I was experimenting to see if the complexity of handling the fixed-effects part separately from the random-effects part of the model was warranted (and apparently it is). TheLMMsimple
class throws both into a single sparse matrix andupdatemu()
for that class is only four lines.For
LMMsplit
the random-effects part of the system matrix is stored as a sparse symmetric matrix and the fixed-effects part is a dense matrix.The formula/data interface is slightly more verbose than in R. A formula must be enclosed in
:( )
to retain it as an expression. ThusThe first time you do this the response will seem slow, which is because all the methods are being encountered for the first time and need to be compiled. Subsequent calls to will be much faster.
The text was updated successfully, but these errors were encountered: