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)
xtivreg2: endogeneity and overidentificationHello everyone, I have an issue with interpret the result of xtivreg2: - Overidentification is signi…
Household Fixed EffectHello, Is there an issue with using HH fixed effects or individual fixed effects when the death of a…
Problems with command "etable"Hi there, My intention is to run "etable" to create a results table of two models. My code is: [A…
Help: weights not allowed r(101)Hi! I met a mistake in following command: egen x2 = group(sex re age educ) gen wm = sex == 1 &…
Estimating latent class models in Stata using both categorical and continuous indicator variablesHi Statalist community, I am trying to run latent class models and I am fairly new to this type of …
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