-2

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()
  • Welcome to stack overflow. You may have noticed your question is getting downvoted. In general "please write my code for me" will not get a great response. Either research the statsmodel library yourself and show what you've tried and how it's not working, or employ someone to code it for you. – Paul Stafford Allen Aug 07 '23 at 09:38

0 Answers0