From 4b7fb8b605eb88120ea5aac232db5895d266a66a Mon Sep 17 00:00:00 2001 From: PharmCat Date: Tue, 16 Feb 2021 23:08:15 +0300 Subject: [PATCH] update --- README.md | 4 +-- docs/src/validation.md | 61 +++++++++++++++++++++++++++++++++++++++++- test/test.jl | 2 +- 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2b19a7dc..390cc838 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,8 @@ import Pkg; Pkg.add("Metida") Using: ``` -using Metida, StatsBase, StatsModels, CSV, DataFrames -df = CSV.File(dirname(pathof(Metida))*"\\..\\test\\csv\\df0.csv") |> DataFrame +using Metida, CSV, DataFrames +df = CSV.File(joinpath(dirname(pathof(Metida)),"..","test","csv","df0.csv")) |> DataFrame categorical!(df, :subject); categorical!(df, :period); categorical!(df, :sequence); diff --git a/docs/src/validation.md b/docs/src/validation.md index 2d57f2a4..03fe3861 100644 --- a/docs/src/validation.md +++ b/docs/src/validation.md @@ -5,6 +5,12 @@ Validation provided with 3 sections: * Parameters validation for public datasets Metida & SPSS & MixedModels * Validation with bioequivalence datasets with Metida & SPSS +To run validation: + +``` +using Metida; include(joinpath(dirname(pathof(Metida)), "..", "test", "validation.jl")) +``` + ## Section 1: REML validation for public datasets Metida & SPSS #### REML result table @@ -212,7 +218,26 @@ SPSS: ## Section 2: Parameters validation for public datasets Metida & SPSS & MixedModels -not done yet +##### Model 7 +``` +lmm = LMM(@formula(diameter ~ 1), df; +random = [VarEffect(@covstr(1|plate), SI), VarEffect(@covstr(1|sample), SI)] +) +fit!(lmm) +``` + +| Model | Parameter | Value Metida | Value MM | Value SPSS | +|--------|--------|--------|--------|-------| +| 7 | (Intercept) estimate | 22.9722 | | | +| 7 | (Intercept) SE | 0.808573 | | | +| 7 | plate σ² | 0.716908 | | | +| 7 | sample σ² | 3.73092 | | | +| 7 | Residual σ²| 0.302415 | | | +| | | | | | +| | | | | | +| | | | | | +| | | | | | +| | | | | | ## Section 3: Validation with bioequivalence datasets with Metida & SPSS @@ -257,6 +282,40 @@ MIXED lnpk BY period treatment sequence subject /REPEATED=treatment | SUBJECT(subject*period) COVTYPE(DIAG) /EMMEANS=TABLES(treatment) COMPARE REFCAT(FIRST) ADJ(LSD). ``` +#### Results + +| DatasSet | REML Model 1 | +|--------|--------| +| 01 | 530.1445193510292 | +| 02 | -30.67455875307806 | +| 03 | 425.44656318173423 | +| 04 | 314.22176883261096 | +| 05 | -74.87997706595712 | +| 06 | 530.1445193182162 | +| 07 | 1387.0928273412144 | +| 08 | 2342.5993980030553 | +| 09 | 2983.26033032097 | +| 10 | -16.41729812792036 | +| 11 | 250.94514897106058 | +| 12 | 1140.3816624784859 | +| 13 | 2087.481017283834 | +| 14 | 1012.351698923092 | +| 15 | 2087.481017283834 | +| 16 | 323.99767383075243 | +| 17 | 77.56902301272578 | +| 18 | 904.8743799636109 | +| 19 | 782.9395904949903 | +| 20 | 796.3124436472704 | +| 21 |470.59083255259935 | +| 22 | 248.99027587947566 | +| 23 | 119.80621157945501 | +| 24 | 274.3063623684229 | +| 25 | 660.046543272457 | +| 26 | 433.84147581860896 | +| 27 | 1123.6556434756412 | +| 28 | 329.2574937705332 | +| 29 | 26.96606070210349 | +| 30 | 26.316526650535426 | Full SPSS code provided in validation folder ([here](https://github.com/PharmCat/ jl/blob/master/validation/spssrdscode.sps.txt)). diff --git a/test/test.jl b/test/test.jl index 6d6fbf11..6e69eb71 100644 --- a/test/test.jl +++ b/test/test.jl @@ -47,7 +47,7 @@ include("testdata.jl") @test stderror(lmm)[1] ≈ 0.33471795812641164 atol=1E-6 @test length(modelmatrix(lmm)) == 120 @test isa(response(lmm), Vector) - @test sum(Metida.hessian(lmm)) ≈ 1118.160713481362 atol=1E-6 + @test sum(Metida.hessian(lmm)) ≈ 1118.160713481362 atol=1E-2 #AI like algo Metida.fit!(lmm; aifirst = true, init = Metida.theta(lmm), blocksolve = true) @test Metida.m2logreml(lmm) ≈ 16.241112644506067 atol=1E-6