Hi everyone,

I’m reaching out to the community for some help with a roadblock I’ve encountered in my code involving PyMC and Kalman Filters.

**Project Goal:**

I’m working on a project that utilizes PyMC for Bayesian inference with time-varying parameters (TVP). Within this project, I’ve defined a function called `fit_tvp_pvar`

that incorporates Kalman Filter imputation for handling missing values.

**Errors:**

**Missing Kalman Filter:**

- When attempting to leverage the Kalman Filter for imputation, I stumble upon this error:
`module 'pytensor.tensor' has no attribute 'KalmanFilter'`

This suggests that`pytensor.tensor`

might not have a built-in Kalman Filter implementation.

**PyMC Model Definition/Sampling Error:**

- After successfully imputing missing values using an alternative method (e.g., iterative imputation), the code throws an error during PyMC model definition or sampling:
`ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding`

Unfortunately, this error message isn’t very specific, making troubleshooting challenging.

**Code Snippet:**

Here’s a relevant part of the code demonstrating the `kalman_imputation`

function and the error related to the missing Kalman Filter attribute:

I first run this code using numby in the Kalman filter

def fit_tvp_pvar(self, num_iterations=10000, burn=5000, tune=5000, cores=1, delay=1):

print(“Starting fit_tvp_pvar method”)`imputation_methods = ['kalman', 'iterative', 'knn'] imputed = False for method in imputation_methods: try: print(f"Attempting {method} imputation") # Imputation process ... if method == 'kalman': data = self.kalman_imputation(self.data[self.vars].values.astype('float32')) elif method == 'iterative': imputer = IterativeImputer(max_iter=100, random_state=self.seed) data = imputer.fit_transform(self.data[self.vars].values.astype('float32')) elif method == 'knn': imputer = KNNImputer() data = imputer.fit_transform(self.data[self.vars].values.astype('float32')) data_tensor = pt.as_tensor_variable(data.astype('float32')) # Checking for inf or nan values ... if not pt.any(pt.isnan(data_tensor)).eval(): imputed = True self.n_vars = data_tensor.shape[1].eval() print(f"Imputation successful with {method} method.") break else: print(f"Inf or nan values found after {method} imputation") # Handle inf or nan values ... time.sleep(delay) except Exception as e: print(f"{method} imputation failed: {e}") print(f"Error occurred at line {sys.exc_info()[2].tb_lineno} in fit_tvp_pvar") print(f"Error details: {traceback.format_exc()}") print("Trying the next method...") if not imputed: raise ValueError("All imputation methods failed.") try: print(f"Starting PyMC model definition") with pm.Model() as tvp_pvar_model: # Priors sd_dist = pm.HalfNormal('sd_dist', sigma=1.0) log_sd_vals = pm.Normal("log_sd_vals", mu=0, sigma=1, shape=(self.n_vars,)) exp_log_sd_vals = pt.exp(log_sd_vals) sd_vals = pm.Deterministic("sd_vals", exp_log_sd_vals) alphas = pm.Normal("alphas", mu=0, sigma=1, shape=(self.n_obs, self.n_vars)) # State transitions using loop state_vars = [] for t in range(self.n_obs): prev_state = state_vars[t - 1] if t > 0 else pt.zeros((1, self.p * self.n_vars)) shocks = pm.Normal(f"shocks_t{t}", mu=0.0, sigma=sd_vals, shape=(self.n_vars,)) new_state = pt.zeros_like(prev_state) for lag in range(self.p): is_not_finite = pt.or_(pt.isinf(alphas[t - lag - 1]), pt.isnan(shocks[t - lag])) new_state += pt.dot(pt.switch(~is_not_finite, alphas[t - lag - 1], 0.0), shocks[t - lag]) state_vars.append(new_state) # Likelihood etas = pm.Normal(f"etas_t{t}", mu=pt.dot(state_vars[t], pt.repeat(pt.arange(self.p)[::-1], self.n_obs, axis=0)), sigma=sd_vals, observed=data_tensor[t]) print(f"Starting MCMC sampling") # MCMC sampling trace = pm.sample(draws=num_iterations, tune=tune, chains=cores) self.trace = trace except Exception: print("Exception occurred during PyMC model definition or sampling:") exc_type, exc_value, exc_traceback = sys.exc_info() print(f"Error occurred at line {exc_traceback.tb_lineno} in fit_tvp_pvar") print(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback))) def kalman_imputation(self, data): """ Impute missing values using the Kalman Filter. """ print("Starting Kalman imputation") print("Note: Using NumPy for Kalman imputation as it operates on NumPy arrays, not PyTensor tensors") try: data = np.where(np.isinf(data), np.nan, data) initial_state_mean = np.nanmean(data, axis=0) initial_state_mean = np.where(np.isnan(initial_state_mean), 0, initial_state_mean) kf = KalmanFilter(initial_state_mean=initial_state_mean, n_dim_obs=data.shape[1]) masked_data = np.ma.masked_invalid(data) imputed_data, _ = kf.em(masked_data, n_iter=10).smooth(masked_data) if isinstance(imputed_data, np.ma.MaskedArray): filled_data = imputed_data.filled(fill_value=np.nanmean(imputed_data)) else: filled_data = imputed_data return filled_data except Exception as e: print(f"Error in kalman_imputation: {e}") print(f"Error occurred at line {sys.exc_info()[2].tb_lineno} in kalman_imputation") print(f"Error details: {traceback.format_exc()}") raise`

with error

Starting fit_tvp_pvar method

Attempting kalman imputation

Starting Kalman imputation

Note: Using NumPy for Kalman imputation as it operates on NumPy arrays, not PyTensor tensors

Imputation successful with kalman method.

Starting PyMC model definition

Starting MCMC sampling

ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding

ERROR (pytensor.graph.rewriting.basic): node: Assert{msg=PyTensor Assert failed!}(0.0, False)

ERROR (pytensor.graph.rewriting.basic): TRACEBACK:

ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last):

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 1919, in process_node

replacements = node_rewriter.transform(fgraph, node)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 1081, in transform

return self.fn(fgraph, node)

^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/tensor/rewriting/basic.py”, line 1128, in constant_folding

required = thunk()

^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/link/c/op.py”, line 91, in rval

thunk()

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/link/c/basic.py”, line 1771, incall

raise exc_value.with_traceback(exc_trace)

AssertionError: PyTensor Assert failed!Exception occurred during PyMC model definition or sampling:

Error occurred at line 107 in fit_tvp_pvar

Traceback (most recent call last):

File “/var/folders/p_/4shh5wgx7vn_sp4_77tp6c7m0000gn/T/ipykernel_11911/1276847003.py”, line 107, in fit_tvp_pvar

trace = pm.sample(draws=num_iterations, tune=tune, chains=cores)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pymc/sampling/mcmc.py”, line 684, in sample

step = assign_step_methods(model, step, methods=pm.STEP_METHODS, step_kwargs=kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pymc/sampling/mcmc.py”, line 212, in assign_step_methods

model_logp = model.logp()

^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pymc/model/core.py”, line 725, in logp

rv_logps = transformed_conditional_logp(

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pymc/logprob/basic.py”, line 611, in transformed_conditional_logp

temp_logp_terms = conditional_logp(

^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pymc/logprob/basic.py”, line 479, in conditional_logp

fgraph, rv_values, _ = construct_ir_fgraph(rv_values, ir_rewriter=ir_rewriter)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pymc/logprob/rewriting.py”, line 475, in construct_ir_fgraph

ir_rewriter.rewrite(fgraph)

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 121, in rewrite

return self.apply(fgraph, *args, **kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 291, in apply

sub_prof = rewriter.apply(fgraph)

^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 291, in apply

sub_prof = rewriter.apply(fgraph)

^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 2457, in apply

sub_prof = grewrite.apply(fgraph)

^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 2037, in apply

nb += self.process_node(fgraph, node)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 1922, in process_node

self.failure_callback(

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 1777, in warn_inplace

return cls.warn(exc, nav, repl_pairs, node_rewriter, node)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 1765, in warn

raise exc

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 1919, in process_node

replacements = node_rewriter.transform(fgraph, node)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 1081, in transform

return self.fn(fgraph, node)

^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/tensor/rewriting/basic.py”, line 1128, in constant_folding

required = thunk()

^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/link/c/op.py”, line 91, in rval

thunk()

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/link/c/basic.py”, line 1771, incall

raise exc_value.with_traceback(exc_trace)

AssertionError: PyTensor Assert failed!

Then, I used everywhere Pytensor

`def fit_tvp_pvar(self, num_iterations=10000, burn=5000, tune=5000, cores=1, delay=1): print("Starting fit_tvp_pvar method") imputation_methods = ['kalman', 'iterative', 'knn'] imputed = False for method in imputation_methods: try: print(f"Attempting {method} imputation") # Imputation process ... if method == 'kalman': data = self.kalman_imputation(self.data[self.vars].values.astype('float32')) elif method == 'iterative': imputer = IterativeImputer(max_iter=100, random_state=self.seed) data = imputer.fit_transform(self.data[self.vars].values.astype('float32')) elif method == 'knn': imputer = KNNImputer() data = imputer.fit_transform(self.data[self.vars].values.astype('float32')) data_tensor = pt.as_tensor_variable(data.astype('float32')) # Checking for inf or nan values ... if not pt.any(pt.isnan(data_tensor)).eval(): imputed = True self.n_vars = data_tensor.shape[1].eval() print(f"Imputation successful with {method} method.") break else: print(f"Inf or nan values found after {method} imputation") # Handle inf or nan values ... time.sleep(delay) except Exception as e: print(f"{method} imputation failed: {e}") print(f"Error occurred at line {sys.exc_info()[2].tb_lineno} in fit_tvp_pvar") print(f"Error details: {traceback.format_exc()}") print("Trying the next method...") if not imputed: raise ValueError("All imputation methods failed.") try: print(f"Starting PyMC model definition") with pm.Model() as tvp_pvar_model: # Priors sd_dist = pm.HalfNormal('sd_dist', sigma=1.0) log_sd_vals = pm.Normal("log_sd_vals", mu=0, sigma=1, shape=(self.n_vars,)) exp_log_sd_vals = pt.exp(log_sd_vals) sd_vals = pm.Deterministic("sd_vals", exp_log_sd_vals) alphas = pm.Normal("alphas", mu=0, sigma=1, shape=(self.n_obs, self.n_vars)) # State transitions using loop state_vars = [] for t in range(self.n_obs): prev_state = state_vars[t - 1] if t > 0 else pt.zeros((1, self.p * self.n_vars)) shocks = pm.Normal(f"shocks_t{t}", mu=0.0, sigma=sd_vals, shape=(self.n_vars,)) new_state = pt.zeros_like(prev_state) for lag in range(self.p): is_not_finite = pt.or_(pt.isinf(alphas[t - lag - 1]), pt.isnan(shocks[t - lag])) new_state += pt.dot(pt.switch(~is_not_finite, alphas[t - lag - 1], 0.0), shocks[t - lag]) state_vars.append(new_state) # Likelihood etas = pm.Normal(f"etas_t{t}", mu=pt.dot(state_vars[t], pt.repeat(pt.arange(self.p)[::-1], self.n_obs, axis=0)), sigma=sd_vals, observed=data_tensor[t]) print(f"Starting MCMC sampling") # MCMC sampling trace = pm.sample(draws=num_iterations, tune=tune, chains=cores) self.trace = trace except Exception: print("Exception occurred during PyMC model definition or sampling:") exc_type, exc_value, exc_traceback = sys.exc_info() print(f"Error occurred at line {exc_traceback.tb_lineno} in fit_tvp_pvar") print(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback))) def kalman_imputation(self, data): """ Impute missing values using the Kalman Filter with PyTensor. """ print("Starting Kalman imputation with PyTensor") try: # Convert data to PyTensor tensor data_tensor = pt.as_tensor_variable(data.astype('float32')) # Initialize Kalman Filter parameters (example, actual implementation may vary) initial_state_mean = pt.mean(data_tensor, axis=0) initial_state_mean = pt.where(pt.isnan(initial_state_mean), 0, initial_state_mean) # Example KalmanFilter class from PyTensor (hypothetical) kf = pt.KalmanFilter(initial_state_mean=initial_state_mean, n_dim_obs=data_tensor.shape[1]) # Perform Kalman smoothing imputed_data, _ = kf.em(data_tensor, n_iter=10).smooth(data_tensor) # Convert back to numpy array if necessary filled_data = imputed_data.eval() # Assuming PyTensor tensor to numpy array conversion return filled_data except Exception as e: print(f"Error in kalman_imputation: {e}") raise`

Getting

Starting fit_tvp_pvar method

Attempting kalman imputation

Starting Kalman imputation with PyTensor

Error in kalman_imputation: module ‘pytensor.tensor’ has no attribute ‘KalmanFilter’

kalman imputation failed: module ‘pytensor.tensor’ has no attribute ‘KalmanFilter’

Error occurred at line 44 in fit_tvp_pvar

Error details: Traceback (most recent call last):

File “/var/folders/p_/4shh5wgx7vn_sp4_77tp6c7m0000gn/T/ipykernel_12988/1786618341.py”, line 44, in fit_tvp_pvar

data = self.kalman_imputation(self.data[self.vars].values.astype(‘float32’))

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/var/folders/p_/4shh5wgx7vn_sp4_77tp6c7m0000gn/T/ipykernel_12988/1786618341.py”, line 131, in kalman_imputation

kf = pt.KalmanFilter(initial_state_mean=initial_state_mean, n_dim_obs=data_tensor.shape[1])

^^^^^^^^^^^^^^^

AttributeError: module ‘pytensor.tensor’ has no attribute ‘KalmanFilter’Trying the next method…

Attempting iterative imputation

Imputation successful with iterative method.

Starting PyMC model definition

Starting MCMC sampling

ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding

ERROR (pytensor.graph.rewriting.basic): node: Assert{msg=PyTensor Assert failed!}(0.0, False)

ERROR (pytensor.graph.rewriting.basic): TRACEBACK:

ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last):

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 1919, in process_node

replacements = node_rewriter.transform(fgraph, node)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 1081, in transform

return self.fn(fgraph, node)

^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/tensor/rewriting/basic.py”, line 1128, in constant_folding

required = thunk()

^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/link/c/op.py”, line 91, in rval

thunk()

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/link/c/basic.py”, line 1771, incall

raise exc_value.with_traceback(exc_trace)

AssertionError: PyTensor Assert failed!Exception occurred during PyMC model definition or sampling:

Error occurred at line 106 in fit_tvp_pvar

Traceback (most recent call last):

File “/var/folders/p_/4shh5wgx7vn_sp4_77tp6c7m0000gn/T/ipykernel_12988/1786618341.py”, line 106, in fit_tvp_pvar

trace = pm.sample(draws=num_iterations, tune=tune, chains=cores)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pymc/sampling/mcmc.py”, line 684, in sample

step = assign_step_methods(model, step, methods=pm.STEP_METHODS, step_kwargs=kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pymc/sampling/mcmc.py”, line 212, in assign_step_methods

model_logp = model.logp()

^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pymc/model/core.py”, line 725, in logp

rv_logps = transformed_conditional_logp(

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pymc/logprob/basic.py”, line 611, in transformed_conditional_logp

temp_logp_terms = conditional_logp(

^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pymc/logprob/basic.py”, line 479, in conditional_logp

fgraph, rv_values, _ = construct_ir_fgraph(rv_values, ir_rewriter=ir_rewriter)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pymc/logprob/rewriting.py”, line 475, in construct_ir_fgraph

ir_rewriter.rewrite(fgraph)

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 121, in rewrite

return self.apply(fgraph, *args, **kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 291, in apply

sub_prof = rewriter.apply(fgraph)

^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 291, in apply

sub_prof = rewriter.apply(fgraph)

^^^^^^^^^^^^^^^^^^^^^^

File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 2457, in apply

sub_prof = grewrite.apply(fgraph)

^^^^^^^^^^^^^

^^^^^^^^^ File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 2037, in apply nb += self.process_node(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 1922, in process_node self.failure_callback( File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 1777, in warn_inplace return cls.warn(exc, nav, repl_pairs, node_rewriter, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 1765, in warn raise exc File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 1919, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py”, line 1081, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/tensor/rewriting/basic.py”, line 1128, in constant_folding required = thunk() ^^^^^^^ File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/link/c/op.py”, line 91, in rval thunk() File “/Users/dimitri/anaconda3/lib/python3.11/site-packages/pytensor/link/c/basic.py”, line 1771, incallraise exc_value.with_traceback(exc_trace) AssertionError: PyTensor Assert failed!

**Questions:**

**Kalman Filter with**`pytensor`

:

- Does
`pytensor.tensor`

offer a built-in Kalman Filter implementation? - If not, what alternative libraries or approaches could I employ for Kalman Filter imputation within this context?

**PyMC Model Definition/Sampling Error:**

- The
`pytensor.graph.rewriting.basic`

error message lacks clarity. Could anyone offer insights or suggestions for troubleshooting this error related to PyMC model definition or sampling?

**Additional Information:**

- Libraries used
`pymc`

v 5`pytensor`

2.23.0

(Please advise if there’s a specific version recommended for Kalman Filter functionality)

I would greatly appreciate any guidance or suggestions you can offer to help me resolve these errors and successfully execute the `fit_tvp_pvar`

function.

Thank you in advance for your time and assistance!

Sincerely,

Dimitri