11import numpy as np
2+ import numpy .linalg
23import scipy .stats
34from typing import Union
45
@@ -218,7 +219,7 @@ def wald_test(
218219
219220def wald_test_chisq (
220221 theta_mle : np .ndarray ,
221- theta_invcovar : np .ndarray ,
222+ theta_covar : np .ndarray ,
222223 theta0 : Union [int , np .ndarray ] = 0
223224):
224225 """
@@ -236,8 +237,8 @@ def wald_test_chisq(
236237
237238 :param theta_mle: np.array (par x genes)
238239 Maximum likelihood estimator of given parameter by gene.
239- :param theta_invcovar : np.array (genes x par x par)
240- Inverse of the covariance matrix of the parameters in theta_mle by gene.
240+ :param theta_covar : np.array (genes x par x par)
241+ Covariance matrix of the parameters in theta_mle by gene.
241242 This is the negative hessian or the inverse of the
242243 observed fisher information matrix.
243244 :param theta0: float
@@ -246,13 +247,13 @@ def wald_test_chisq(
246247 if np .size (theta0 ) == 1 :
247248 theta0 = np .broadcast_to (theta0 , theta_mle .shape )
248249
249- if theta_mle .shape [0 ] != theta_invcovar .shape [1 ]:
250+ if theta_mle .shape [0 ] != theta_covar .shape [1 ]:
250251 raise ValueError (
251- 'stats.wald_test(): theta_mle and theta_invcovar have to contain the same number of parameters' )
252- if theta_mle .shape [1 ] != theta_invcovar .shape [0 ]:
253- raise ValueError ('stats.wald_test(): theta_mle and theta_invcovar have to contain the same number of genes' )
254- if theta_invcovar .shape [1 ] != theta_invcovar .shape [2 ]:
255- raise ValueError ('stats.wald_test(): the first two dimensions of theta_invcovar have to be of the same size' )
252+ 'stats.wald_test(): theta_mle and theta_covar have to contain the same number of parameters' )
253+ if theta_mle .shape [1 ] != theta_covar .shape [0 ]:
254+ raise ValueError ('stats.wald_test(): theta_mle and theta_covar have to contain the same number of genes' )
255+ if theta_covar .shape [1 ] != theta_covar .shape [2 ]:
256+ raise ValueError ('stats.wald_test(): the first two dimensions of theta_covar have to be of the same size' )
256257 if theta0 .shape [0 ] > 1 :
257258 if theta_mle .shape [0 ] != theta0 .shape [0 ]:
258259 raise ValueError ('stats.wald_test(): theta_mle and theta0 have to contain the same number of entries' )
@@ -264,7 +265,7 @@ def wald_test_chisq(
264265 np .matmul (
265266 np .matmul (
266267 theta_diff [:, [i ]].T ,
267- theta_invcovar [i , :, :]
268+ numpy . linalg . inv ( theta_covar [i , :, :])
268269 ),
269270 theta_diff [:, [i ]]
270271 )
0 commit comments