-
Notifications
You must be signed in to change notification settings - Fork 8
Description
I am currently facing below error when calling fit_model:
ValueError: Buffer dtype mismatch, expected 'long' but got 'long long'
Is this an issue with the compability of limetr-spmat-numpy versions? What are the recommended versions of these packages to use limetr?
I would appreciate any help, thanks
Here is the complete error:
`---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[53], line 11
10 # Fit the model using the fit_model method
---> 11 model.fit_model(var=None, trim_steps=3, options=None)
13 # Show results
14 print("Fixed Effects (β):", model.soln["beta"])
File c:\Users\godit\anaconda3\envs\py310-env\lib\site-packages\limetr\core.py:384, in LimeTr.fit_model(self, var, trim_steps, options)
381 if trim_steps < 2:
382 raise ValueError("At least two trimming steps.")
--> 384 self._fit_model(var=var, options=options)
385 if self.inlier_pct < 1.0:
386 index = self.detect_outliers(self.result.x)
File c:\Users\godit\anaconda3\envs\py310-env\lib\site-packages\limetr\core.py:336, in LimeTr._fit_model(self, var, options)
323 def _fit_model(self,
324 var: ndarray = None,
325 options: Dict = None):
326 """
327 (Inner) Fit model function
328
(...)
334 scipy optimizer options, by default None
335 """
--> 336 var = self.get_model_init() if var is None else var.copy()
338 bounds = np.hstack([self.fevar.get_uprior_info(),
339 self.revar.get_uprior_info()]).T
340 constraints_mat = block_diag(self.fevar.get_linear_upriors_mat(),
341 self.revar.get_linear_upriors_mat())
File c:\Users\godit\anaconda3\envs\py310-env\lib\site-packages\limetr\core.py:314, in LimeTr.get_model_init(self)
312 gamma = np.zeros(self.revar.size)
313 var = np.hstack([beta, gamma])
--> 314 grad_beta = self.gradient(var)[:self.fevar.size]
315 hess_beta = self.hessian(var)[:self.fevar.size,
316 :self.fevar.size]
317 beta = beta - np.linalg.solve(
318 hess_beta + np.identity(self.fevar.size),
319 grad_beta
320 )
File c:\Users\godit\anaconda3\envs\py310-env\lib\site-packages\limetr\core.py:234, in LimeTr.gradient(self, var)
232 beta, gamma = self.get_vars(var)
233 r = self.get_residual(beta)
--> 234 d = self.get_varmat(gamma)
235 femat = self.get_femat(beta)
236 remat = self.get_remat()
File c:\Users\godit\anaconda3\envs\py310-env\lib\site-packages\limetr\core.py:192, in LimeTr.get_varmat(self, gamma)
179 def get_varmat(self, gamma: ndarray) -> BDLMat:
180 """
181 Compute trimming weighted variance covariance matrix of the likelihood
182
(...)
190 Weighted variance covariance matrix of the likelihood.
191 """
--> 192 return BDLMat(self.get_obsvar(),
193 self.get_remat()*np.sqrt(gamma),
194 self.data.group_sizes)
File c:\Users\godit\anaconda3\envs\py310-env\lib\site-packages\spmat\dlmat.py:377, in BDLMat.init(self, dvecs, lmats, dsizes)
374 self.lranks = np.minimum(self.dsizes, self.lmats.shape[1])
375 self.sdvecs = np.sqrt(self.dvecs)
--> 377 self.bilmat = BILMat(self.lmats / self.sdvecs[:, np.newaxis], self.dsizes)
378 self.dsize = self.dsizes.sum()
File c:\Users\godit\anaconda3\envs\py310-env\lib\site-packages\spmat\dlmat.py:147, in BILMat.init(self, lmats, dsizes)
144 if self.dsizes.sum() != self.lmats.shape[0]:
145 raise ValueError("Sizes of blocks do not match shape of matrix.")
--> 147 self._u, s = linalg.block_lsvd(self.lmats.copy(), self.dsizes, self.lranks)
148 self._v = s**2
149 self._w = -self._v / (1 + self._v)
File src\spmat\linalg.pyx:10, in spmat.linalg.block_lsvd()
ValueError: Buffer dtype mismatch, expected 'long' but got 'long long'`