Open bvkrauth opened 4 years ago
The new RESCALE option (see https://github.com/bvkrauth/rcr/issues/63) helps solve this problem. When rescale is set to "yes", the range allowed for XRANGE becomes 50*SD(outcome)/SD(treatment), which is very large.
But this creates something of a new problem: because the range is so large, the values returned by DETAILS are not very close together and it is possible that this will affect the graphs. I may need to make some additional changes to avoid this problem so I am keeping this issue open.
Here is some code that would work to interpolate, but I don't like the way the graph looks.
run config_test `0'
which rcr
which rcrplot
di "Data from file ${fname}" _newline ///
"Parameter values for tests: os = ${os}, exe = ${exe}, tol = ${tol}"
*****************************************************************************
* Test BUG014
*****************************************************************************
* Description of bug: rcrplot doesn't work with xrange outside of (-50,50).
* The problem is that rcr, details only calculates
* lambda(betax) for a grid of betax values between
* -50 and 50.
*
* Possible solutions:
* (1) Don't accept values of xrange outside that range
* (2) Change rcr to calculate lambda(betax) for some
* tail values and interpolate between them.
rcr SAT Small_Class ${controls}, details
* The axes on this graph run from -100 to 100, but the lines only run from
* -50 to 50
rcrplot , xrange(-100 100)
* One possible workaround is to linearly interpolate the end points like
* this. But it doesn't look great, so I probably don't want to implement it
local xmin -100
local xmax 100
sort betax
count if betax == `xmin'
if r(N) == 0 {
egen min_obs = rank(-betax) if betax < `xmin'
gen double lambda_fit = lambda + (lambda[_n + 1]- lambda)/(betax[_n + 1] - betax) * (`xmin' - betax)
replace betax = `xmin' if min_obs == 1
replace lambda = lambda_fit if min_obs == 1
keep betax lambda
}
count if betax == `xmax'
if r(N) == 0 {
egen max_obs = rank(betax) if betax > `xmax'
gen double lambda_fit = lambda + (lambda[_n - 1]- lambda)/(betax[_n - 1] - betax) * (`xmax' - betax)
replace betax = `xmax' if max_obs == 1
replace lambda = lambda_fit if max_obs == 1
keep betax lambda
}
rcrplot , xrange(`xmin' `xmax')
See bug014.do