Hello
I would like some assistance with generating newvar [XIRR] from returned r-class command.
I am using the finxirr (command for a single cash-flow series) package from http://www.stata.com/users/kcrow
The sample data is:
id amount date
1 -10000 01/01/2008
1 2750 01/03/2008
1 4250 30/10/2008
1 3250 15/02/2009
1 2750 01/04/2009
2 -12000 01/01/2008
2 2750 01/03/2008
2 4250 30/10/2008
2 3250 15/02/2009
2 2750 01/04/2009
I require the return to be separated by the var_id, so I have used the 'by id:' command
CODE:
. by id: finxirr amount
The result is displayed in the results window as follows:
--------------------------------------------------------------------------------------------------------------------------------------------------------------
-> id = 1
XIRR, Extented internal rate of return = .373
--------------------------------------------------------------------------------------------------------------------------------------------------------------
-> id = 2
XIRR, Extented internal rate of return = .0994
I have used the return list command to display scalar r(xirr)
. return list
scalars:
r(xirr) = .0993987644807661
And then gen command to create the newvar:
. generate XIRR = `r(xirr)'
However, the variable for both id1 & id2 display the result for id = 2, as shown below:
id amount date XIRR
1 -10000 01/01/2008 .0993988
1 2750 01/03/2008 .0993988
1 4250 30/10/2008 .0993988
1 3250 15/02/2009 .0993988
1 2750 01/04/2009 .0993988
2 -12000 01/01/2008 .0993988
2 2750 01/03/2008 .0993988
2 4250 30/10/2008 .0993988
2 3250 15/02/2009 .0993988
2 2750 01/04/2009 .0993988
I have read the stored results and return stored results stata PDF Guides and searched the forums and understand that "returned results from previous commands are replaced by subsequent commands of the same class".
I have searched the forums and could not see an example of how to run the return list command when the results are provided in the format above (id separated by dashed line)
I require id1 XIRR variable to display .373 - it's returned 'r(xirr)' result while XIRR for id2 maintains its 'r(xirr)' result.
Any assistance would be greatly appreciated.
Mark
Related Posts with Generating new variable from r-class command that produces multiple returns (as a result of using 'by:' command)
coefficients for covariates under inverse probability weighting modelHello, i know Code: teffects ipw or Code: teffects ipwra estimate the treatment effect on the …
forvalues: unexpected value of a looping local: 81/100=.8100000000000001Dear Stata list users, I want to loop over values d=0(0.01)0.2 and d2= 0.80(0.01)1 I already know t…
Estimation of censored valueDear All, Situation: I have some biological variables containing left censored observation (below t…
Using teffects psmatch, is it possible to display the logistic treatment model used to generate the propensity scores?When using teffects psmatch, is it possible to display the logistic treatment model used by teffects…
identify years of violations.Dear All, I find this question here (https://bbs.pinggu.org/forum.php?mod...=1#pid56831974). The dat…
Subscribe to:
Post Comments (Atom)
0 Response to Generating new variable from r-class command that produces multiple returns (as a result of using 'by:' command)
Post a Comment