Skip to content

Commit d2391aa

Browse files
committed
start changing parse
1 parent d2e01b1 commit d2391aa

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,9 @@ fit!(model)
6464
## See also
6565
- J. Kim, J. Shen, A. Wang, D.V. Mehrotra, S. Ko, J.J. Zhou, and H. Zhou: **VCSEL: Prioritizing SNP-set by penalized variance component selection** (2021) ([link](http://doi.org/10.1214/21-aoas1491))
6666
- L. Hu, W. Lu, J. Zhou, and H. Zhou: **MM algorithms for variance component estimation and selection in logistic linear mixed models** (2019) ([link](http://doi.org/10.5705/ss.202017.0220))
67-
- J.J. Zhou, T. Hu, D. Qiao, M.H. Cho, and H. Zhou: **Boosting gene mapping power and efficiency with efficient exact variance component tests of single nucleotide polymorphism sets** (2016) ([link](http://doi.org/10.1534/genetics.116.190454))
67+
- J.J. Zhou, T. Hu, D. Qiao, M.H. Cho, and H. Zhou: **Boosting gene mapping power and efficiency with efficient exact variance component tests of single nucleotide polymorphism sets** (2016) ([link](http://doi.org/10.1534/genetics.116.190454))
68+
69+
## Contributors
70+
<a href="https://github.com/Hua-Zhou/MultiResponseVarianceComponentModels.jl/graphs/contributors">
71+
<img src="https://contrib.rocks/image?repo=Hua-Zhou/MultiResponseVarianceComponentModels.jl" />
72+
</a>

src/parse.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
"""
22
lrt(model1::VCModel, model0::VCModel)
33
4-
Perform a variation of the likelihood ratio test for univariate variance components models as in
5-
Molenberghs and Verbeke 2007 with model1 and model0 being the full and nested models, respectively.
4+
Perform a variation of the likelihood ratio test for univariate variance components models
5+
as in Molenberghs and Verbeke 2007 with `model1` and `model0` being the full and nested
6+
models, respectively.
67
"""
78
function lrt(
89
model1 :: VCModel,
910
model0 :: VCModel
1011
)
1112
df = length(model1.V) - length(model0.V)
12-
@assert df > 0
13-
@assert size(model0.Σ[1], 1) == 1
14-
@assert size(model1.Σ[1], 1) == 1
13+
@assert df > 0 "models should be nested"
14+
@assert size(model1.Σ[1], 1) == 1 && size(model0.Σ[1], 1) == 1 "models should be univariate"
1515
lrt = 2 * (model1.logl[1] - model0.logl[1])
1616
coefs = [2.0^-df * binomial(df, i) for i in 1:df]
1717
ps = [ccdf(Chisq(i), lrt) for i in 1:df]
18-
sum(coefs .* ps)
18+
dot(coefs, ps)
1919
end
2020

2121
"""
2222
h2(model::VCModel)
2323
24-
Calculate heritability estimates and their standard errors, assuming that all variance components
25-
capture genetic effects except the last term. Also return total heritability from sum of individual
26-
contributions and its standard error.
24+
Calculate heritability estimates and their standard errors, assuming that all variance
25+
components capture genetic effects except the last term. Also return total heritability from
26+
sum of individual contributions and its standard error.
2727
"""
2828
function h2(model::VCModel)
2929
m, d = length(model.Σ), size(model.Σ[1], 1)
@@ -52,16 +52,6 @@ function h2(model::VCModel)
5252
h2s, ses
5353
end
5454

55-
function findvar(d::Int)
56-
s, r = (d), d
57-
idx = ones(Int, d)
58-
for j in 2:length(idx)
59-
idx[j] = idx[j - 1] + r
60-
r -= 1
61-
end
62-
idx
63-
end
64-
6555
"""
6656
rg(model::VCModel)
6757
@@ -94,3 +84,13 @@ function rg(model::VCModel)
9484
[copytri!(ses[i], 'L') for i in 1:m]
9585
rgs, ses
9686
end
87+
88+
function findvar(d::Int)
89+
s, r = (d), d
90+
idx = ones(Int, d)
91+
for j in 2:length(idx)
92+
idx[j] = idx[j - 1] + r
93+
r -= 1
94+
end
95+
idx
96+
end

0 commit comments

Comments
 (0)