by foreign make : egen median_2 = median(price) //中位数 by foreign make : egen sd_2 = sd(price) //标准差 gen x = sd_2*sd_2 //方差 *bysort bysort foreign make : egen mean_2 = mean(price) //均值 bysort foreign make : egen median_2 = median(price) //中位数 bysort forei...
We wish to obtain the deviation in length of stay from the median for all patients having the same diagnostic code: . use https://www.stata-press.com/data/r18/egenxmpl2, clear . by dcode, sort: egen medstay = median(los) . generate deltalos = los - medstay Example 3: sum() ...
For instance, we can generate basis functions with basis as the stub name: makespline bspline x2-x5, basis(basis) This would generate a third-order B-spline basis function for each of the variables in x2-x5, with knots at the medians of x2-x5. Each of the basis functions would ...