hrossman / pymsm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error message

ehodneland opened this issue · comments

I have prepared a pandas dataframe according to the documentation https://hrossman.github.io/pymsm/usage/Preparing_a_dataset/#preparing-a-dataset-for-multistate-modeling-with-pymsm but I receive this error message when I try to fit the model:

Init MultistateModel

from pymsm.multi_state_competing_risks_model import MultiStateModel
multi_state_model = MultiStateModel(
dataset=dfML,
covariate_names=covariate_cols,
terminal_states=terminal_states)


AttributeError Traceback (most recent call last)
Cell In[64], line 3
1 # Init MultistateModel
2 from pymsm.multi_state_competing_risks_model import MultiStateModel
----> 3 multi_state_model = MultiStateModel(
4 dataset=dfML,
5 covariate_names=covariate_cols,
6 terminal_states=terminal_states)

File ~\AppData\Roaming\Python\Python311\site-packages\pymsm\multi_state_competing_risks_model.py:127, in MultiStateModel.init(self, dataset, terminal_states, update_covariates_fn, covariate_names, event_specific_fitter, competing_risk_data_format, state_labels, trim_transitions_threshold)
125 self._trim_transitions()
126 else:
--> 127 self._assert_valid_input()

File ~\AppData\Roaming\Python\Python311\site-packages\pymsm\multi_state_competing_risks_model.py:156, in MultiStateModel._assert_valid_input(self)
154 # Check the number of times is either equal or one less than the number of states
155 for obj in self.dataset:
--> 156 n_states = len(obj.states)
157 n_times = len(obj.time_at_each_state)
158 assert n_states == n_times or n_states == n_times + 1

AttributeError: 'str' object has no attribute 'states'