Computing Discretionary Accruals
Posted: 30 March 2015 03:32 AM   [ Ignore ]
Newbie
Rank
Total Posts:  4
Joined  2015-03-30

Hi guys,

I have a question regarding my calculating on the discretionary accruals. For this calculation I used a lot of commands, but the last commands are creating a loop to calculate the final discretionary accruals. But, no matter what I try, I keep getting an “invalid syntax (r198)”.

sum sic2id
scalar max2=r(max)
local k=max2
set more off
forvalues i=1(1)`k’{
qui reg acc inverse_assets dsal ppeg roa if sic2id==`i’
qui predict res if sic2id==`i’, res
qui replace accr=res if sic2id==`i’
qui replace adjr2=e(r2_a) if sic2id==`i’
qui replace b0=_b[_cons]
qui replace b1=_b[inverse_assets]
qui replace b2=_b[dsal]
qui replace b3=_b[ppeg]
qui replace b4=_b[roa]
qui drop res
di `i’ ” / ” `k’
}


A friend of mine tried the same commands and it did work for her. Do you guys have any idea about the mistake I made of what to do about this invalid syntax?
Btw: In order to test whether I did something wrong in my do-file, I ran here do-file on my dataset and it still gave the invalid syntax code.

 

Profile
 
 
Posted: 31 March 2015 07:18 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

hi Tessa,

Did you try:
- removing some of the statements? for examle, the ‘replace’ statements, or only running the regression in the loop
- running it on a smaller dataset (maybe there is an industry with few obs that cannot be estimated)

Hope this helps,

Joost

 Signature 

To reply/post new questions: Please use the group WRDS/SAS on Google Groups! http://groups.google.com/d/forum/wrdssas

Profile
 
 
Posted: 09 April 2015 04:46 AM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  4
Joined  2015-03-30

Even my regression gives me an invalid syntax?

Profile
 
 
Posted: 09 April 2015 10:08 AM   [ Ignore ]   [ # 3 ]
Newbie
Rank
Total Posts:  19
Joined  2015-02-12

Are you sure you used correct names for the variables?

Profile
 
 
Posted: 09 April 2015 10:09 AM   [ Ignore ]   [ # 4 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

Try:

// try some industry
reg acc inverse_assets dsal ppeg roa if sic2id==1
// try full sample
reg acc inverse_assets dsal ppeg roa 
//browse relevant variables: are they all numbers? (right aligned, as opposed to left aligned for text)
browse acc inverse_assets dsal ppeg roa 

Best,

Joost

 Signature 

To reply/post new questions: Please use the group WRDS/SAS on Google Groups! http://groups.google.com/d/forum/wrdssas

Profile
 
 
Posted: 13 April 2015 01:06 AM   [ Ignore ]   [ # 5 ]
Newbie
Rank
Total Posts:  4
Joined  2015-04-13

Hi Tessa,

Regarding discretionary accruals, Robson provided very detailed tutorial. You can find his posts here: https://robsonglasscock.wordpress.com/

In addition, you can find improved code here http://www.statalist.org/forums/forum/general-stata-discussion/general/312185-estimating-discretionary-accruals-using-the-modified-jones-1991

Profile