@@ -46,29 +46,20 @@ vcmodelrot = TwoVarCompModelRotate(vcmodel)
4646@inferred logpdf (vcmodelrot, vcdatarot)
4747@test logpdf (vcmodel, vcdata) == logpdf (vcmodelrot, vcdatarot)
4848@test (logpdf (vcmodelrot, [vcdatarot vcdatarot; vcdatarot vcdatarot]) -
49- logpdf (vcmodel, [vcdata vcdata; vcdata vcdata])) ≈ 0.0
50-
51- # @info "Evaluate gradient"
52- # ∇ = zeros(2d^2)
53- # #@code_warntype gradient!(∇, vcmodelrot, vcdatarot)
54- # @inferred gradient!(∇, vcmodelrot, vcdatarot)
55- # @test norm(gradient(vcmodel, vcdata) - gradient(vcmodelrot, vcdatarot)) ≈ 0.0
56- # @test norm(gradient(vcmodel, vcdata) - gradient(vcmodel, vcdatarot)) ≈ 0.0
57- # @test norm(gradient(vcmodel, [vcdata vcdata]) -
58- # 2.0gradient(vcmodel, vcdata)) ≈ 0.0
59- # @test norm(gradient(vcmodel, [vcdata vcdata]) -
60- # gradient(vcmodelrot, [vcdatarot vcdatarot])) ≈ 0.0
49+ logpdf (vcmodel, [vcdata vcdata; vcdata vcdata])) ≈ 0.0
6150
6251@info " Evaluate gradient"
6352∇ = zeros (2 d^ 2 )
6453# @code_warntype gradient!(∇, vcmodelrot, vcdatarot)
6554@inferred VarianceComponentModels. gradient! (∇, vcmodelrot, vcdatarot)
66- @test norm (VarianceComponentModels. gradient (vcmodel, vcdata) - VarianceComponentModels. gradient (vcmodelrot, vcdatarot)) ≈ 0.0
67- @test norm (VarianceComponentModels. gradient (vcmodel, vcdata) - VarianceComponentModels. gradient (vcmodel, vcdatarot)) ≈ 0.0
55+ @test norm (VarianceComponentModels. gradient (vcmodel, vcdata) -
56+ VarianceComponentModels. gradient (vcmodelrot, vcdatarot)) ≈ 0.0
57+ @test norm (VarianceComponentModels. gradient (vcmodel, vcdata) -
58+ VarianceComponentModels. gradient (vcmodel, vcdatarot)) ≈ 0.0
6859@test norm (VarianceComponentModels. gradient (vcmodel, [vcdata vcdata]) -
69- 2.0 VarianceComponentModels. gradient (vcmodel, vcdata)) ≈ 0.0
60+ 2.0 VarianceComponentModels. gradient (vcmodel, vcdata)) ≈ 0.0
7061@test norm (VarianceComponentModels. gradient (vcmodel, [vcdata vcdata]) -
71- VarianceComponentModels. gradient (vcmodelrot, [vcdatarot vcdatarot])) ≈ 0.0
62+ VarianceComponentModels. gradient (vcmodelrot, [vcdatarot vcdatarot])) ≈ 0.0
7263
7364@info " Evaluate Fisher information matrix of Σ"
7465H = zeros (2 d^ 2 , 2 d^ 2 )
@@ -77,10 +68,9 @@ H = zeros(2d^2, 2d^2)
7768@test norm (fisher_Σ (vcmodel, vcdata) - fisher_Σ (vcmodelrot, vcdatarot)) ≈ 0.0
7869@test norm (fisher_Σ (vcmodel, vcdata) - fisher_Σ (vcmodel, vcdatarot)) ≈ 0.0
7970@test norm (fisher_Σ (vcmodel, [vcdata vcdata]) -
80- 2 fisher_Σ (vcmodel, vcdata)) ≈ 0.0
71+ 2 fisher_Σ (vcmodel, vcdata)) ≈ 0.0
8172@test norm (fisher_Σ (vcmodel, [vcdata vcdata]) -
82- fisher_Σ (vcmodelrot, [vcdatarot vcdatarot])) ≈ 0.0
83-
73+ fisher_Σ (vcmodelrot, [vcdatarot vcdatarot])) ≈ 0.0
8474
8575@info " Evaluate Fisher information matrix of B"
8676H = zeros (p * d, p * d)
@@ -89,9 +79,9 @@ H = zeros(p * d, p * d)
8979@test norm (fisher_B (vcmodel, vcdata) - fisher_B (vcmodelrot, vcdatarot)) ≈ 0.0
9080@test norm (fisher_B (vcmodel, vcdata) - fisher_B (vcmodel, vcdatarot)) ≈ 0.0
9181@test norm (fisher_B (vcmodel, [vcdata vcdata]) -
92- 2.0 fisher_B (vcmodel, vcdata)) ≈ 0.0
82+ 2.0 fisher_B (vcmodel, vcdata)) ≈ 0.0
9383@test norm (fisher_B (vcmodel, [vcdata vcdata]) -
94- fisher_B (vcmodelrot, [vcdatarot vcdatarot])) ≈ 0.0
84+ fisher_B (vcmodelrot, [vcdatarot vcdatarot])) ≈ 0.0
9585
9686@info " Find MLE using Fisher scoring"
9787vcmfs = deepcopy (vcmodel)
@@ -123,7 +113,8 @@ vcmfs.sense = '='
123113vcmfs. b = 0.0
124114vcmfs. lb = 0.0
125115vcmfs. ub = 1.0
126- logl_fs, _, _, Σcov_fs, Bse_fs, = mle_fs! (vcmfs, vcdatarot; solver = :Ipopt , qpsolver = :Ipopt )
116+ logl_fs, _, _, Σcov_fs, Bse_fs, = mle_fs! (vcmfs, vcdatarot;
117+ solver = :Ipopt , qpsolver = :Ipopt )
127118@show vcmfs. B
128119@test vcmfs. B[1 ] ≈ vcmfs. B[2 ]
129120@test all (vcmfs. B .≥ 0.0 )
@@ -170,9 +161,4 @@ vcmreml = deepcopy(vcmodel)
170161logl_reml, _, _, Σcov_reml, Bse_reml, = fit_reml! (vcmreml, vcdata; algo = :MM )
171162@show vcmreml. B, Bse_reml, B
172163
173- # # NOTE:
174- # # fit_reml! currently returns logpdf(vcmodel, vcdatarot), Σcov, Bse, Bcov
175- # # as opposed to logpdf(vcmodel, vcdatarot), vcmodel, Σse, Σcov, Bse, Bcov.
176- # # returning more than 4 values causes segmentation fault for some reason.
177-
178164end # module VarianceComponentTypeTest
0 commit comments