#delim ; version 16.0; * Create plot of native center ridits for the variable trunk in the xauto data. SSC packages required: xauto, xcontract, keyby, wridit, xframeappend, lablist. *; clear all; set scheme rbn4mono; * Input data *; xauto, clear; * Create frame trunkfreq with 1 obs per trunk value present in the dataset and data on frequencies and add ridit variables *; xcontract trunk, frame(trunkfreq); frame trunkfreq {; wridit trunk [fwei=_freq], handedness(left) gene(lridit); wridit trunk [fwei=_freq], handedness(right) gene(rridit); wridit trunk [fwei=_freq], handedness(center) gene(cridit); lab var lridit "Left ridit"; lab var rridit "Right ridit"; lab var cridit "Center ridit"; desc, fu; list, abbr(32); }; * Create data frame trunkval with 1 obs per trunk value from 4 to 24 by 0.5 and add foreign ridits from frame trunkfreq *; local trunkmin=4; local trunkmax=24; local intwidth=0.5; cap frame drop trunkval; frame create trunkval; frame trunkval {; set obs `=1+(`trunkmax'-`trunkmin')/`intwidth''; gene trunk=`trunkmin'+`intwidth'*(_n-1); fridit trunk, fframe(trunkfreq, weight(_freq)) handedness(left) gene(lridit); fridit trunk, fframe(trunkfreq, weight(_freq)) handedness(right) gene(rridit); fridit trunk, fframe(trunkfreq, weight(_freq)) handedness(center) gene(cridit); compress; desc, fu; list, abbr(32); }; * Append data frames into default frame *; clear; xframeappend trunkfreq trunkval, gene(obstype) drop; lab def obstype 1 "Value in data" 2 "Value in range"; lab val obstype obstype; lab var obstype "Observation type"; compress; keyby obstype trunk; desc, fu; lablist obstype, var; by obstype: list, abbr(32); * Create plots *; * Use left ridit with connect(stepstair) for center ridit function line *; line lridit trunk if obstype==2, sort connect(stepstair) || scatter cridit trunk if obstype==1, msym(circle) msize(1) || , ylab(0(0.125)1) ytitle("Native center ridit function") xlab(`trunkmin'(1)`trunkmax') legend(size(3) row(1) order(1 "Ridit function" 2 "Ridit of mass point")) ysize(4.6) xsize(4.6); graph export figseq1.pdf, replace; more; * Use right ridit with connect(stairstep) for center ridit function line *; line rridit trunk if obstype==2, sort connect(stairstep) || scatter cridit trunk if obstype==1, msym(circle) msize(1) || , ylab(0(0.125)1) ytitle("Native center ridit function") xlab(`trunkmin'(1)`trunkmax') legend(size(3) row(1) order(1 "Ridit function" 2 "Ridit of mass point")) ysize(4.6) xsize(4.6); graph export figseq2.pdf, replace; more; exit;