{"id":1305,"date":"2016-11-06T11:53:56","date_gmt":"2016-11-06T11:53:56","guid":{"rendered":"http:\/\/62.131.51.129\/?p=1305"},"modified":"2016-11-06T11:53:56","modified_gmt":"2016-11-06T11:53:56","slug":"estimating-with-python","status":"publish","type":"post","link":"http:\/\/archief.van-maanen.com\/?p=1305","title":{"rendered":"Estimating with Python"},"content":{"rendered":"<p>It is relatively easy to do an estimate with a Python script. This is due to the fact that Python works with matrices and such matrices can be used as an input in a estimation procedure. I created an example where a dataset is retrieve from Oracle. Then the dataset is translated into a matrix. Subsequently some columns from that matrix are taken as dependent and independent variables, which are subsequently used as input to an OLS estimation procedure.<br \/>\nThe code:<\/p>\n<pre>\nimport cx_Oracle\nimport numpy as np\nimport statsmodels.api as sm\ncon = cx_Oracle.connect('scott\/bunvegni@van-maanen.com\/orcl')\ncur = con.cursor()\ncur.execute('select * from departments where manager_id is not null')\nres = cur.fetchall()\nprint res\ncon.close()\nA = np.array(res)\ny= A[:,0].astype(np.float)\nx= A[:,[2,3]].astype(np.float)\nlmRegModel = sm.OLS(y,x)\nresult = lmRegModel.fit()\nresult.summary()\n<\/pre>\n<p>I use the numpy library to translate the data as retrieved from Oracle into a matrix. I am then able to retrieve one column as the independent variable and 2 columns as independent variables. I explicitly cast them into floats. I am then able to start the estimation process. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is relatively easy to do an estimate with a Python script. This is due to the fact that Python works with matrices and such matrices can be used as an input in a estimation procedure. I created an example where a dataset is retrieve from Oracle. Then the dataset is translated into a matrix. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1306,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1305","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/1305","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1305"}],"version-history":[{"count":0,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/1305\/revisions"}],"wp:attachment":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1305"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}