-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/friosavila/stpackages
- Loading branch information
Showing
4 changed files
with
144 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
*! v0.1 alt to tabstat | ||
*! v0.2 Two ways to collect Results | ||
* v0.1 alt to tabstat | ||
|
||
program tabstat2, rclass | ||
syntax anything(everything) [aw iw fw] [if] [in], [save *] | ||
tabstat `0' | ||
tempname smatrix | ||
tempname smatrix smatrix2 | ||
local j=1 | ||
if "`save'"!="" { | ||
while _rc==0 { | ||
matrix `smatrix' = nullmat(`smatrix'),r(Stat`j') | ||
local j=`j'+1 | ||
matrix `smatrix2' = nullmat(`smatrix2')\r(Stat`j') | ||
|
||
local j=`j'+1 | ||
capture confirm matrix r(Stat`j') | ||
} | ||
} | ||
return add | ||
return matrix tmatrix = `smatrix' | ||
end | ||
return matrix tmatrix2 = `smatrix2' | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
capture program drop pie_i | ||
capture program drop re_scale | ||
|
||
program re_scale, rclass | ||
syntax anything, [total] | ||
numlist "`anything'" , min(0) range(>=0) | ||
tempname tval | ||
scalar `tval'=0 | ||
foreach j of numlist `anything' { | ||
scalar `tval'=`tval'+`j' | ||
} | ||
|
||
if `tval'>100 { | ||
foreach j of numlist `anything' { | ||
local newlist `newlist' `=`j'/`tval'*100' | ||
} | ||
} | ||
else if "`total'"!="" { | ||
foreach j of numlist `anything' { | ||
local newlist `newlist' `=`j'/`tval'*100' | ||
} | ||
} | ||
else { | ||
local newlist `anything' `=100-`tval'' | ||
} | ||
return local newlist `newlist' | ||
end | ||
|
||
program pie_i | ||
syntax anything, [total RESolution(int 100) plotopt(string asis) ] | ||
qui:re_scale `anything', `total' | ||
local newlist `r(newlist)' | ||
tempname toplot | ||
frame create `toplot' | ||
frame `toplot': { | ||
set obs `resolution' | ||
range re 2*_pi 0 | ||
local hi0 = 0 | ||
set obs `=`resolution'+1' | ||
foreach i of numlist `newlist' { | ||
local j = `j'+1 | ||
local jm1 = `j'-1 | ||
** Local Cum | ||
local lw`j'=`hi`jm1'' | ||
local hi`j'=`lw`j''+`i'/100 | ||
qui:gen x`j' = cos(re*`i'/100+`lw`j''*2*_pi) | ||
qui:gen y`j' = sin(re*`i'/100+`lw`j''*2*_pi) | ||
qui:replace x`j'=0 in `=`resolution'+1' | ||
qui:replace y`j'=0 in `=`resolution'+1' | ||
} | ||
local tt `j' | ||
local j =0 | ||
|
||
forvalues i = 1/`tt' { | ||
local pieplot `pieplot' (area x`i' y`i', nodropbase lw(vthin)) | ||
} | ||
|
||
two `pieplot', `plotopt' aspect(1) yscale(off) xscale(off) | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
capture program drop pie_ii | ||
program pie_ii | ||
syntax anything, [*] | ||
tempname nframe | ||
frame create `nframe' | ||
frame `nframe' { | ||
set obs 1 | ||
foreach i in `anything' { | ||
local j = `j'+1 | ||
gen v`j'=`i' | ||
local vlist `vlist' v`j' | ||
} | ||
graph pie `vlist', `options' | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
*capture program drop pie_i | ||
*capture program drop re_scale | ||
|
||
program re_scale, rclass | ||
syntax anything, [total] | ||
numlist "`anything'" , min(0) range(>=0) | ||
tempname tval | ||
scalar `tval'=0 | ||
foreach j of numlist `anything' { | ||
scalar `tval'=`tval'+`j' | ||
} | ||
|
||
if `tval'>100 { | ||
foreach j of numlist `anything' { | ||
local newlist `newlist' `=`j'/`tval'*100' | ||
} | ||
} | ||
else if "`total'"!="" { | ||
foreach j of numlist `anything' { | ||
local newlist `newlist' `=`j'/`tval'*100' | ||
} | ||
} | ||
else { | ||
local newlist `anything' `=100-`tval'' | ||
} | ||
return local newlist `newlist' | ||
end | ||
|
||
program pie_i | ||
syntax anything, [total RESolution(int 100) plotopt(string asis) ] | ||
re_scale `anything', `total' | ||
local newlist `r(newlist)' | ||
tempname toplot | ||
frame create `toplot' | ||
frame `toplot': { | ||
set obs `resolution' | ||
range re 2*_pi 0 | ||
local hi0 = 0 | ||
set obs `=`resolution'+1' | ||
foreach i of numlist `newlist' { | ||
local j = `j'+1 | ||
local jm1 = `j'-1 | ||
** Local Cum | ||
local lw`j'=`hi`jm1'' | ||
local hi`j'=`lw`j''+`i'/100 | ||
gen x`j' = cos(re*`i'/100+`lw`j''*2*_pi) | ||
gen y`j' = sin(re*`i'/100+`lw`j''*2*_pi) | ||
replace x`j'=0 in `=`resolution'+1' | ||
replace y`j'=0 in `=`resolution'+1' | ||
} | ||
local tt `j' | ||
local j =0 | ||
|
||
forvalues i = 1/`tt' { | ||
local pieplot `pieplot' (area x`i' y`i', nodropbase lw(vthin)) | ||
} | ||
|
||
two `pieplot', `plotopt' aspect(1) yscale(off) xscale(off) | ||
} | ||
end |