R code :
model =lmer( "BRAND_TRX ~ CALLS + ( 1 + CALLS|SPECIALTYGROUPING:MARKET_SALES_segment )",data = data)
Please provide the corresponding python code using statsmodel library.
I tried variance covariance but could not find the desired solutions.
here:
# Define the formulas for each channel separately
formula_calls = 'BRAND_TRX ~ CALLS'
oo = np.ones(data.shape[0])
vc = {"g1": "1 + CALLS+C(SPECIALTYGROUPING):C(MARKET_SALES_segment)"}
# Fit the models for each channel using the respective grouping columns
model = sm.MixedLM.from_formula(formula_calls, data=data, groups=oo,vc_formula=vc,re_formula="1")
results = model.fit()