Hi everyone,
Has anyone experienced errors with levelsof not present with levels commands? This curious case occurs with the following effort to find the value for _n at which rho is maximized or MAE is minimized under specific conditions. The `variables' list has "ihap irlx isad" and `panelrange' is "1/3". The following levels command works:
if "`Ecriterion'"=="rho" | "`Ecriterion'"=="mae" {
qui gen long obsno=_n
foreach var of varlist `variables' {
foreach id of numlist `panelrange' {
capture noisily {
quietly summarize SP_`Ecriterion'_`var'_ID if SP_id_`var'_ID==`id' & SP_d_`var'_ID==`diff', meanonly
if "`Ecriterion'"=="rho" loc a="max"
else if "`Ecriterion'"=="mae" loc a="min"
levels obsno if SP_`Ecriterion'_`var'_ID == r(`a') & SP_id_`var'_ID==`id' & SP_d_`var'_ID==`diff'
loc emax`var'`id'=SP_e_`var'_ID[`r(levels)']
}
}
}
}
The code is not perfect and could use a clean, but it works just fine. I have confirmed this by checking the contents of the `emax`var'`id'' macros. However, curiously, if the "levels" command is replaced with "levelsof", then the following errors result:
SP_e_ihap_ID not found
SP_e_ihap_ID not found
SP_e_ihap_ID not found
SP_e_irlx_ID not found
SP_e_irlx_ID not found
SP_e_irlx_ID not found
SP_e_isad_ID not found
SP_e_isad_ID not found
SP_e_isad_ID not found
This is very strange, I think, because the two commands are often interchangeable (and meant to be so)? If anyone has experienced anything similar or can diagnose the problem, please let me know! The gtools version of levelsof also produces the same errors.
Thanks for any input and time you can offer!
Mike
Related Posts with Error with levelsof but not levels command
My fixed effects regression changes if I omit an omitted variableHello all, I run a fixed effects regression in a linear probability model of self rated health and …
How can I calculate a confidence interval around a linear spline that it interacted with another variableI have a large dataset (50m rows) in Stata. One of my independent variables is age, and I'm using li…
Absolute value of residualHello Experts A typical measure for firms’ use of earnings management in the finance literature is b…
How to identify closing triads in a panel data set?Dear Stata experts, I am currently working on a project using panel data with 20.286 observations. …
Regular survival analysis versus competing risk analysisHi, I have a question regarding my analysis setup for research on the exit-route for strategies ado…
Subscribe to:
Post Comments (Atom)
0 Response to Error with levelsof but not levels command
Post a Comment