I am using statsmodels to train a linear quantile regression. I have different combinations of features that I need to try and train, but it is as if statsmodels only allows a certain amount of features to be included in the models. I have attached a dummy example below.
# Construct dummy data:
df_dum = pd.DataFrame(columns=['y'])
df_dum['y'] = np.random.normal(size=10)
cols = ['x1','x2','x3','x4','x5','x6','x7','x8','x9','x10','x11','x12','x13','x14','x15','x16','x17','x18','x19','x20','x21','x22','x23','x24']
for i in range(len(cols)):
df_dum[cols[i]] = np.random.normal(size=10)
# specify feature constellations
feat1 = ['x1','x2','x3','x4','x5','x6','x7','x8','x9','x10']
feat2 = ['x1','x2','x3','x4','x5','x6','x7','x8','x9','x10','x11','x12','x13','x14','x15']
mod1 = sm.QuantReg(df_dum['y'], df_dum[feat1]).fit(0.50)
mod2 = sm.QuantReg(df_dum['y'], df_dum[feat2]).fit(0.50)
Here mod1
has no problem running but mod2
gives me the error:
ValueError: operands could not be broadcast together with shapes (15,) (10,)
. So it is as if statsmodels remembers the number of features from the previous model?