Skip to content

Commit

Permalink
Reweave docs files
Browse files Browse the repository at this point in the history
  • Loading branch information
dmbates committed Dec 5, 2017
1 parent 7b7a0a3 commit 37d82e2
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 80 deletions.
4 changes: 2 additions & 2 deletions docs/jmd/constructors.jmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ lmm
For illustration, several data sets from the *lme4* package for *R* are made available in `.rda` format in this package.
These include the `Dyestuff` and `Dyestuff2` data sets.
```{julia;term=true}
using DataFrames, RData, MixedModels
using DataFrames, RData, MixedModels, StatsBase
const dat = convert(Dict{Symbol,DataFrame},
load(Pkg.dir("MixedModels", "test", "dat.rda")));
dump(dat[:Dyestuff])
describe(dat[:Dyestuff])
```
The columns in these data sets have been renamed for convenience.
The response is always named `Y`.
Expand Down
96 changes: 48 additions & 48 deletions docs/src/SubjectItem.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,40 @@ julia> const dat = convert(Dict{Symbol,DataFrame}, load(Pkg.dir("MixedModels", "
julia> mm1 = fit!(lmm(@formula(Y ~ 1+S+T+U+V+W+X+Z+(1+S+T+U+V+W+X+Z|G)+(1+S+T+U+V+W+X+Z|H)), dat[:kb07]))
Linear mixed model fit by maximum likelihood
Formula: Y ~ 1 + S + T + U + V + W + X + Z + ((1 + S + T + U + V + W + X + Z) | G) + ((1 + S + T + U + V + W + X + Z) | H)
logLik -2 logLik AIC BIC
-1.42931613×102.85863226×102.87483226×10 2.91930103×10
logLik -2 logLik AIC BIC
-1.4293159×102.8586318×102.8748318×102.91930056×10

Variance components:
Column Variance Std.Dev. Corr.
G (Intercept) 90791.6237 301.316484
S 5187.9402 72.027357 -0.43
T 5552.4111 74.514503 -0.47 0.07
U 7584.6653 87.089984 0.21 -0.20 0.41
V 8841.5313 94.029417 0.20 -0.76 -0.54 -0.20
W 1823.9330 42.707529 0.47 -0.53 -0.11 -0.44 0.29
X 7422.6234 86.154648 -0.10 0.13 -0.05 -0.86 -0.06 0.70
Z 3801.2195 61.654031 -0.48 0.41 -0.38 -0.09 0.18 -0.78 -0.39
H (Intercept) 130031.4034 360.598674
S 1853.0405 43.046957 -0.34
T 62466.7444 249.933480 -0.68 -0.45
U 2941.3214 54.233950 0.20 -0.06 -0.18
V 1037.6157 32.212044 0.57 -0.75 0.02 0.02
W 1619.1082 40.238144 0.28 -0.04 -0.27 0.44 -0.21
X 4706.3361 68.602741 0.08 -0.24 0.21 -0.13 -0.26 0.01
Z 4837.5738 69.552669 0.04 -0.45 0.32 -0.69 0.65 -0.68 -0.10
Residual 399587.7869 632.129565
G (Intercept) 90715.0184 301.189340
S 5180.3901 71.974927 -0.43
T 5543.1348 74.452232 -0.47 0.08
U 7584.8816 87.091226 0.21 -0.20 0.41
V 8832.9843 93.983958 0.20 -0.76 -0.54 -0.20
W 1821.9809 42.684668 0.47 -0.53 -0.11 -0.44 0.28
X 7417.1453 86.122850 -0.10 0.13 -0.05 -0.86 -0.06 0.70
Z 3801.0318 61.652509 -0.47 0.41 -0.39 -0.09 0.18 -0.78 -0.39
H (Intercept) 129690.6871 360.125932
S 1856.9765 43.092650 -0.34
T 62370.7020 249.741270 -0.68 -0.45
U 2950.1553 54.315332 0.20 -0.03 -0.18
V 1042.0598 32.280950 0.57 -0.76 0.02 0.02
W 1620.5108 40.255569 0.28 -0.03 -0.27 0.44 -0.21
X 4703.6870 68.583431 0.08 -0.24 0.21 -0.13 -0.26 0.02
Z 4821.2335 69.435103 0.04 -0.47 0.32 -0.68 0.65 -0.69 -0.10
Residual 399627.0136 632.160592
Number of obs: 1790; levels of grouping factors: 56, 32

Fixed-effects parameters:
Estimate Std.Error z value P(>|z|)
(Intercept) 2180.63 76.8637 28.3701 <1e-99
S -66.9899 19.3343 -3.46482 0.0005
T -333.881 47.6917 -7.00082 <1e-11
U 78.9861 21.2279 3.72087 0.0002
V 22.1509 20.3366 1.08922 0.2761
W -18.9244 17.5052 -1.08107 0.2797
X 5.26196 22.4251 0.234646 0.8145
Z -23.9501 21.0314 -1.13878 0.2548
(Intercept) 2180.63 76.7856 28.3989 <1e-99
S -66.99 19.3346 -3.46478 0.0005
T -333.881 47.6587 -7.00566 <1e-11
U 78.987 21.235 3.71967 0.0002
V 22.1518 20.3368 1.08925 0.2760
W -18.9243 17.5061 -1.08101 0.2797
X 5.26182 22.4216 0.234677 0.8145
Z -23.951 21.0197 -1.13946 0.2545


````
Expand All @@ -65,9 +65,9 @@ xtol_abs: [1.0e-10, 1.0e-10, 1.0e-10, 1.0e-10, 1.0e-10, 1.0e-10,
initial_step: [0.75, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.75, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.75, 1.0, 1.0, 1.0, 1.0, 1.0, 0.75, 1.0, 1.0, 1.0, 1.0, 0.75, 1.0, 1.0, 1.0, 0.75, 1.0, 1.0, 0.75, 1.0, 0.75, 0.75, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.75, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.75, 1.0, 1.0, 1.0, 1.0, 1.0, 0.75, 1.0, 1.0, 1.0, 1.0, 0.75, 1.0, 1.0, 1.0, 0.75, 1.0, 1.0, 0.75, 1.0, 0.75]
maxfeval: -1

Function evaluations: 2150
Final parameter vector: [0.476669, -0.0495603, -0.0559578, 0.0294869, 0.0291771, 0.0319766, -0.0139779, -0.0464195, 0.102601, -0.0172312, -0.0166362, -0.110942, -0.0244482, 0.0126322, 0.0219091, 0.102309, 0.0780709, -0.0945351, 0.00503189, -0.0133206, -0.0649625, 0.108351, 0.00551326, -0.0540187, -0.134323, 0.0515467, 0.0, 0.000989713, 0.00082312, -0.000902588, 0.0, 0.00013651, -0.000244137, 0.0, 6.27183e-9, 0.0, 0.570451, -0.0233509, -0.267494, 0.0174073, 0.0289346, 0.0178525, 0.00842305, 0.00494545, 0.0639696, -0.288241, 0.00128561, -0.0302377, 0.00360149, -0.0252118, -0.050996, 0.0411303, -0.0300041, -0.0137795, -0.0247621, 0.0957016, 0.0127431, 0.07846, -0.0102507, 0.0172816, 0.0193387, -0.0779396, 0.0234571, -0.0529219, -0.0391965, 0.0569404, 0.00277857, -0.00149982, -0.00147603, 0.0, -4.42426e-5, 0.0]
Final objective value: 28586.322643859592
Function evaluations: 2829
Final parameter vector: [0.476444, -0.0495227, -0.0557742, 0.0295214, 0.0292097, 0.0319541, -0.0139336, -0.0463229, 0.102521, -0.0170701, -0.0165868, -0.110967, -0.0243266, 0.0126983, 0.0218126, 0.102316, 0.0781059, -0.0943707, 0.00505476, -0.0135029, -0.0650083, 0.108318, 0.00550319, -0.0540444, -0.134248, 0.0516112, 0.0, 0.000111037, 9.89607e-5, -0.000120772, 0.0, 0.000144849, -0.000171985, 0.0, 1.49074e-5, 0.0, 0.569675, -0.0234122, -0.266913, 0.0173413, 0.0290032, 0.0178621, 0.00844082, 0.0049074, 0.0640206, -0.288127, 0.00329602, -0.0307006, 0.00437284, -0.0241439, -0.053426, 0.0425733, -0.0139551, -0.0162798, -0.0184925, 0.0991966, -0.00479098, 0.0829213, -0.00678668, 0.0223168, 0.000985977, -0.0775749, 0.0226446, -0.0535127, -0.0355039, 0.0560694, 0.00364195, -0.00381326, -0.00114592, 0.0, -5.49465e-5, 0.0]
Final objective value: 28586.31798310179
Return code: FTOL_REACHED


Expand All @@ -77,31 +77,31 @@ Return code: FTOL_REACHED

````julia
julia> mm1.trms[1].Λ
8×8 Array{Float64,2}:
0.476669 0.0 0.0 0.0 0.0 0.0 0.0 0.0
-0.0495603 0.102601 0.0 0.0 0.0 0.0 0.0 0.0
-0.0559578 -0.0172312 0.102309 0.0 0.0 0.0 0.0 0.0
0.0294869 -0.0166362 0.0780709 0.108351 0.0 0.0 0.0 0.0
0.0291771 -0.110942 -0.0945351 0.00551326 0.0 0.0 0.0 0.0
0.0319766 -0.0244482 0.00503189 -0.0540187 0.000989713 0.0 0.0 0.0
-0.0139779 0.0126322 -0.0133206 -0.134323 0.00082312 0.00013651 0.0 0.0
-0.0464195 0.0219091 -0.0649625 0.0515467 -0.000902588 -0.000244137 6.27183e-9 0.0
8×8 LowerTriangular{Float64,Array{Float64,2}}:
0.476444
-0.0495227 0.102521
-0.0557742 -0.0170701 0.102316
0.0295214 -0.0165868 0.0781059 0.108318
0.0292097 -0.110967 -0.0943707 0.00550319 0.0
0.0319541 -0.0243266 0.00505476 -0.0540444 0.000111037 0.0
-0.0139336 0.0126983 -0.0135029 -0.134248 9.89607e-5 0.000144849 0.0
-0.0463229 0.0218126 -0.0650083 0.0516112 -0.000120772 -0.000171985 1.49074e-5 0.0

````



````julia
julia> mm1.trms[2].Λ
8×8 Array{Float64,2}:
0.570451 0.0 0.0 0.0 0.0 0.0 0.0 0.0
-0.0233509 0.0639696 0.0 0.0 0.0 0.0 0.0 0.0
-0.267494 -0.288241 0.0411303 0.0 0.0 0.0 0.0 0.0
0.0174073 0.00128561 -0.0300041 0.07846 0.0 0.0 0.0 0.0
0.0289346 -0.0302377 -0.0137795 -0.0102507 0.0234571 0.0 0.0 0.0
0.0178525 0.00360149 -0.0247621 0.0172816 -0.0529219 0.00277857 0.0 0.0
0.00842305 -0.0252118 0.0957016 0.0193387 -0.0391965 -0.00149982 0.0 0.0
0.00494545 -0.050996 0.0127431 -0.0779396 0.0569404 -0.00147603 -4.42426e-5 0.0
8×8 LowerTriangular{Float64,Array{Float64,2}}:
0.569675
-0.0234122 0.0640206
-0.266913 -0.288127 0.0425733
0.0173413 0.00329602 -0.0139551 0.0829213
0.0290032 -0.0307006 -0.0162798 -0.00678668 0.0226446
0.0178621 0.00437284 -0.0184925 0.0223168 -0.0535127 0.00364195
0.00844082 -0.0241439 0.0991966 0.000985977 -0.0355039 -0.00381326 0.0
0.0049074 -0.053426 -0.00479098 -0.0775749 0.0560694 -0.00114592 -5.49465e-5 0.0

````

Expand Down
31 changes: 22 additions & 9 deletions docs/src/constructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,28 @@ lmm
For illustration, several data sets from the *lme4* package for *R* are made available in `.rda` format in this package.
These include the `Dyestuff` and `Dyestuff2` data sets.
````julia
julia> using DataFrames, RData, MixedModels
julia> using DataFrames, RData, MixedModels, StatsBase

julia> const dat = convert(Dict{Symbol,DataFrame},
load(Pkg.dir("MixedModels", "test", "dat.rda")));

julia> dump(dat[:Dyestuff])
DataFrames.DataFrame 30 observations of 2 variables
G: DataArrays.PooledDataArray{String,UInt8,1}(30) String["A", "A", "A", "A"]
Y: DataArrays.DataArray{Float64,1}(30) [1545.0, 1440.0, 1440.0, 1520.0]
julia> describe(dat[:Dyestuff])
G
Summary Stats:
Length: 30
Type: CategoricalArrays.CategoricalString{UInt8}
Number Unique: 6

Y
Summary Stats:
Mean: 1527.500000
Minimum: 1440.000000
1st Quartile: 1468.750000
Median: 1530.000000
3rd Quartile: 1575.000000
Maximum: 1635.000000
Length: 30
Type: Float64


````
Expand Down Expand Up @@ -67,7 +80,7 @@ The second and subsequent calls to such functions are much faster.)

````julia
julia> @time fit!(lmm(@formula(Y ~ 1 + (1|G)), dat[:Dyestuff2]))
0.000860 seconds (1.40 k allocations: 75.156 KiB)
0.000941 seconds (1.44 k allocations: 74.375 KiB)
Linear mixed model fit by maximum likelihood
Formula: Y ~ 1 + (1 | G)
logLik -2 logLik AIC BIC
Expand Down Expand Up @@ -141,7 +154,7 @@ Linear mixed model fit by maximum likelihood

Variance components:
Column Variance Std.Dev. Corr.
G (Intercept) 584.258968 24.17145
G (Intercept) 584.258971 24.17145
U 33.632805 5.79938 0.00
Residual 653.115782 25.55613
Number of obs: 180; levels of grouping factors: 18
Expand Down Expand Up @@ -511,10 +524,10 @@ sdest
```
````julia
julia> varest(fm2)
654.9414511016189
654.9414530367545

julia> sdest(fm2)
25.591823911195128
25.591823949002823

````

Expand Down
Loading

0 comments on commit 37d82e2

Please sign in to comment.