Skip to content

Commit 4383a56

Browse files
committed
add option for using intercept as the random effect
1 parent baed7c1 commit 4383a56

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/mrtool/core/cov_model.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,7 @@ def __init__(
945945
ref_cov=None,
946946
ref_cat=None,
947947
use_re=False,
948+
use_re_intercept=False,
948949
prior_beta_gaussian=None,
949950
prior_beta_uniform=None,
950951
prior_beta_laplace=None,
@@ -965,6 +966,7 @@ def __init__(
965966
prior_gamma_laplace=prior_gamma_laplace,
966967
)
967968
self.ref_cat = ref_cat
969+
self.use_re_intercept = use_re_intercept
968970
if len(self.alt_cov) != 1:
969971
raise ValueError("alt_cov should be a single column.")
970972
if len(self.ref_cov) > 1:
@@ -1026,11 +1028,13 @@ def num_x_vars(self) -> int:
10261028

10271029
@property
10281030
def num_z_vars(self) -> int:
1029-
"""Number of the random effects. Currently it is the same with the
1030-
number of the fixed effects, but this is to be discussed.
1031-
TODO: Overwrite the number of random effects.
1031+
"""Number of the random effects. When use_re_intercept is set to True,
1032+
it will use a single intercept random effect. Otherwise, it will use
1033+
each category will have its own random effect.
10321034
10331035
"""
1036+
if self.use_re_intercept:
1037+
return 1
10341038
return self.num_x_vars
10351039

10361040
@property

0 commit comments

Comments
 (0)