Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. hours = [1000, 10000, 11000, 11000, 15000, 18000, 37000, 24000, 28000, 28000, 42000, 46000, 50000, 34000, 34000, 46000, 50000, 56000, 64000, 64000, 65000, 80000, 81000, 81000, 44000, 49000, 76000, 76000, 89000, 38000, 80000, 69000, 46000, 47000, 57000, 72000, 77000, 68000]
  2.  
  3. market_Price = [30945, 28974, 27989, 27989, 36008, 24780, 22980, 23997, 25957, 27847, 36000, 25588, 23980, 25990, 25990, 28995, 26770, 26488, 24988, 24988, 17574, 12995, 19788, 20488, 19980, 24978, 16000, 16400, 18988, 19980, 18488, 16988, 15000, 15000, 16998, 17499, 15780, 8400]
  4.  
  5. age = [2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 7, 8, 8, 8, 8, 8, 13,]
  6.  
  7. std_divs = []
  8. for ratio in ratios:
  9. n = 0
  10. price_difference_final = []
  11. while n < len(prices):
  12. predicted_price = (log(h)*h1+h1)*ratio + (log(a)*a1+a1)*(1-ratio)
  13. price_difference_final.append(prices[n] - predicted_price)
  14. n += 1
  15. data = np.array(price_difference_final)
  16. std_divs.append(np.std(data))
  17. std_div = min(std_divs)
  18. optimum_ratio = ratios[std_divs.index(min(std_divs))]
  19.  
  20. import numpy as np
  21. from scipy.optimize import curve_fit
  22.  
  23. hours = [1000, 10000, 11000, 11000, 15000, 18000, 37000, 24000,
  24. 28000, 28000, 42000, 46000, 50000, 34000, 34000, 46000,
  25. 50000, 56000, 64000, 64000, 65000, 80000, 81000, 81000,
  26. 44000, 49000, 76000, 76000, 89000, 38000, 80000, 69000,
  27. 46000, 47000, 57000, 72000, 77000, 68000]
  28.  
  29. market_Price = [30945, 28974, 27989, 27989, 36008, 24780, 22980,
  30. 23997, 25957, 27847, 36000, 25588, 23980, 25990,
  31. 25990, 28995, 26770, 26488, 24988, 24988, 17574,
  32. 12995, 19788, 20488, 19980, 24978, 16000, 16400,
  33. 18988, 19980, 18488, 16988, 15000, 15000, 16998,
  34. 17499, 15780, 8400]
  35.  
  36. age = [2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4,
  37. 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 7,
  38. 8, 8, 8, 8, 8, 13]
  39.  
  40. combined = np.array([hours, market_Price])
  41.  
  42. def f():
  43. # Some function which uses combined where
  44. # combined[0] = hours and combined[1] = market_Price
  45. pass
  46.  
  47. popt, pcov = curve_fit(f, combined, market_Price)
  48.  
  49. In [26]:
  50.  
  51. y=np.array(market_Price)
  52. x=np.log(np.array([hours, age])).T
  53. In [27]:
  54.  
  55. mymodel=ols(y, x, 'Market_Price', ['Hours', 'Age'])
  56. In [28]:
  57.  
  58. mymodel.p # return coefficient p-values
  59. Out[28]:
  60. array([ 1.32065700e-05, 3.06318351e-01, 1.34081122e-05])
  61. In [29]:
  62.  
  63. mymodel.summary()
  64.  
  65. ==============================================================================
  66. Dependent Variable: Market_Price
  67. Method: Least Squares
  68. Date: Mon, 24 Mar 2014
  69. Time: 15:40:00
  70. # obs: 38
  71. # variables: 3
  72. ==============================================================================
  73. variable coefficient std. Error t-statistic prob.
  74. ==============================================================================
  75. const 45838.261850 9051.125823 5.064371 0.000013
  76. Hours -1023.097422 985.498239 -1.038152 0.306318
  77. Age -8862.186475 1751.640834 -5.059363 0.000013
  78. ==============================================================================
  79. Models stats Residual stats
  80. ==============================================================================
  81. R-squared 0.624227 Durbin-Watson stat 1.301026
  82. Adjusted R-squared 0.602754 Omnibus stat 2.999547
  83. F-statistic 29.070664 Prob(Omnibus stat) 0.223181
  84. Prob (F-statistic) 0.000000 JB stat 1.807013
  85. Log likelihood -366.421766 Prob(JB) 0.405146
  86. AIC criterion 19.443251 Skew 0.376021
  87. BIC criterion 19.572534 Kurtosis 3.758751
  88. ==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement