In [1]:
using MixedModels
versioninfo(true)
Julia Version 0.3.0-prerelease+3123
Commit 0a5e89c* (2014-05-20 13:53 UTC)
Platform Info:
System: Linux (x86_64-pc-linux-gnu)
CPU: AMD Athlon(tm) II X4 635 Processor
WORD_SIZE: 64
Ubuntu 14.04 LTS
uname: Linux 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64
Memory: 7.796886444091797 GB (3694.8359375 MB free)
Uptime: 65958.0 sec
Load Avg: 1.6064453125 1.42919921875 1.39892578125
AMD Athlon(tm) II X4 635 Processor:
speed user nice sys idle irq
#1 2900 MHz 58224 s 21251 s 16520 s 6484610 s 867 s
#2 2900 MHz 71361 s 19819 s 15372 s 6477851 s 618 s
#3 2900 MHz 118766 s 18500 s 19167 s 6224736 s 2223 s
#4 800 MHz 61193 s 12228 s 18799 s 6472977 s 6419 s
BLAS: libopenblas (NO_LAPACK NO_LAPACKE DYNAMIC_ARCH NO_AFFINITY)
LAPACK: liblapack
LIBM: libopenlibm
Environment:
MANDATORY_PATH = /usr/share/gconf/awesome.mandatory.path
PATH = /home/bates/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
TERM = dumb
XDG_SESSION_PATH = /org/freedesktop/DisplayManager/Session2
HOME = /home/bates
XDG_SEAT_PATH = /org/freedesktop/DisplayManager/Seat0
DEFAULTS_PATH = /usr/share/gconf/awesome.default.path
Package Directory: /home/bates/.julia/v0.3
14 required packages:
- CUDA 0.1.0
- Cbc 0.0.7
- Clang 0.0.1
- Clp 0.0.7
- GLM 0.3.2
- GLPK 0.2.11
- GLPKMathProgInterface 0.1.4
- Gadfly 0.2.8
- IJulia 0.1.9
- JuMP 0.5.2
- MAT 0.2.4
- Metis 0.0.2
- MixedModels 0.3.1 master
- RDatasets 0.1.1
38 additional packages:
- ArrayViews 0.4.4
- BinDeps 0.2.12
- Blocks 0.0.3
- Calculus 0.1.3
- Codecs 0.1.0
- Color 0.2.9
- Compose 0.1.28
- DataArrays 0.1.9
- DataFrames 0.5.4
- DataStructures 0.2.13
- Datetime 0.1.3
- Distance 0.3.2
- Distributions 0.4.6
- DualNumbers 0.1.0
- GZip 0.2.12
- Graphs 0.4.2
- HDF5 0.2.23
- Hexagons 0.0.1
- Iterators 0.1.2
- JSON 0.3.5
- Loess 0.0.2
- MUMPS 0.0.1+ master (dirty)
- MUMPS1 0.0.0- master (unregistered, dirty)
- MathProgBase 0.1.6
- NLopt 0.0.3
- Nettle 0.1.4
- NumericExtensions 0.6.2
- NumericFuns 0.2.3
- PDMats 0.1.2
- REPLCompletions 0.0.0
- Reexport 0.0.1
- ReverseDiffSparse 0.1.0
- SortingAlgorithms 0.0.1
- StatsBase 0.3.12
- SuperLU 0.0.0- master (unregistered, dirty)
- URIParser 0.0.2
- ZMQ 0.1.11
- Zlib 0.1.7
In [3]:
mm0 = DataFrame(read_rda("../mm0.RData")["mm0"])
Out[3]:
mean sdiff ambiguity subj item 1 -2.8372 2045.558659539001 unambig 01 33 2 -1.4067 2045.558659539001 unambig 01 33 3 -3.0055 2045.558659539001 unambig 01 33 4 -4.0167 2045.558659539001 unambig 01 33 5 -1.5048 -1042.441340460999 ambig 01 56 6 -2.502 -1042.441340460999 ambig 01 56 7 -1.2454 -1042.441340460999 ambig 01 56 8 -3.0896 -1042.441340460999 ambig 01 56 9 -8.1918 1957.558659539001 unambig 01 20 10 -8.1806 1957.558659539001 unambig 01 20 11 -8.5901 1957.558659539001 unambig 01 20 12 -7.8089 1957.558659539001 unambig 01 20 13 2.8722 -2042.441340460999 unambig 01 2 14 1.6689 -2042.441340460999 unambig 01 2 15 -0.70684 -2042.441340460999 unambig 01 2 16 -0.17952 -2042.441340460999 unambig 01 2 17 -6.5411 -1053.441340460999 ambig 01 13 18 -9.5143 -1053.441340460999 ambig 01 13 19 -2.9382 -1053.441340460999 ambig 01 13 20 -3.5104 -1053.441340460999 ambig 01 13 21 -4.7557 1946.558659539001 unambig 01 46 22 -5.1288 1946.558659539001 unambig 01 46 23 -2.2103 1946.558659539001 unambig 01 46 24 -4.1751 1946.558659539001 unambig 01 46 25 -1.2201 2045.558659539001 unambig 01 32 26 -0.63251 2045.558659539001 unambig 01 32 27 -4.0742 2045.558659539001 unambig 01 32 28 -3.6618 2045.558659539001 unambig 01 32 29 -2.3575 -943.4413404609991 ambig 01 31 30 -3.8526 -943.4413404609991 ambig 01 31 &vellip &vellip &vellip &vellip &vellip &vellip
It appears that the sdiff column is already centered.
In [4]:
mean(mm0[:sdiff])
Out[4]:
1.4144035843229623e-13
In [5]:
lm0 = fit(lmm(mean ~ ambiguity * sdiff + (sdiff|item) + (sdiff|subj), mm0),true)
f_1: 397284.05776, [1.0,0.0,1.0,1.0,0.0,1.0]
f_2: 397350.19041, [1.75,0.0,1.0,1.0,0.0,1.0]
f_3: 397284.98471, [1.0,1.0,1.0,1.0,0.0,1.0]
f_4: 397350.67281, [1.0,0.0,1.75,1.0,0.0,1.0]
f_5: 397323.34288, [1.0,0.0,1.0,1.75,0.0,1.0]
f_6: 397286.9838, [1.0,0.0,1.0,1.0,1.0,1.0]
f_7: 397325.1724, [1.0,0.0,1.0,1.0,0.0,1.75]
f_8: 397130.63492, [0.25,0.0,1.0,1.0,0.0,1.0]
f_9: 397284.9847, [1.0,-1.0,1.0,1.0,0.0,1.0]
f_10: 397120.03245, [1.0,0.0,0.25,1.0,0.0,1.0]
f_11: 397223.77895, [1.0,0.0,1.0,0.25,0.0,1.0]
f_12: 397286.98329, [1.0,0.0,1.0,1.0,-1.0,1.0]
f_13: 397183.37728, [1.0,0.0,1.0,1.0,0.0,0.25]
f_14: 396140.41478, [0.401307,-1.56017e-8,0.0,0.819552,-1.01256e-6,0.66984]
f_15: 400653.42336, [0.0,-8.81177e-8,0.0,0.0,-5.71644e-6,0.0]
f_16: 396118.91063, [0.166608,2.39985e-8,0.0,1.50128,1.5504e-6,0.876404]
f_17: 396248.11692, [0.593565,5.97111e-8,0.0,1.03623,3.87485e-6,1.2813]
f_18: 396159.71274, [0.358697,-1.48434e-8,0.0,1.56169,-9.6566e-7,0.560055]
f_19: 396139.83951, [0.183269,3.52101e-8,0.0,1.6514,2.27709e-6,0.964045]
f_20: 396312.09266, [0.0304974,-4.94473e-8,0.0,1.56489,-3.23502e-6,0.98858]
f_21: 396770.40133, [0.205954,2.28655e-8,0.0472119,1.47761,0.0472134,0.88224]
f_22: 396121.35051, [0.172467,9.89766e-8,0.0,1.50141,-0.0996898,0.875829]
f_23: 397380.98095, [0.168518,-0.0998477,0.000419115,1.50428,-0.000447494,0.874362]
f_24: 397381.2393, [0.166236,0.099898,0.0,1.5018,-0.000361349,0.87309]
f_25: 396796.2741, [0.172151,2.24036e-8,0.06646,1.46796,1.44736e-6,0.884619]
f_26: 396649.15406, [0.145039,-0.000282967,0.0,1.44364,-0.012724,0.918203]
f_27: 396796.3106, [0.213567,2.26463e-8,0.0563467,1.51529,1.46304e-6,0.883369]
f_28: 396854.30134, [0.125555,0.00119167,0.0,1.53198,-0.00173898,0.821682]
f_29: 396237.45168, [0.199199,6.29861e-5,0.0,1.49462,-0.0158415,0.863813]
f_30: 396121.75016, [0.176213,2.20564e-8,0.0,1.5043,1.4246e-6,0.860587]
f_31: 396798.72135, [0.169598,0.000750839,0.0,1.51558,0.00942447,0.88578]
f_32: 396412.79667, [0.159808,-9.58204e-5,0.00266976,1.50277,-0.000498116,0.875685]
f_33: 396552.07788, [0.168516,-0.00019704,0.0,1.49432,-0.0014433,0.874669]
f_34: 396523.30691, [0.167163,2.3839e-8,0.006646,1.49795,1.5401e-6,0.877226]
f_35: 396406.2633, [0.16825,0.000113624,0.0,1.5043,-0.00865248,0.877924]
f_36: 396150.54884, [0.164452,-2.82751e-5,0.0,1.49551,-0.001271,0.880584]
f_37: 396208.22104, [0.166661,-4.97668e-5,0.0,1.50104,0.00993012,0.877265]
f_38: 397109.66901, [0.166646,-0.00998977,0.0,1.50122,3.78404e-5,0.876736]
f_39: 397107.64659, [0.166546,0.00980037,0.0,1.50223,0.0013224,0.87697]
f_40: 396759.01353, [0.167111,-0.000578639,0.0,1.50425,0.00255733,0.875341]
f_41: 396281.69791, [0.167321,2.3978e-8,0.000855241,1.50149,1.54908e-6,0.87651]
f_42: 396123.53195, [0.165512,9.82553e-6,0.0,1.50072,-0.000102135,0.877819]
f_43: 396162.84007, [0.166799,3.19256e-5,0.0,1.50111,-0.000196424,0.875715]
f_44: 396175.96209, [0.166982,-3.86235e-5,0.0,1.50116,0.000251763,0.877016]
f_45: 396151.34969, [0.166237,-2.86171e-5,0.0,1.50131,-1.37096e-5,0.876421]
f_46: 396606.22739, [0.16661,-0.000244985,0.0,1.50125,-3.14708e-5,0.87639]
f_47: 396615.77322, [0.166605,0.000249314,0.0,1.50129,1.08636e-5,0.87641]
f_48: 396118.87982, [0.166592,-1.112e-6,0.0,1.50125,8.80907e-5,0.876389]
f_49: 396125.84431, [0.166602,-1.33321e-5,0.0,1.50131,0.000132475,0.876391]
f_50: 396118.96425, [0.166576,-2.248e-6,0.0,1.50122,0.000174631,0.876374]
f_51: 396121.71424, [0.166586,-8.75047e-6,0.0,1.50122,0.000104894,0.876457]
f_52: 396119.11801, [0.166611,-3.0759e-6,0.0,1.50118,7.27407e-5,0.876372]
f_53: 395994.74456, [0.166558,-5.43771e-7,5.63154e-5,1.50123,5.24359e-5,0.876371]
f_54: 396114.27077, [0.166533,1.27605e-6,0.000202806,1.50122,3.53732e-5,0.87636]
f_55: 395996.71576, [0.166547,1.097e-5,5.7437e-5,1.50117,2.54641e-6,0.876392]
f_56: 395982.90418, [0.166507,5.1231e-6,3.49702e-5,1.50123,4.51178e-5,0.876321]
f_57: 396134.48398, [0.166503,1.82164e-5,0.0,1.50117,5.74864e-5,0.876284]
f_58: 395995.38531, [0.166504,5.50964e-6,5.67414e-5,1.50127,-2.89385e-6,0.876283]
f_59: 395988.17405, [0.166496,-7.53421e-6,4.85699e-5,1.50125,7.18899e-5,0.876336]
f_60: 395983.30948, [0.166515,5.83335e-6,3.40435e-5,1.50122,3.87171e-5,0.876305]
f_61: 395983.38661, [0.166517,4.69369e-6,4.08285e-5,1.50123,2.71342e-5,0.876325]
f_62: 395983.04671, [0.1665,4.17429e-6,3.39868e-5,1.50123,4.34635e-5,0.876324]
f_63: 395984.66284, [0.166507,1.2303e-5,3.96753e-5,1.50123,4.76587e-5,0.876319]
f_64: 395986.04108, [0.166511,1.40179e-5,3.36964e-5,1.50123,4.38701e-5,0.876324]
f_65: 395982.83132, [0.16651,-2.84095e-6,3.38259e-5,1.50123,4.71697e-5,0.876319]
f_66: 395985.34762, [0.166513,-1.1925e-5,3.25569e-5,1.50123,4.42195e-5,0.876321]
f_67: 395983.28641, [0.166509,-4.64687e-6,4.09589e-5,1.50123,4.89322e-5,0.876317]
f_68: 395992.40238, [0.166508,-3.0435e-6,2.55122e-5,1.50123,4.77501e-5,0.876317]
f_69: 395982.37807, [0.166515,-8.50608e-7,3.83368e-5,1.50124,4.61926e-5,0.876321]
f_70: 395982.29996, [0.166521,-9.97624e-7,3.5804e-5,1.50123,4.79465e-5,0.876324]
f_71: 395982.30107, [0.16652,1.00684e-6,3.6216e-5,1.50123,4.82638e-5,0.876331]
f_72: 395982.27789, [0.166523,8.02649e-7,3.6601e-5,1.50123,4.74871e-5,0.876321]
f_73: 395982.30192, [0.166524,6.68874e-7,3.60286e-5,1.50123,4.8919e-5,0.876323]
f_74: 395982.29116, [0.166524,6.4253e-7,3.61594e-5,1.50123,4.96297e-5,0.876323]
f_75: 395982.25381, [0.166524,-1.84093e-7,3.69734e-5,1.50123,4.74636e-5,0.876321]
f_76: 395982.2484, [0.166524,-5.53068e-7,3.66799e-5,1.50123,4.63081e-5,0.876321]
f_77: 395982.25015, [0.166523,-5.30195e-7,3.6956e-5,1.50123,4.61456e-5,0.876321]
f_78: 395982.25617, [0.166524,-3.87066e-7,3.63972e-5,1.50123,4.56998e-5,0.876321]
f_79: 395982.25238, [0.166524,-4.35604e-7,3.70035e-5,1.50123,4.57237e-5,0.876322]
f_80: 395982.25218, [0.166523,-2.46806e-7,3.65535e-5,1.50123,4.59441e-5,0.87632]
f_81: 395982.25082, [0.166523,-1.96421e-7,3.67971e-5,1.50123,4.55019e-5,0.87632]
f_82: 395982.25532, [0.166524,-1.21989e-6,3.65246e-5,1.50123,4.6238e-5,0.876321]
f_83: 395982.24859, [0.166524,-7.47725e-7,3.6674e-5,1.50123,4.6963e-5,0.876322]
f_84: 395982.25411, [0.166524,-8.60973e-7,3.64365e-5,1.50123,4.74333e-5,0.876321]
f_85: 395982.24843, [0.166524,-5.78334e-7,3.67822e-5,1.50123,4.68949e-5,0.876321]
SUCCESS
Out[5]:
Linear mixed model fit by maximum likelihood
logLik: -197991.124215, deviance: 395982.248430
Variance components:
Variance Std.Dev.
item 0.470864 0.686195
0.000000 0.000152
subj 38.267833 6.186100
13.039647 3.611045
Residual 16.980082 4.120689
Number of obs: 69588; levels of grouping factors: 60, 37
Fixed-effects parameters:
Estimate Std.Error z value
[1] 1.15876 1.02108 1.13484
[2] 0.496996 0.0312451 15.9063
[3] -0.000387593 0.593657 -0.000652892
[4] 0.000381613 2.46849e-5 15.4594
One of the problems here is that the range of values of sdiff is so large that the variance of the random slopes converges to a very small value, making it difficult to assess convergence.
In [6]:
extrema(mm0[:sdiff])
Out[6]:
(-2053.441340460999,2056.558659539001)
In [7]:
mm0[:ssdiff] = mm0[:sdiff]/1000.
Out[7]:
69588-element DataArray{Float64,1}:
2.04556
2.04556
2.04556
2.04556
-1.04244
-1.04244
-1.04244
-1.04244
1.95756
1.95756
1.95756
1.95756
-2.04244
⋮
-1.95444
-1.95444
-1.95444
-1.95444
2.05656
2.05656
2.05656
2.05656
2.05656
2.05656
2.05656
2.05656
In [8]:
lm1 = fit(lmm(mean ~ ambiguity*ssdiff+(ssdiff|item)+(ssdiff|subj),mm0))
Out[8]:
Linear mixed model fit by maximum likelihood
logLik: -197584.418259, deviance: 395168.836519
Variance components:
Variance Std.Dev.
item 0.176411 0.420013
0.022679 0.150594
subj 1.233113 1.110456
0.023150 0.152152
Residual 17.006708 4.123919
Number of obs: 69588; levels of grouping factors: 60, 37
Fixed-effects parameters:
Estimate Std.Error z value
[1] 1.15861 0.191523 6.04943
[2] 0.497135 0.0312694 15.8985
[3] -0.387581 0.0396038 -9.78645
[4] 0.381601 0.0247042 15.4468
In [9]:
names(lm1)
Out[9]:
18-element Array{Symbol,1}:
:L
:LambdatZt
:RX
:X
:Xs
:XtX
:Xty
:beta
:fnms
:inds
:lambda
:mu
:perm
:pvec
:u
:y
:REML
:fit
In [10]:
lm1.lambda
Out[10]:
2-element Array{Array{Float64,2},1}:
2x2 Array{Float64,2}:
0.101847 0.0
-0.000448034 0.0365172
2x2 Array{Float64,2}:
0.268964 0.0
-0.0128854 0.036895
In [11]:
cor(lm1)
Out[11]:
2-element Array{Array{Float64,2},1}:
2x2 Array{Float64,2}:
1.0 -0.0122682
-0.0122682 1.0
2x2 Array{Float64,2}:
1.0 -0.329716
-0.329716 1.0
The show method for this type of linear mixed model is not complete in that it does not give the estimated correlation of the vector-valued random effects. These are given by the cor method above.
Content source: lme4/lme4-convergence
Similar notebooks: