I have the following Dataframe:
Price Quantity Cost
1 6.979 800.359 1.830
2 7.420 427.363 1.830
3 7.408 486.639 1.830
4 7.613 574.584 1.830
5 8.059 621.247 1.830
6 8.445 498.810 1.830
7 7.864 635.192 1.830
8 9.629 405.185 1.830
9 12.137 364.420 1.830
10 10.945 241.486 1.830
I ran this:
ols=sm.OLS(annual['Price'],annual[['Price', 'Quantity']]).fit()
print(ols.predict([1,10]))
(I read here: What is first value that is passed into StatsModels predict function? that I need to add the 1 as constant)
My expected result would be ~340, actual result: [1.]
I also read that I should include the costs and use the IV2SLS regression like this:
IV = IV2SLS(annual['Price'],
annual[['Price', 'Quantity']],
annual[['Price', 'Cost']])
How do I get the prediction here?
I tried:
IV.fit().predict([1.83,10])
Again expected result ~340 Actual result: [1.83]
Thank you!