display "Developed by Thomas W. Findley, MD, PhD" display "Kessler Institute for Rehabilitation, W. Orange, NJ 07052" if "%_1"=="" { display "you must type the name of the variable you want transformed" display "syntax is do transfor var1 var2" display "where var1 is the variable you want transformed" display " and var2 is an (optional) variable you want var1 graphed against" exit 198 } /* save transtmp,replace *you may delete this if you are using Professional Stata */ /* keep %_1 %_2 *or have fewer than 8 variables in Student Stata */ generate x=%_1 generate cube=x^3 generate square=x^2 generate sqroot=x^.5 generate log = log(x) generate negrecrt=-(x^(-.5)) generate negrec=-(x^(-1)) label variable cube "Cube Transformation of %_1" label variable square "Square Transformation of %_1" label variable x "Raw Data of %_1" label variable sqroot "Square Root of %_1" label variable log "Natural Logarithm of %_1" label variable negrecrt "Negative Reciprocal Root of %_1" label variable negrec "Negative Reciprocal of %_1" capture confirm existence %_2 if _rc==0 { #delimit ; graph sqroot log negrecrt negrec cube square x %_2, r c(lllllll) sort s(dOTSpo.) b1 ("+ Cube Transformation o Square Transformation") saving (trans.gph,replace); *use transtmp,clear; #delimit cr exit 198 } summarize cube,detail display "For Cube Transformation of %_1" display "Skewness is " _result(14) di "For a measure of skewness less affected by outlying data points, compare" display "mean value is " _result(3) display "median value is " _result(10) di " " display "Kurtosis is " _result(15) " Kurtosis of Normal distribution is 3" display "To measure the tails of the distribution more robustly, compare" display "Standard deviation is " _result(4)^.5 display "Interquartile range/1.35 is " (_result(11)-_result(9))/1.35 di " " display "Finally, does the predicted range of data make any sense?" display "The range has been converted back to the original units of %_1" di "90% range is from Mean - 1.6 S.D." (_result(3)-1.645*_result(4)^.5)^(1/3) di "to Mean + 1.6 S.D." (_result(3)+1.645*_result(4)^.5)^(1/3) display "Actual 90% range is from 5% " (_result(7))^(1/3) display "to 95% " (_result (13))^(1/3) di " " di _dup(59) "-" di " " summarize square,detail display "For Square Transformation of %_1" display "Skewness is " _result(14) di "For a measure of skewness less affected by outlying data points, compare" display "mean value is " _result(3) display "median value is " _result(10) di " " display "Kurtosis is " _result(15) " Kurtosis of Normal distribution is 3" display "To measure the tails of the distribution more robustly, compare" display "Standard deviation is " _result(4)^.5 display "Interquartile range/1.35 is " (_result(11)-_result(9))/1.35 di " " display "Finally, does the predicted range of data make any sense?" display "The range has been converted back to the original units of %_1" di "90% range is from Mean - 1.6 S.D." (_result(3)-1.645*_result(4)^.5)^(1/2) di "to Mean + 1.6 S.D." (_result(3)+1.645*_result(4)^.5)^(1/2) display "Actual 90% range is from 5% " (_result(7))^(1/2) display "to 95% " (_result (13))^(1/2) di " " di _dup(59) "-" di " " summarize x,detail display "Raw data of %_1" display "Skewness is " _result(14) di "For a measure of skewness less affected by outlying data points, compare" display "mean value is " _result(3) display "median value is " _result(10) di " " display "Kurtosis is " _result(15) " Kurtosis of Normal distribution is 3" display "To measure the tails of the distribution more robustly, compare" display "Standard deviation is " _result(4)^.5 display "Interquartile range/1.35 is " (_result(11)-_result(9))/1.35 di " " display "Finally, does the predicted range of data make any sense?" display "The range has been converted back to the original units of %_1" di "90% range is from Mean - 1.6 S.D." (_result(3)-1.645*_result(4)^.5) di "to Mean + 1.6 S.D." (_result(3)+1.645*_result(4)^.5) display "Actual 90% range is from 5% " (_result(7)) display "to 95% " (_result (13)) display " " di _dup(59) "-" di " " summarize sqroot,detail display "For Square Root Transformation of %_1" display "Skewness is " _result(14) di "For a measure of skewness less affected by outlying data points, compare" display "mean value is " _result(3) display "median value is " _result(10) di " " display "Kurtosis is " _result(15) " Kurtosis of Normal distribution is 3" display "To measure the tails of the distribution more robustly, compare" display "Standard deviation is " _result(4)^.5 display "Interquartile range/1.35 is " (_result(11)-_result(9))/1.35 di " " display "Finally, does the predicted range of data make any sense?" display "The range has been converted back to the original units of %_1" di "90% range is from Mean - 1.6 S.D." (_result(3)-1.645*_result(4)^.5)^2 di "to Mean + 1.6 S.D." (_result(3)+1.645*_result(4)^.5)^2 display "Actual 90% range is from 5% " (_result(7))^2 display "to 95% " (_result (13))^2 di " " di _dup(59) "-" di " " summarize log,detail display "For Natural Logarithm Transformation of %_1" display "Skewness is " _result(14) di "For a measure of skewness less affected by outlying data points, compare" display "mean value is " _result(3) display "median value is " _result(10) di " " display "Kurtosis is " _result(15) " Kurtosis of Normal distribution is 3" display "To measure the tails of the distribution more robustly, compare" display "Standard deviation is " _result(4)^.5 display "Interquartile range/1.35 is " (_result(11)-_result(9))/1.35 di " " display "Finally, does the predicted range of data make any sense?" display "The range has been converted back to the original units of %_1" di "90% range is from Mean - 1.6 S.D." exp(_result(3)-1.645*_result(4)^.5) di "to Mean + 1.6 S.D." exp(_result(3)+1.645*_result(4)^.5) display "Actual 90% range is from 5% " exp(_result(7)) display "to 95% " exp(_result (13)) di " " di _dup(59) "-" di " " summarize negrecrt,detail display "For Negative Reciprocal Square Root Transformation of %_1" display "Skewness is " _result(14) di "For a measure of skewness less affected by outlying data points, compare" display "mean value is " _result(3) display "median value is " _result(10) di " " display "Kurtosis is " _result(15) " Kurtosis of Normal distribution is 3" display "To measure the tails of the distribution more robustly, compare" display "Standard deviation is " _result(4)^.5 display "Interquartile range/1.35 is " (_result(11)-_result(9))/1.35 di " " display "Finally, does the predicted range of data make any sense?" display "The range has been converted back to the original units of %_1" di "90% range is from Mean - 1.6 S.D. " 1/((_result(3)-1.645*(_result(4)^.5))^2) di "to Mean + 1.6 S.D. " 1/((_result(3)+1.645*(_result(4)^.5))^2) display "Actual 90% range is from 5% " 1/(_result(7)^2) display "to 95% " 1/(_result(13)^2) di " " di _dup(59) "-" di " " summarize negrec,detail display "For Negative Reciprocal Transformation of %_1" display "Skewness is " _result(14) di "For a measure of skewness less affected by outlying data points, compare" display "mean value is " _result(3) display "median value is " _result(10) di " " display "Kurtosis is " _result(15) " Kurtosis of Normal distribution is 3" display "To measure the tails of the distribution more robustly, compare" display "Standard deviation is " _result(4)^.5 display "Interquartile range/1.35 is " (_result(11)-_result(9))/1.35 di " " display "Finally, does the predicted range of data make any sense?" display "The range has been converted back to the original units of %_1" di "90% range is from Mean - 1.6 S.D. " -1/((_result(3)-1.645*_result(4)^.5)) di "to Mean + 1.6 S.D. " -1/(_result(3)+1.645*_result(4)^.5) display "Actual 90% range is from 5% " -1/_result(7) display "to 95% " -1/_result(13) set textsize 200 graph cube,hist normal bin(10) saving(trans1,replace) graph square,hist normal bin(10) saving(trans2,replace) graph x,hist normal bin(10) saving(trans3,replace) graph sqroot,hist normal bin(10) saving(trans4,replace) graph log,hist normal bin(10) saving(trans5,replace) graph negrecrt,hist normal bin(10) saving(trans6,replace) graph negrec,hist normal bin(10) saving(trans7,replace) graph using trans1 trans2 trans3 trans4 trans5 trans6 trans7, saving(trans8,replace) set textsize 100 graph cube square x sqroot log negrecrt negrec, oneway box r saving(trans9,replace) /* use transtmp.dta,clear * delete this if you are using regular STATA */ /* shell del transtmp.dta * delete this for regular STATA */