Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PharmCat committed Jan 24, 2021
1 parent 0aa1f09 commit 20c8f5c
Show file tree
Hide file tree
Showing 28 changed files with 929 additions and 860 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
src/temp.jl
test/precompile/
test/devtest.jl
test/dstest.jl
test/snoopy.jl
examples/
docs/build/
docs/img/
etc/
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Metida"
uuid = "a1dec852-9fe5-11e9-361f-8d9fde67cfa2"
authors = ["Vladimir Arnautov <[email protected]>"]
version = "0.1.14"
version = "0.2.0"

[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Expand Down Expand Up @@ -29,7 +29,8 @@ julia = "1.1, 1.2, 1.3, 1.4, 1.5, 1.6"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "CSV", "DataFrames", "StatsBase"]
test = ["Test", "CSV", "DataFrames", "StatsBase", "StatsModels"]
8 changes: 8 additions & 0 deletions change.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
- 0.2.0
* many changes in VarianceType, covariance structure
* code cleaning
* change methods names
* rmatrix / gmatrix
* StatsBase methods
* test and other

- 0.1.13

* output fix
Expand Down
10 changes: 10 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,13 @@ Metida.CompoundSymmetry
```@docs
Metida.HeterogeneousCompoundSymmetry
```

### Metida.gmatrix
```@docs
Metida.gmatrix
```

### Metida.rmatrix
```@docs
Metida.rmatrix
```
60 changes: 58 additions & 2 deletions docs/src/ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,74 @@
### Sweep algorithm

* Sweep based on [SweepOperator.jl](https://github.com/joshday/SweepOperator.jl). Thanks to @joshday and @Hua-Zhou.

* http://hua-zhou.github.io/teaching/biostatm280-2019spring/slides/12-sweep/sweep.html

More:

* Section 7.4-7.6 of Numerical Analysis for Statisticians by Kenneth Lange (2010).
* Section 7.4-7.6 of Numerical Analysis for Statisticians by Kenneth Lange (2010).

* The paper A tutorial on the SWEEP operator by James H. Goodnight (1979).


### REML
### REML & Parameter estimation

* Henderson, C. R., et al. “The Estimation of Environmental and Genetic Trends from Records Subject to Culling.” Biometrics, vol. 15, no. 2, 1959, pp. 192–218. JSTOR, www.jstor.org/stable/2527669.

* Lindstrom & J.; Bates, M. (1988). Newton—Raphson and EM Algorithms for Linear Mixed-Effects Models for Repeated-Measures Data. Journal of the American Statistical Association. 83. 1014. 10.1080/01621459.1988.10478693.

* Gurka, Matthew. (2006). Selecting the Best Linear Mixed Model under REML. The American Statistician. 60. 19-26. 10.1198/000313006X90396.

* Sang Hong Lee, Julius H.J. van der Werf. An efficient variance component approach implementing an average information REML suitable for combined LD and linkage mapping with a general complex pedigree. Genetics Selection Evolution, BioMed Central, 2006, 38 (1), pp.25-43. ⟨hal-00894558⟩

* F.N. Gumedze, T.T. Dunne, Parameter estimation and inference in the linear mixed model, Linear Algebra and its Applications, Volume 435, Issue 8, 2011, Pages 1920-1944, ISSN 0024-3795, https://doi.org/10.1016/j.laa.2011.04.015. (http://www.sciencedirect.com/science/article/pii/S002437951100320X)

### AI algorithm

* D.L. Johnson, R. Thompson, Restricted Maximum Likelihood Estimation of Variance Components for Univariate Animal Models Using Sparse Matrix Techniques and Average Information, Journal of Dairy Science, Volume 78, Issue 2, 1995, Pages 449-456, ISSN 0022-0302, https://doi.org/10.3168/jds.S0022-0302(95)76654-1. (http://www.sciencedirect.com/science/article/pii/S0022030295766541)

* Mishchenko, Kateryna & Holmgren, Sverker & Rönnegård, Lars. (2007). Newton-type Methods for REML Estimation in Genetic Analysis of Quantitative Traits. Journal of Computational Methods in Science and Engineering. 8. 10.3233/JCM-2008-81-203.

* Matilainen K, Mäntysaari EA, Lidauer MH, Strandén I, Thompson R. Employing a Monte Carlo algorithm in Newton-type methods for restricted maximum likelihood estimation of genetic parameters. PLoS One. 2013;8(12):e80821. Published 2013 Dec 10. doi:10.1371/journal.pone.0080821

### Covariance structures

* Wolfinger, Russ. (1993). Covariance structure selection in general mixed models. Communications in Statistics-simulation and Computation - COMMUN STATIST-SIMULAT COMPUT. 22. 1079-1106. 10.1080/03610919308813143.

* Littell, Ramon & Pendergast, Jane & Natarajan, Ranjini. (2000). Modelling covariance structure in the analysis of repeated measures data. Statistics in Medicine. 19. 1793-1819. 10.1002/1097-0258(20000715)19:13%3C1793::AID-SIM482%3E3.0.CO;2-Q.

* QUINTAL, SILVANA SILVA RED, VIANA, ALEXANDRE PIO, CAMPOS, BIANCA MACHADO, VIVAS, MARCELO, & AMARAL JÚNIOR, ANTONIO TEIXEIRA DO. (2017). ANALYSIS OF STRUCTURES OF COVARIANCE AND REPEATABILITY IN GUAVA SEGREGANTING POPULATION. Revista Caatinga, 30(4), 885-891. https://doi.org/10.1590/1983-21252017v30n408rc

* McNeish, D., Harring, J. Covariance pattern mixture models: Eliminating random effects to improve convergence and performance. Behav Res 52, 947–979 (2020). https://doi.org/10.3758/s13428-019-01292-4

### And more

* Laird, Nan M., and James H. Ware. “Random-Effects Models for Longitudinal Data.” Biometrics, vol. 38, no. 4, 1982, pp. 963–974. JSTOR, www.jstor.org/stable/2529876.

* Giesbrecht, F. G., and Burns, J. C. (1985), "Two-Stage Analysis Based on a Mixed Model: Large-sample Asymptotic Theory and Small-Sample Simulation Results," Biometrics, 41, 853-862.

* Jennrich, R., & Schluchter, M. (1986). Unbalanced Repeated-Measures Models with Structured Covariance Matrices. Biometrics, 42(4), 805-820. doi:10.2307/2530695

* Fletcher, Roger (1987), Practical methods of optimization (2nd ed.), New York: John Wiley & Sons, ISBN 978-0-471-91547-8

* Wolfinger et al., (1994) Computing gaussian likelihoods and their derivatives for general linear mixed models doi: 10.1137/0915079

* Hrong-Tai Fai & Cornelius (1996) Approximate F-tests of multiple degree of freedom hypotheses in generalized least squares analyses of unbalanced split-plot experiments, Journal of Statistical Computation and Simulation, 54:4, 363-378, DOI: 10.1080/00949659608811740

* Schaalje GB, McBride JB, Fellingham GW. Adequacy of approximations to distributions of test statistics in complex mixed linear models. J Agric Biol Environ Stat. 2002;7:512–24.

* Wright, Stephen, and Jorge Nocedal (2006) "Numerical optimization." Springer

* Van Peer, A. (2010), Variability and Impact on Design of Bioequivalence Studies. Basic & Clinical Pharmacology & Toxicology, 106: 146-153. doi:10.1111/j.1742-7843.2009.00485.x

### Julia packages

* Revels, Jarrett & Lubin, Miles & Papamarkou, Theodore. (2016). Forward-Mode Automatic Differentiation in Julia.

* Mogensen et al., (2018). Optim: A mathematical optimization package for Julia. Journal of Open Source Software, 3(24), 615,doi: 10.21105/joss.00615

### CuSolver & CuBLAS

* https://docs.nvidia.com/cuda/cusolver/index.html

* https://docs.nvidia.com/cuda/cublas/index.htm
77 changes: 76 additions & 1 deletion docs/src/validation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,81 @@
## Validation

### sleepstudy.csv

| Model | REML Metida | REML SPSS|
|--------|--------|-------|
| 1 | 1729.4925602367025 | 1729.492560 |
| 2 | 1904.3265170722132 | 1662.172084 |
| 3 | 1772.0953251997046 | 1772.095 |
| 4 | 1730.1895427398322 | 1730.189543 |


#### Model 1

```
lmm = Metida.LMM(@formula(Reaction~Days), df;
random = Metida.VarEffect(Metida.SI),
subject = :Subject
)
Metida.fit!(lmm)
```

```
```
#### Model 2

```
lmm = Metida.LMM(@formula(Reaction~1), df;
random = Metida.VarEffect(Metida.@covstr(Days), Metida.CS),
subject = :Subject
)
Metida.fit!(lmm)
```

```
```

#### Model 3

```
lmm = Metida.LMM(@formula(Reaction~1), df;
random = Metida.VarEffect(Metida.@covstr(Days), Metida.CSH, subj = :Subject)
)
Metida.fit!(lmm)
```

```
```

#### Model 4

```
lmm = Metida.LMM(@formula(Reaction~1), df;
random = Metida.VarEffect(Metida.@covstr(Days), Metida.ARH, subj = :Subject)
)
Metida.fit!(lmm)
```

```
```

### Pastes.csv

| Model | REML Metida | REML SPSS|
|--------|--------|-------|
| 5 | 246.99074585348623 | 246.990746 |

#### Model 5

```
lmm = Metida.LMM(@formula(strength~1), df;
random = [Metida.VarEffect(Metida.SI, subj = :batch), Metida.VarEffect(Metida.SI, subj = [:batch, :cask])]
)
Metida.fit!(lmm)
```

```
```

### Reference dataset

Expand All @@ -20,4 +95,4 @@ Anglin, P.M. and R. Gencay (1996) “Semiparametric estimation of a hedonic pric
Anglin, P., and Gencay, R. (1996). Semiparametric Estimation of a Hedonic Price Function. Journal of Applied Econometrics, 11, 633–648.

Verbeek, M. (2004). A Guide to Modern Econometrics, 2nd ed. Chichester, UK: John Wiley.
O'Brien, R. G., and Kaiser, M. K. (1985) MANOVA method for analyzing repeated measures designs: An extensive primer. Psychological Bulletin 97, 316–333, Table 7.
O'Brien, R. G., and Kaiser, M. K. (1985) MANOVA method for analyzing repeated measures designs: An extensive primer. Psychological Bulletin 97, 316–333, Table 7.
16 changes: 12 additions & 4 deletions src/Metida.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ fit!, LMM, VarEffect, theta, logreml, m2logreml, thetalength

include("abstracttype.jl")
include("sweep.jl")
include("utils.jl")
include("varstruct.jl")
include("gmat.jl")
include("rmat.jl")
Expand All @@ -40,6 +39,7 @@ include("fit.jl")
include("showutils.jl")
include("statsbase.jl")
include("initg.jl")
include("utils.jl")

function __init__()

Expand All @@ -48,16 +48,24 @@ end
function _precompile_()
ccall(:jl_generating_output, Cint, ()) == 1 || return nothing
isdefined(Metida, Symbol("#@covstr")) && precompile(Tuple{getfield(Metida, Symbol("#@covstr")), LineNumberNode, Module, Int})
precompile(Tuple{typeof(Metida.ffx), Int64})
precompile(Tuple{typeof(Metida.ffxpone), Int64})

precompile(Tuple{typeof(Metida.reml_sweep_β), Metida.LMM{Float64}, Array{Float64, 1}})
precompile(Tuple{typeof(Metida.reml_sweep_β_b), Metida.LMM{Float64}, Array{Float64, 1}})

precompile(Tuple{typeof(Metida.rholinkpsigmoid), Float64})
precompile(Tuple{typeof(Metida.rholinkpsigmoidr), Float64})

precompile(Tuple{typeof(Metida.varlinkvecapply!), Array{Float64, 1}, Array{Symbol, 1}})
precompile(Tuple{typeof(Metida.varlinkrvecapply!), Array{Float64, 1}, Array{Symbol, 1}})
precompile(Tuple{typeof(Metida.varlinkvecapply), Array{Float64, 1}, Array{Symbol, 1}})

precompile(Tuple{typeof(Metida.varlinkvecapply!), Array{Float64, 1}, Array{Function, 1}})
precompile(Tuple{typeof(Metida.vlink), Float64})
precompile(Tuple{typeof(Metida.vlinkr), Float64})

precompile(Tuple{typeof(Metida.initvar), Array{Float64, 1}, Array{Float64, 2}})

precompile(Tuple{typeof(Metida.intersectsubj), Array{VarEffect, 1}, VarEffect})

end
_precompile_()
#include(".jl")
Expand Down
Loading

0 comments on commit 20c8f5c

Please sign in to comment.