I want to perform a graphical analysis called "worm plot"; it is a detrended plot, where one plots the difference between the empirical and theoretical distributions (y axis) against the theoretical distribution (x axis).
I've obtained the empirical Z distribution and I need to generate the theoretical distribution within age ranges. I have tried the following:
egen ndist_t = rank(emp_z),by(agerange)
egen Ndist_t = count(emp_z),by(agerange)
gen zdist_t = n/(N+1)
replace zdist_t = invnorm(zdist_t)
At the end I imagine to have obtained the theoretical distribution to my (Z) sample.
Am I right? If so, is there some way more appropriated to do it?
Many thanks in advanced,