Skip to content

Commit

Permalink
Merge pull request #52 from PharmCat/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
PharmCat authored Jan 16, 2025
2 parents bfa5efc + 3e03d65 commit 8414ec7
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uuid = "a1dec852-9fe5-11e9-361f-8d9fde67cfa2"
keywords = ["lenearmodel", "mixedmodel"]
desc = "Mixed-effects models with flexible covariance structure."
authors = ["Vladimir Arnautov <[email protected]>"]
version = "0.16.3"
version = "0.16.4"

[deps]
DiffResults = "163ba53b-c6d8-5494-b064-1a9d43ac40c5"
Expand All @@ -23,7 +23,7 @@ DiffResults = "1"
Distributions = "0.21, 0.22, 0.23, 0.24, 0.25"
ForwardDiff = "0.10"
LineSearches = "7"
MetidaBase = "0.11, 0.12"
MetidaBase = "0.11, 0.12, 0.13, 0.14"
Optim = "1"
ProgressMeter = "1"
StatsBase = "0.30, 0.31, 0.32, 0.33, 0.34"
Expand Down
14 changes: 10 additions & 4 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ mm = fit(MixedModel, @formula(response ~ factor+ (0+r1|subject)), rds2, REML = t
println(mm) #hide
```

## Aumented covariance (Experimental)
## Augmented covariance (Experimental)

Covariance modificator `ACOV()` can be used as second repeated effect. In this case covariance calculated with existed matrix,
that was build at previous step. For example addition `ACOV(AR)` to `DIAG` structure is the same as `ARH` if same blocking factor used.
that was build at previous step. For example, addition `ACOV(AR)` to `DIAG` structure is the same as `ARH` if same blocking factor used.

```@example lmmexample
lmm1 = Metida.LMM(@formula(response ~ 1), rds2;
Expand All @@ -226,7 +226,7 @@ R-part of variance-covariance matrix:
Metida.rmatrix(lmm1, 1)
```

If nested blocking factor used - covariance modification applyed only within that blocks:
If nested blocking factor used - covariance modification applyed only within that blocks (R-part of variance-covariance matrix is the same):

```@example lmmexample
lmm = Metida.LMM(@formula(response ~ 1), rds2;
Expand All @@ -246,4 +246,10 @@ lmm = Metida.LMM(@formula(resp ~ 0 + device), devday;
Metida.VarEffect(Metida.@covstr(1|subj&device), Metida.ACOV(Metida.AR))]
)
Metida.fit!(lmm)
```
```
R-matrix:

```@example lmmexample
Metida.rmatrix(lmm, 1)
```

41 changes: 41 additions & 0 deletions test/csv/repeated_missing.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
group,id,val,mval
A,1,2.3845000648143104,2.3845000648143104
A,2,2.4002561961133253,2.4002561961133253
A,3,2.6461247053588703,
A,4,2.5039299718606545,
A,5,1.0856472591949988,1.0856472591949988
A,6,2.184389840299886,2.184389840299886
A,7,0.405296230921422,0.405296230921422
A,8,1.3254312116518587,1.3254312116518587
A,9,1.5495464246891864,1.5495464246891864
A,10,-0.17655622878550603,-0.17655622878550603
B,1,2.8617827203521014,2.8617827203521014
B,2,0.02583697070742752,0.02583697070742752
B,3,2.167474135584393,2.167474135584393
B,4,4.484640823668984,4.484640823668984
B,5,-1.129080615928823,-1.129080615928823
B,6,3.442505366382359,
B,7,3.045772822402446,3.045772822402446
B,8,1.2842885308109802,1.2842885308109802
B,9,2.3089545570457086,2.3089545570457086
B,10,1.9163191156848915,
C,1,2.886648125971103,2.886648125971103
C,2,-1.5491195086556038,-1.5491195086556038
C,3,2.1595467761537903,2.1595467761537903
C,4,3.845202599290304,3.845202599290304
C,5,-0.38409050331907757,
C,6,4.428785225343573,
C,7,2.0453017605832784,2.0453017605832784
C,8,2.456749458938131,2.456749458938131
C,9,2.868069759602771,2.868069759602771
C,10,-0.333015483137292,
D,1,7.582685079197572,7.582685079197572
D,2,5.086570519714996,5.086570519714996
D,3,2.116264311458874,2.116264311458874
D,4,-0.5144802973394635,
D,5,5.758583356184874,
D,6,-1.1222165881349004,
D,7,-4.626400023827016,-4.626400023827016
D,8,0.26968789850638286,0.26968789850638286
D,9,-1.9164805507645635,-1.9164805507645635
D,10,-0.8226309476831426,-0.8226309476831426
25 changes: 25 additions & 0 deletions test/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,31 @@ end
Base.show(io, lmm)
@test Metida.m2logreml(lmm) 713.5850978377632 atol=1E-8
end

@testset " Model: UN (repeated) missing " begin
io = IOBuffer();
lmm = Metida.LMM(@formula(val~1), rep_missing, repeated = Metida.VarEffect(Metida.@covstr(group|id), Metida.UN))
fit!(lmm)
#SPSS check +
@test Metida.m2logreml(lmm) 138.674280 atol=1E-6
@test Metida.theta(lmm)[1]^2 0.930862 atol=1E-6
@test Metida.theta(lmm)[4]^2 13.833087 atol=1E-6
@test Metida.theta(lmm)[5] 0.222058 atol=1E-6
@test Metida.theta(lmm)[9] -0.516841 atol=1E-6
Base.show(io, lmm)

mlmm = Metida.LMM(@formula(mval~1), rep_missing, repeated = Metida.VarEffect(Metida.@covstr(group|id), Metida.UN))
fit!(mlmm)
#SPSS check +
@test Metida.m2logreml(mlmm) 103.523394 atol=1E-6
@test Metida.theta(mlmm)[1]^2 0.815214 atol=1E-6
@test Metida.theta(mlmm)[4]^2 13.881296 atol=1E-6
@test Metida.theta(mlmm)[5] 0.295511 atol=1E-6
@test Metida.theta(mlmm)[9] -0.127460 atol=1E-6
Base.show(io, mlmm)
Base.show(io, mlmm.log)
end

@testset " Model: BE RDS 1, FDA model " begin

lmm = Metida.LMM(@formula(lnpk~sequence+period+treatment), dfrdsfda;
Expand Down
2 changes: 2 additions & 0 deletions test/testdata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ devday = CSV.File(path*"/csv/devday.csv"; types = [ Float64, String, Strin
dfrdsfda = CSV.File(joinpath(path, "csv", "berds", "rds1.csv"), types = Dict(:PK => Float64, :subject => String, :period => String, :sequence => String, :treatment => String )) |> DataFrame
dropmissing!(dfrdsfda)
dfrdsfda.lnpk = log.(dfrdsfda.PK)

rep_missing = CSV.File(path*"/csv/repeated_missing.csv"; types = [ String, String, Float64, Float64]) |> DataFrame

4 comments on commit 8414ec7

@PharmCat
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/123151

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.16.4 -m "<description of version>" 8414ec7a318b69b9b8804e28871864de1629a6fa
git push origin v0.16.4

@PharmCat
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error while trying to register: Version 0.16.4 already exists

Please sign in to comment.