Is the unstructure covariance structure the same as in MixedModels.jl without zerocorr()
?
Yes:
using Metida, CSV, DataFrames, CategoricalArrays, MixedModels;
rds2 = CSV.File(joinpath(dirname(pathof(Metida)), "..", "test", "csv", "ftdf3.csv"); types = [String, Float64, Float64, String, String, String, String, String, Float64]) |> DataFrame
MixedModels:
mm = fit(MixedModel, @formula(response ~ factor+ (0+r1|subject)), rds2, REML = true)
Linear mixed model fit by REML
response ~ 1 + factor + (0 + r1 | subject)
REML criterion at convergence: 705.3822336725552
Variance components:
ColumnVariance Std.Dev. Corr.
subject r1: A 8.51765 2.91850
r1: B 12.72191 3.56678 +0.46
r1: C 21.13547 4.59733 +0.46 +0.58
Residual 1.01648 1.00820
Number of obs: 168; levels of grouping factors: 24
Fixed-effects parameters:
──────────────────────────────────────────────────
Coef. Std. Error z Pr(>|z|)
──────────────────────────────────────────────────
(Intercept) 40.1983 0.79166 50.78 <1e-99
factor -11.0272 1.11958 -9.85 <1e-22
──────────────────────────────────────────────────
Metida:
lmm = Metida.LMM(@formula(response~factor), rds2;
random = Metida.VarEffect(Metida.@covstr(r1|subject), UN),
)
Metida.fit!(lmm)
Linear Mixed Model: response ~ factor
Random 1:
Model: r1|subject
Type: UN (6), Subjects: 24
Repeated:
Residual only
Blocks: 24, Maximum block size: 7
Status: converged (No Errors)
-2 logREML: 705.382 BIC: 741.166
Fixed-effects parameters:
──────────────────────────────────────────────────
Coef. Std. Error z Pr(>|z|)
──────────────────────────────────────────────────
(Intercept) 40.1983 0.791652 50.78 <1e-99
factor -11.0271 1.11956 -9.85 <1e-22
──────────────────────────────────────────────────
Variance components:
θ vector: [2.91848, 3.56669, 4.59709, 0.458287, 0.463127, 0.575315, 1.00823]
Random 1 σ² r1: A var 8.51753
Random 1 σ² r1: B var 12.7213
Random 1 σ² r1: C var 21.1332
Random 1 ρ: r1: A × r1: B rho 0.458287
Random 1 ρ: r1: A × r1: C rho 0.463127
Random 1 ρ: r1: B × r1: C rho 0.575315
Residual σ² var 1.01653
1 Like
Metida 0.16.3 released.
Add covariance modificator.
With ACOV
covariance structure it is possible to change existed covariance structure and add covariance with AR
or CH
pattern.
So…
LMM(@formula(response ~ 1), ftdf3;
repeated = [VarEffect(@covstr(r1|subject), DIAG),
VarEffect(@covstr(1|subject), ACOV(AR))])
is the same as:
LMM(@formula(response ~ 1), ftdf3;
repeated = VarEffect(Metida.@covstr(r1|subject), ARH))
But other blocking factors can be used for covariation pattern:
LMM(@formula(response ~ 1), ftdf3;
repeated = [VarEffect(@covstr(r1|subject), DIAG),
VarEffect(@covstr(1|r2), ACOV(CS))])
Or some complicated structures can be build by this way:
LMM(@formula(resp ~ 0 + device), devday;
repeated = [VarEffect(Metida.@covstr(device|subj&day), UN),
VarEffect(Metida.@covstr(1|subj&device), ACOV(AR))])
see example here
2 Likes