Skip to content

REF: update estmat2nparray [ci skip] - #1716

Open
josef-pkt wants to merge 1 commit into
statsmodels:mainfrom
josef-pkt:update_stata2py
Open

josef-pkt wants to merge 1 commit into
statsmodels:mainfrom
josef-pkt:update_stata2py

Conversation

@josef-pkt

Copy link
Copy Markdown
Member

this is the Stata file I'm currently using to dump results

Comment thread tools/estmat2nparray.ado

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need 12.0? I'm still running 11.x.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, I only have Stata 12, and I don't remember whether I changed this on purpose (I don't think so) or whether Stata did it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stata changed your .ado file? I think it's a minimum version for programs. Ie., this won't run on Stata < 12. Not positive about that though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can try it out and make changes, and I can check them on Stata 12,
I have absolutely no idea about different Stata versions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When and why did this get renamed to estmat2nparray? None of my .do files have this name.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And yeah this needs to be changed back to 11.0, if I'm going to be able to use it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like I renamed it when I started to add the ereturn list results, most likely to avoid name clashes when I was working with both versions, and to signal it add est
https://github.com/josef-pkt/statsmodels/commits/update_stata2py/tools/estmat2nparray.ado

@josef-pkt

Copy link
Copy Markdown
Member Author

Here is an example how I currently use it.

I do a bit of editing in the final file, that I haven't changed yet in the do file.
move Bunch definition to top
and in this example there are some extra nans . that are not automatically converted (a few syntax errors in the editor to find and replace them.)

(I haven't checked yet if the example do file in tools is outdated or not.)

/*
webuse dollhill3
outsheet using airline_dollhill3.csv, delimiter(",")
*/
clear
tempname filename
local filename = "results_poisson_constrained_.py"

insheet using airline_dollhill3.csv, delimiter(",")
gen lnpyears=ln(pyears)
constraint 1 4.agecat = 5.agecat

poisson deaths lnpyears smokes i.agecat
/* boiler plate, add matrices if needed */
tempname cov
tempname params_table
matrix cov = e(V)
matrix params_table = r(table)'
estat ic
matrix ic = r(S)
estmat2nparray params_table cov ic, saving(`filename') format("%16.0g") resname("noexposure_noconstraint") replace
/*------------------*/

poisson deaths smokes i.agecat, exposure(pyears)
/* boiler plate, add matrices if needed */
tempname cov
tempname params_table
matrix cov = e(V)
matrix params_table = r(table)'
estmat2nparray params_table cov, saving(`filename') format("%16.0g") resname("exposure_noconstraint") append
/*------------------*/

poisson deaths lnpyears smokes i.agecat, constraints(1)
/* boiler plate, add matrices if needed */
tempname cov
tempname params_table
matrix cov = e(V)
matrix params_table = r(table)'
estmat2nparray params_table cov, saving(`filename') format("%16.0g") resname("noexposure_constraint") append
/*------------------*/

poisson deaths smokes i.agecat, exposure(pyears) constraints(1)
/* boiler plate, add matrices if needed */
tempname cov
tempname params_table
matrix cov = e(V)
matrix params_table = r(table)'
estmat2nparray params_table cov, saving(`filename') format("%16.0g") resname("exposure_constraint") append
/*------------------*/

constraint 2 5.agecat - 4.agecat = 0.5

poisson deaths lnpyears smokes i.agecat, constraints(2)
/* boiler plate, add matrices if needed */
tempname cov
tempname params_table
matrix cov = e(V)
matrix params_table = r(table)'
estmat2nparray params_table cov, saving(`filename') format("%16.0g") resname("noexposure_constraint2") append
/*------------------*/

poisson deaths smokes i.agecat, exposure(pyears) constraints(2)
/* boiler plate, add matrices if needed */
tempname cov
tempname params_table
matrix cov = e(V)
matrix params_table = r(table)'
estmat2nparray params_table cov, saving(`filename') format("%16.0g") resname("exposure_constraint2") append
/*------------------*/

poisson deaths smokes i.agecat, exposure(pyears) constraints(2) vce(robust)
/* boiler plate, add matrices if needed */
tempname cov
tempname params_table
matrix cov = e(V)
matrix params_table = r(table)'
estmat2nparray params_table cov, saving(`filename') format("%16.0g") resname("exposure_constraint2_robust") append
/*------------------*/

when I want to add nobs arrays I add outsheet

capture drop fittedvalues fittedvalues_se 
predict fittedvalues, xb
predict fittedvalues_se, stdp
outsheet fittedvalues fittedvalues_se using theil_predict.csv, comma replace 

@josef-pkt josef-pkt added the PR label Aug 1, 2014
@josef-pkt josef-pkt mentioned this pull request Aug 26, 2014
@jseabold

Copy link
Copy Markdown
Member

Can merge this if comments are addressed.

@josef-pkt josef-pkt removed the PR label Mar 5, 2016
@josef-pkt josef-pkt mentioned this pull request Jun 5, 2017
7 tasks done
@josef-pkt

Copy link
Copy Markdown
Member Author

bump, I don't remember which or where ismy latest version (after switching computers and folders several times). It would be easier to just use the one in the statsmodels source tree.
(I'm using now Stata 14 mostly, and Stata 12 should be fine as minimum)

@jbrockmendel

Copy link
Copy Markdown
Contributor

@josef-pkt any thoughts on what the destiny of this file and/or PR?

@josef-pkt

Copy link
Copy Markdown
Member Author

Needs to be updated and merged.
I'm currently using a version of this file with Stata 14, but I'm not sure whether I made additional changes or not.
The file in my stata_work folder has modification date ‎Monday, ‎September ‎10, ‎2018, ‏‎9:36:02 AM

@josef-pkt

Copy link
Copy Markdown
Member Author

The latest version that I used is modified ‎January ‎7, ‎2022, which has some pep-8 compat fixes, AFAIR
I should open a new PR

@josef-pkt josef-pkt added the superseded Used for PRs with content that is superseded by a newer PR label Feb 20, 2023
@josef-pkt

Copy link
Copy Markdown
Member Author

new PR with updated version is in #8691

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

superseded Used for PRs with content that is superseded by a newer PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants