You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry to add another issue, but hopefully this is easier to resolve. I am attempting to tabulate smoking prevalence ('_RFSMOK3') by imputed race ('_IMPRACE') with BRFSS data. This works fine for all territories including Puerto Rico from 2018-2022. However, when using the 2021 BRFSS data for Puerto Rico I am getting the error below. I have also provided my code below the error, but it will require download of the 2021 BRFSS data (or other years for it to work). Do you know what is causing this issue?
ERROR:
---------------------------------------------------------------------------
LinAlgError Traceback (most recent call last)
Cell In[247], line 12
8 # df = recode_smoker(df)
9 # df = recode_smokeless(df)
11 stratified_count = CrossTabulation(param=PopParam.count)
---> 12 stratified_count.tabulate(
13 vars=df[[variable, '_IMPRACE']],
14 samp_weight=df['_LLCPWT'],
15 stratum=df['_STSTR'],
16 psu=df['_PSU'],
17 single_psu=SinglePSUEst.skip,
18 remove_nan=True)
20 df_out = stratified_count.to_dataframe()
21 df_out
File [~\.conda\envs\ntcp_env\Lib\site-packages\samplics\categorical\tabulation.py:598](http://localhost:8888/lab/tree/~/.conda/envs/ntcp_env/Lib/site-packages/samplics/categorical/tabulation.py#line=597), in CrossTabulation.tabulate(self, vars, varnames, samp_weight, stratum, psu, ssu, fpc, deff, coef_var, single_psu, strata_comb, remove_nan)
593 # TODO:
594 # Replace the inversion of cov_prop and cov_prop_srs below by the a multiplication
595 # we have that inv(x' V x) = inv(x' L L' x) = z'z where z = inv(L) x
596 # L is the Cholesky factor i.e. L = np.linalg.cholesky(V)
597 x1_t = np.transpose(x1)
--> 598 x2_tilde = x2 - x1 @ np.linalg.inv(x1_t @ cov_prop_srs @ x1) @ (
599 x1_t @ cov_prop_srs @ x2
600 )
602 delta_est = np.linalg.inv(np.transpose(x2_tilde) @ cov_prop_srs @ x2_tilde) @ (
603 np.transpose(x2_tilde) @ cov_prop @ x2_tilde # TODO: is it cov_prop_srs
604 )
606 tbl_keys = list(tbl_est.point_est.keys())
File [~\.conda\envs\ntcp_env\Lib\site-packages\numpy\linalg\_linalg.py:608](http://localhost:8888/lab/tree/~/.conda/envs/ntcp_env/Lib/site-packages/numpy/linalg/_linalg.py#line=607), in inv(a)
605 signature = 'D->D' if isComplexType(t) else 'd->d'
606 with errstate(call=_raise_linalgerror_singular, invalid='call',
607 over='ignore', divide='ignore', under='ignore'):
--> 608 ainv = _umath_linalg.inv(a, signature=signature)
609 return wrap(ainv.astype(result_t, copy=False))
File [~\.conda\envs\ntcp_env\Lib\site-packages\numpy\linalg\_linalg.py:104](http://localhost:8888/lab/tree/~/.conda/envs/ntcp_env/Lib/site-packages/numpy/linalg/_linalg.py#line=103), in _raise_linalgerror_singular(err, flag)
103 def _raise_linalgerror_singular(err, flag):
--> 104 raise LinAlgError("Singular matrix")
LinAlgError: Singular matrix
Hi @MamadouSDiallo,
Sorry to add another issue, but hopefully this is easier to resolve. I am attempting to tabulate smoking prevalence ('_RFSMOK3') by imputed race ('_IMPRACE') with BRFSS data. This works fine for all territories including Puerto Rico from 2018-2022. However, when using the 2021 BRFSS data for Puerto Rico I am getting the error below. I have also provided my code below the error, but it will require download of the 2021 BRFSS data (or other years for it to work). Do you know what is causing this issue?
ERROR:
CODE:
The text was updated successfully, but these errors were encountered: