Hi, I have problem to calculate the predicted value of my variable, cashtoasset, for each observation. I use panel data with gvkey (cross sectional unit) and year (time unit). I use this model to calculate the predicted value for cashtoasset but i fail a lot when i use the loop function:
reg cashtoasset size markettobook cashflow ncworkingcapital bookleverage dividend acquisition
this is the problem i mean:
xtset gvkey year
Panel variable: gvkey (unbalanced)
Time variable: year, 1999 to 2022, but with gaps
Delta: 1 unit
. egen id=group(gvkey)
. gen predicted_cashtoasset=.
(6,302 missing values generated)
. qui sum id, meanonly
. local N= r(N)
. forvalues i=1(1)`N' {
reg cashtoasset size markettobook cashflow ncworkingcapital bookleverage dividend acquisition if id==`i'
predict px if id==`i'
replace predicted_cashtoasset = px if id==`i'
drop px
}
no observations
r(2000);
Do anyone know how calculate the predicted value ? Thank you
reg cashtoasset size markettobook cashflow ncworkingcapital bookleverage dividend acquisition
this is the problem i mean:
xtset gvkey year
Panel variable: gvkey (unbalanced)
Time variable: year, 1999 to 2022, but with gaps
Delta: 1 unit
. egen id=group(gvkey)
. gen predicted_cashtoasset=.
(6,302 missing values generated)
. qui sum id, meanonly
. local N= r(N)
. forvalues i=1(1)`N' {
reg cashtoasset size markettobook cashflow ncworkingcapital bookleverage dividend acquisition if id==`i'
predict px if id==`i'
replace predicted_cashtoasset = px if id==`i'
drop px
}
no observations
r(2000);
Do anyone know how calculate the predicted value ? Thank you
Comment