Hello to the readers! I am estimating discretionary accruals by using a modified jones model. I am pretty sure I am using all the correct symbols. Nevertheless, the error r(198) comes up.
This is the part where the mistake occurs:
sum sic2id
local k=r(max)
forvalues i=1(1) `k'{
qui reg tacc inverse_a drev ppe if sic2id== `i'
qui predict res if sic2id== `i', res
qui replace dac=res if sic2id== `i'
qui replace r2a=e(r2_a) if sic2id==`i'
qui replace b1=_b[inverse_a] if sic2id== `i'
qui replace b2=_b[drev] if sic2id== `i'
qui replace b3=_b[ppe] if sic2id== `i'
qui drop res
di `i' " / " `k'
}
I have read multiple posts like mine and tried to solve it like you guys:
What I tried to do is:
gen Jones_Modified = .
forval y = 2010(1) 2019 {
forval i = 1(1) {
display `i'
display `y'
capture reg tacc inverse_a drev ppe if `i' == sic2id & `y' == fyear, noconstant
if c(rc) == 0 { // SUCCESSFUL REGRESSION
predict r if `i' == sic2id & `y' == fyear, resid
replace Jones_Modified = r if `i' == sic2id & `y' == fyear
drop r
}
else if !inlist(c(rc), 2000, 2001) { // UNANTICIPATED ERROR
display as error "Unexpected error encountered"
exit c(rc)
}
else { // NO OR INSUFFICIENT OBSERVATIONS; NOTIFY & PROCEED
display "No or insufficient observations"
}
}
}
But the mistake is the same. The ticks are accurate and I also tried to play with spaces.
Could you please look at my code.
Very much appreciated.
This is the part where the mistake occurs:
sum sic2id
local k=r(max)
forvalues i=1(1) `k'{
qui reg tacc inverse_a drev ppe if sic2id== `i'
qui predict res if sic2id== `i', res
qui replace dac=res if sic2id== `i'
qui replace r2a=e(r2_a) if sic2id==`i'
qui replace b1=_b[inverse_a] if sic2id== `i'
qui replace b2=_b[drev] if sic2id== `i'
qui replace b3=_b[ppe] if sic2id== `i'
qui drop res
di `i' " / " `k'
}
I have read multiple posts like mine and tried to solve it like you guys:
What I tried to do is:
gen Jones_Modified = .
forval y = 2010(1) 2019 {
forval i = 1(1) {
display `i'
display `y'
capture reg tacc inverse_a drev ppe if `i' == sic2id & `y' == fyear, noconstant
if c(rc) == 0 { // SUCCESSFUL REGRESSION
predict r if `i' == sic2id & `y' == fyear, resid
replace Jones_Modified = r if `i' == sic2id & `y' == fyear
drop r
}
else if !inlist(c(rc), 2000, 2001) { // UNANTICIPATED ERROR
display as error "Unexpected error encountered"
exit c(rc)
}
else { // NO OR INSUFFICIENT OBSERVATIONS; NOTIFY & PROCEED
display "No or insufficient observations"
}
}
}
But the mistake is the same. The ticks are accurate and I also tried to play with spaces.
Could you please look at my code.
Very much appreciated.
Comment