File restructure #1

This commit is contained in:
2024-04-19 16:46:33 +02:00
parent a8a94ddc10
commit ecac05b9c4
703 changed files with 10 additions and 272568 deletions

View File

@ -1,77 +0,0 @@
*! Dan Blanchette 1.1 dan.blanchette@duke.edu 08Feb2005
*! Center of Entrepreneurship and Innovation Duke University's Fuqua School of Business
** research computing, unc-ch
* Stata fixed Linux problem of not being able to edit a file in a directory starting with "~"
* Added "Caution" note when requesting to edit a Stata ado file.
** Dan Blanchette 1.0.3 06 Nov 2003 made it work in Linux
*! NJC 1.0.2 31 Dec 2002
** CFB 1.0.1 26Dec2002 cloned from adotype
* NJC 1.2.1 1 December 1999
** NJC 1.2.2 6 December 1999
* NJC 1.2.3 14 December 1999
** AJM 1.3 5 August 2009 (Eliminated file size check for versions 11 and greater.)
program def adoedit, rclass
version 8.0
if "`1'" == "" | "`2'" != "" {
di as err "incorrect syntax"
exit 198
}
args cmd
/* ends with .ado */
if substr(`"`cmd'"',length(`"`cmd'"')-3,length(`"`cmd'"'))==".ado" {
local filen `"`cmd'"'
}
else {
local filen `"`cmd'.ado"'
}
findfile `filen'
// here will exit 601 if `cmd' not found
local file `"`r(fn)'"'
local tfile : subinstr local file "\" "/" , all
if index(`"`tfile'"',"/ado/base") | index(`"`tfile'"',"/ado/updates") {
di " "
di as err "Caution, you are requesting to edit an ado file provided by Stata."
di as err "If this is really what you want, consider first copying the file to {input}`: sysdir PERSONAL' {error}."
di " "
more
di " "
}
capture hexdump `"`file'"', analyze
local size = r(filesize)
* Eliminates file size check for versions 11 and greater.
if c(stata_version) < 11 {
if `size' < 32000 & `size' > 0 {
doedit `"`file'"'
discard
return local adofile `"`file'"'
exit 0
}
else {
di as txt _n "Sorry, files larger than 32,000 bytes cannot be do-edited."
di as txt "You must use another text editor for this file."
error 603
}
}
else if c(stata_version) >= 11 {
doedit `"`file'"'
discard
return local adofile `"`file'"'
exit 0
}
end

View File

@ -1,87 +0,0 @@
{smcl}
{* 5Aug2009}{...}
{* 17Jan2008}{...}
{* 06Nov2003}{...}
{hline}
help for {hi:adoedit} {right:manual: {hi:[R] none}}
{right:dialog: {hi: none} }
{hline}
{title:Edit ado-file in Stata's do-file editor}
{p 8 17 2}{cmd:adoedit}
{it:cmdname}
{p_end}
{title:Description}
{p 4 4 2}
{cmd:adoedit} attempts to edit whichever ado-file named {cmd:cmdname.ado} is first on the
current {help adopath:adopath}. In Stata Version 10 and earlier, one cannot edit files
larger than 32,000 bytes in the do-file editor, nor can one edit built-in commands.
The file size limitation is removed for Stata Version 11 and later.
{p 4 4 2}
This routine is designed for use by those who are writing their own ado-files;
users are exhorted to make a copy of any official ado-files, and to save modified official
ado-files in the ado directory, rather than the Stata directory.{p_end}
{p 4 4 2}
{cmd:adoedit cmdname.ado}
is tolerated.{p_end}
{p 4 4 2}
After a successful edit, the {cmd:discard} command is issued so that Stata will load the
revised ado-file. This will also clear any estimates from the last estimation.{p_end}
{p 4 4 2}
If you wish to edit ado-files with a different text editor, please see
{stata findit fedit:fedit} and the {stata findit texteditors:texteditors} modules on the
{help ssc:SSC} archive.{p_end}
{title:Examples}
{p 4 8 2}{cmd:. adoedit tsspell}{p_end}
{title:Saved Results}
{p 4 8 2}
The {cmd:adoedit} command saves in {cmd:r()}:{p_end}
{synoptset 20 tabbed}{...}
{p2col 5 20 24 2: Macros}{p_end}
{synopt:{cmd:r(adofile)}}the ado-file name and full path{p_end}
{title:Author}
{p 4 4 2}
Dan Blanchette {break}
Center of Entrepreneurship and Innovation {break}
Duke University's Fuqua School of Business {break}
Dan.Blanchette@Duke.edu{p_end}
{title:Acknowledgements}
{p 4 4 2}
This program grew out of previous work by:{p_end}
{p 6 4 2}
Nicholas J. Cox, University of Durham, U.K.{p_end}
{p 4 4 2}
and{p_end}
{p 6 4 2}
Christopher F Baum, Boston College, USA{p_end}
{title:Also see}
{p 4 13 2}On-line: {help doedit:doedit} {help fildfile:findfile},
{help fedit:fedit} (if installed){p_end}

View File

@ -1,23 +0,0 @@
program def alphlist, rclass
*! NJC 1.1.1 28 June 2001
* NJC 1.1.0 6 June 2000
* NJC 1.0.0 27 Jan 2000
version 6.0
syntax , [ Capitals Underscore Global(str) Noisily ]
if length("`global'") > 8 {
di in r "global name must be <=8 characters"
exit 198
}
if "`capitals'" != "" {
local newlist "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
}
else local newlist "a b c d e f g h i j k l m n o p q r s t u v w x y z"
if "`underscore'" != "" { local newlist "`newlist' _" }
if "`noisily'" != "" { di "`newlist'" }
if "`global'" != "" { global `global' "`newlist'" }
return local list `newlist'
end

View File

@ -1,2 +0,0 @@
.h listutil

View File

@ -1,48 +0,0 @@
*! version 1 27may2007
*! Jean-Benoit Hardouin
*
************************************************************************************************************
* Stata program : anaoption
*
* Historic
* Version 1 (2007-05-27): Jean-Benoit Hardouin
*
* Jean-benoit Hardouin, phD, Assistant Professor
* Team of Biostatistics, Clinical Research and Subjective Measures in Health Sciences
* University of Nantes - Faculty of Pharmaceutical Sciences
* France
* jean-benoit.hardouin@anaqol.org
*
* News about this program :http://www.anaqol.org
* FreeIRT Project website : http://www.freeirt.org
*
* Copyright 2007 Jean-Benoit Hardouin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
************************************************************************************************************
program define anaoption ,rclas
version 7.0
syntax [, DETails minvi(real .03) siglevel(real 0.05) minsize(real 0)]
return scalar minvi=`minvi'
return scalar siglevel=`siglevel'
return scalar minsize=`minsize'
return local details `details'
end

View File

@ -1,697 +0,0 @@
*! 0.3.2 2009-03-14 | long freese | fix mean calculation
** predictions for asmprobit
capture program drop asprvalue
capture program drop _Prvasmp
program define asprvalue, rclass
version 9
if e(cmd) == "asmprobit" {
_Prvasmp `0' // local program just for asmprobit -- see below
return add
exit
}
preserve
syntax [, x(passthru) Cat(string) Base(string) Save Diff Rest(string) BRief Full]
* need to sort to calculate means below so accurate for unbalanced panels
local idvar "`e(group)'"
tempname recordnum
sort `idvar', stable
by `idvar' : gen `recordnum' = _n
tempname b
mat `b' = e(b)
local allnames : colnames `b'
* check if there are any interactions, so that otherwise warning message can be specified
local anyX "no"
* make list of case-specific variables
foreach var of local allnames {
local i = index("`var'", "X")
if `i' != 0 {
local anyX "yes"
* is it an alternativeXcase-specific-variable interaction?
local temppreX = substr("`var'", 1, `i'-1)
local temppostX = substr("`var'", `i'+1, .)
* assume that preX are all cats -- TO DO: insert check?
local catslist "`catslist' `temppreX'"
local isAxA "no"
foreach var2 of local allnames {
if "`temppostX'"=="`var2'" | "`temppostX'"=="`base'" {
local isAxA "yes"
local aXalist "`aXalist' `var'"
}
}
* is it an alternativeXalternative interaction?
if "`isAxA'" == "no" {
local aXclist "`aXclist' `var'"
local csvlist "`csvlist' `temppostX'"
}
}
}
* if cat is specified, that is the list of categories
if "`cat'"!= "" {
local catslist = "`cat'"
}
* make sure either cat() or interactions specified
if "`cat'"=="" & "`anyX'"=="no" {
di as err "cat() must be specified if no interactions in model"
error 999
}
local catslist : list uniq catslist
local ncatsmin1 : word count `catslist'
local numcats = `ncatsmin1' + 1
local csvlist : list uniq csvlist
local asvlist : list allnames - aXclist
local asvlist : list asvlist - catslist
local asvlist : list asvlist - aXalist
/*
di "altXasv interactions: `aXalist'"
di "altXcase interactions: `aXclist'"
di "alternatives: `catslist'"
di "altspec vars: `asvlist'"
di "casespec vars: `csvlist'"
di "number of alternatives `ncatsmin1'"
*/
* decode x() values
tokenize `x', parse("()")
local x "`3'"
local x : subinstr local x "=" " ", all
tokenize `x', parse(" ")
while "`1'" != "" & "`2'" != "" {
capture confirm number `3'
if _rc == 0 {
* TO DO: check that `1' is alternative-specific variables
forvalues i = 1(1)`numcats' {
local iplus1 = `i' + 1
confirm number ``iplus1''
local V`1'V`i' = ``iplus1''
}
macro shift `iplus1'
}
else {
local V`1' = `2'
macro shift 2
}
}
* HANDLE REST OPTION
* rest() = mean by default
if "`rest'" == "" {
local rest "mean"
}
*check that rest option includes an allowable option
if "`rest'" != "mean" & "`rest'" != "asmean" {
di as err "rest(`rest') not allowed"
error 999
}
foreach var of local csvlist {
if "`V`var''" == "" {
if "`rest'" == "mean" | "`rest'" == "asmean" {
* qui su `var' if e(sample) == 1 & `recordnum' == 1
qui su `var' if e(sample) == 1 // FIX TO MEAN CALCULATION 9/2012
local V`var' = r(mean)
}
}
}
foreach var of local asvlist {
if "`V`var''" == "" & "`V`var'V1'" == "" {
if "`rest'" == "mean" {
* qui su `var' if e(sample) == 1 & `recordnum' == 1
qui su `var' if e(sample) == 1 // FIX TO MEAN CALCULATION 9/2012
forvalues i = 1(1)`numcats' {
local V`var'V`i' = r(mean)
}
}
if "`rest'" == "asmean" {
tempname refdum
* this variable will equal 1 for only those cases that indicate base
qui gen `refdum' = 1 if e(sample) == 1
local i = 1
foreach catname of local catslist {
qui su `var' if `catname' == 1 & e(sample) == 1
local V`var'V`i' = r(mean)
* turn off refdum for variables indicating category
qui replace `refdum' = 0 if `catname' == 1 & e(sample) == 1
local i = `i' + 1
}
* use refdum to get mean for reference category
qui su `var' if `refdum' == 1 & e(sample) == 1
local V`var'V`i' = r(mean)
}
}
}
* add observations to bottom of dataset
local N = _N
local firstobs = `N' + 1 // firstobs is the reference number of the first added obs
local lastobs = `firstobs'+`ncatsmin1'
qui set obs `lastobs'
capture drop _addedobs
qui gen _addedobs = 1 if _n >= `firstobs'
* find unique value for new observations
local unique "no"
local i = 1234567
while "`unique'" == "no" {
qui count if `idvar' == `i'
if r(N) == 0 {
local unique "yes"
}
local i = `i' + 1234567
}
qui replace `idvar' = `i' in `firstobs'/`lastobs'
qui replace `idvar' = `i' in `firstobs'/`lastobs'
foreach cat of local catslist {
local obs = `firstobs'
foreach cat2 of local catslist {
* set dummy variables indicating which row is which alternative
qui replace `cat' = 1 in `obs' if "`cat'" == "`cat2'"
qui replace `cat' = 0 in `obs' if "`cat'" != "`cat2'"
* set values for aXc interactions
foreach csvar of local csvlist {
qui replace `cat'X`csvar' = `V`csvar'' in `obs' if "`cat'" == "`cat2'"
qui replace `cat'X`csvar' = 0 in `obs' if "`cat'" != "`cat2'"
}
local obs = `obs' + 1
}
* set all alternative dummies to zero for row indicating reference category
qui replace `cat' = 0 in `obs'
* set all aXc to zero for row corresponding to reference category
foreach csvar of local csvlist {
qui replace `cat'X`csvar' = 0 in `obs'
}
}
* set values for alternative-specific variables
foreach alt of local asvlist {
if "`V`alt''" != "" {
qui replace `alt' = `V`alt'' in `firstobs'/`lastobs'
}
else {
forvalues i = 1(1)`numcats' {
local obs = `firstobs' + `i' - 1
qui replace `alt' = `V`alt'V`i'' in `obs'
}
}
}
* set values for aXa interactions
foreach var of local aXalist {
local i = index("`var'", "X")
local temppreX = substr("`var'", 1, `i'-1)
local temppostX = substr("`var'", `i'+1, .)
qui replace `var' = `temppreX'*`temppostX' if _addedobs == 1
}
* generate predicted probabilities
tempname prob
* 5/26/06 WORKAROUND FOR STATA BUG (?!) WHERE PREDICT RESORTS DATA
tempname order
gen `order' = _n
qui predict `prob' if _addedobs == 1
sort `order'
* reference category name
if "`base'" == "" {
local base = "base"
}
* DISPLAY RESULTS
* heading
local ecmd "`e(cmd)'"
local edepvar "`e(depvar)'"
di _n as res "`ecmd'" as txt ": Predictions for " as res "`edepvar'"
* display predicted probabilities
local obs = `firstobs'
capture mat drop asprvres
tempname tmpprob
foreach cat of local catslist {
sca `tmpprob' = `prob'[`obs']
mat asprvres = (nullmat(asprvres) \ `tmpprob')
local obs = `obs' + 1
}
sca `tmpprob' = `prob'[`obs']
mat asprvres = (nullmat(asprvres) \ `tmpprob')
mat rownames asprvres = `catslist' `base'
mat colnames asprvres = prob
if "`diff'" != "" {
mat changesav = asprvres - _ASPRVsav
tempname display
mat `display' = (asprvres, _ASPRVsav, changesav)
mat colnames `display' = Current Saved Diff
mat list `display', noh
}
else {
mat list asprvres, noh
}
* display base values for case-specific variables
if "`csvlist'" != "" {
capture mat drop csvals
foreach var of local csvlist {
mat csvals = (nullmat(csvals) , `V`var'')
}
mat colnames csvals = `csvlist'
mat rownames csvals = x=
if "`brief'" == "" {
di _n as txt "case-specific variables"
if "`diff'" != "" {
mat changecsv = csvals - _ASPRVcsv
tempname displaycsv
mat `displaycsv' = (csvals \ _ASPRVcsv \ changecsv)
mat rownames `displaycsv' = Current Saved Diff
mat list `displaycsv', noh
}
else {
mat list csvals, noh
}
}
}
* display base values for alternative-specific variables
if "`asvlist'" != "" {
capture mat drop asvals
foreach alt of local asvlist {
capture mat drop _tmp
if "`V`alt''" != "" {
mat _tmp = J(1, `numcats', `V`alt'')
}
else {
forvalues i = 1(1)`numcats' {
mat _tmp = (nullmat(_tmp) , `V`alt'V`i'')
}
}
mat asvals = (nullmat(asvals) \ _tmp)
}
mat rownames asvals = `asvlist'
mat colnames asvals = `catslist' `base'
if "`brief'" == "" {
di _n as txt "alternative-specific variables"
if "`diff'" != "" {
tempname curasv
mat `curasv' = asvals
tempname savedasv
mat `savedasv' = _ASPRVasv
mat changeasv = asvals - `savedasv'
mat roweq `curasv' = Current
mat roweq `savedasv' = Saved
mat roweq changeasv = Dif
tempname displayasv
mat `displayasv' = (`curasv' \ `savedasv' \ changeasv)
mat list `displayasv', noh
}
else {
mat list asvals, noh
}
}
}
* display all added observations and values if desired
if "`full'" != "" {
list `allnames' if _addedobs == 1, noobs
}
if "`save'" != "" {
mat _ASPRVsav = asprvres
if "`csvlist'" != "" {
mat _ASPRVcsv = csvals
}
if "`asvlist'" != "" {
mat _ASPRVasv = asvals
}
}
* return results
if "`diff'" != "" { //! added bj 24jul2008
capture return matrix p = changesav, copy //!
capture return matrix csv = changecsv, copy //!
capture return matrix asv = changeasv, copy //!
} //!
else { //!
capture return matrix p = asprvres, copy
capture return matrix csv = csvals, copy
capture return matrix asv = asvals, copy
} //!
restore
end
program define _Prvasmp, rclass
version 9
preserve
syntax [, x(passthru) Cat(string) Base(string) Save Diff Rest(string) BRief Full]
if "`cat'" != "" {
di as err "(note: cat() ignored when using asprvalue with asmprobit)"
}
if "`base'" != "" {
di as err "(note: base() ignored when using asprvalue with asmprobit)"
}
local altvar = e(altvar)
local numcats = e(k_alt)
local asvlist "`e(indvars)'"
local csvlist "`e(ind2vars)'"
if "`csvlist'" == "" {
local csvlist "`e(casevars)'"
}
local idvar "`e(casevar)'"
if "`idvar'" == "" {
local idvar "`e(case)'"
}
* need to sort to calculate means below so accurate for unbalanced panels
tempname recordnum
sort `idvar', stable
by `idvar' : gen `recordnum' = _n
* add values to bottom of dataset
local N = _N
local firstobs = `N' + 1
local lastobs = `firstobs' + `numcats' - 1
qui set obs `lastobs'
capture drop _addedobs
qui gen _addedobs = 1 if _n >= `firstobs'
* find unique value for new observations
local unique "no"
local i = 1234567
while "`unique'" == "no" {
qui count if `idvar' == `i'
if r(N) == 0 {
local unique "yes"
}
local i = `i' + 1234567
}
qui replace `idvar' = `i' in `firstobs'/`lastobs'
* write values for alternative variable with values of alternatives
_pecats `altvar' if e(sample)
local catvals "`r(catvals)'"
forvalues i = 1(1)`numcats' {
local cat`i' : word `i' of `catvals'
local catslist "`catslist' `e(alt`i')'"
local obsnum = `firstobs' + `i' - 1
qui replace `altvar' = `cat`i'' in `obsnum'
}
* decode x() values
tokenize `x', parse("()")
local x "`3'"
local x : subinstr local x "=" " ", all
tokenize `x', parse(" ")
while "`1'" != "" & "`2'" != "" {
* if `3' exists and is a number, alternative-specific variables being specified
capture confirm number `3'
if _rc == 0 {
* TO DO: check that `1' is alternative-specific variable
forvalues i = 1(1)`numcats' {
local iplus1 = `i' + 1
confirm number ``iplus1''
local V`1'V`i' = ``iplus1''
}
macro shift `iplus1'
}
else {
local V`1' = `2'
macro shift 2
}
}
* HANDLE REST OPTION
* rest() = mean by default
if "`rest'" == "" {
local rest "mean"
}
*check that rest option includes an allowable option
if "`rest'" != "mean" & "`rest'" != "asmean" {
di as err "rest(`rest') not allowed"
error 999
}
foreach var of local csvlist {
if "`V`var''" == "" {
if "`rest'" == "mean" | "`rest'" == "asmean" {
* qui su `var' if e(sample) == 1 & `recordnum' == 1
qui su `var' if e(sample) == 1 // FIX TO MEAN CALCULATION 9/2012
local V`var' = r(mean)
}
}
}
foreach var of local asvlist {
if "`V`var''" == "" & "`V`var'V1'" == "" {
if "`rest'" == "mean" {
* qui su `var' if e(sample) == 1 & `recordnum' == 1
qui su `var' if e(sample) == 1 // FIX TO MEAN CALCULATION 9/2012
forvalues i = 1(1)`numcats' {
local V`var'V`i' = r(mean)
}
}
if "`rest'" == "asmean" {
forvalues i = 1(1)`numcats' {
qui su `var' if `altvar' == `cat`i'' & e(sample) == 1
local V`var'V`i' = r(mean)
}
}
}
}
* set values for alternative-specific variables
foreach alt of local asvlist {
if "`V`alt''" != "" {
qui replace `alt' = `V`alt'' in `firstobs'/`lastobs'
}
else {
forvalues i = 1(1)`numcats' {
local obs = `firstobs' + `i' - 1
qui replace `alt' = `V`alt'V`i'' in `obs'
}
}
}
* set values for case-specific variables
foreach var of local csvlist {
qui replace `var' = `V`var'' in `firstobs'/`lastobs'
}
* generate predicted probabilities
tempname prob
** 5/26/06 WORKAROUND FOR STATA BUG (?!) WHERE PREDICT RESORTS DATA
tempname order
gen `order' = _n
* 2008-06-15 list `order' if _addedobs == 1
qui predict `prob' if _addedobs == 1
sort `order'
* DISPLAY RESULTS -- whole routine almost the same as asprvalue but not quite
* heading
local ecmd "`e(cmd)'"
local edepvar "`e(depvar)'"
di _n as res "`ecmd'" as txt ": Predictions for " as res "`edepvar'"
* display predicted probabilities
local obs = `firstobs'
capture mat drop asprvres
tempname tmpprob
foreach cat of local catslist {
sca `tmpprob' = `prob'[`obs']
mat asprvres = (nullmat(asprvres) \ `tmpprob')
local obs = `obs' + 1
}
mat rownames asprvres = `catslist'
mat colnames asprvres = prob
if "`diff'" != "" {
mat changesav = asprvres - _ASPRVsav
tempname display
mat `display' = (asprvres, _ASPRVsav, changesav)
mat colnames `display' = Current Saved Diff
mat list `display', noh
}
else {
mat list asprvres, noh
}
* display base values for case-specific variables
if "`csvlist'" != "" {
capture mat drop csvals
foreach var of local csvlist {
mat csvals = (nullmat(csvals) , `V`var'')
}
mat colnames csvals = `csvlist'
mat rownames csvals = x=
if "`brief'" == "" {
di _n as txt "case-specific variables"
if "`diff'" != "" {
mat changecsv = csvals - _ASPRVcsv
tempname displaycsv
mat `displaycsv' = (csvals \ _ASPRVcsv \ changecsv)
mat rownames `displaycsv' = Current Saved Diff
mat list `displaycsv', noh
}
else {
mat list csvals, noh
}
}
}
* display base values for alternative-specific variables
if "`asvlist'" != "" {
capture mat drop asvals
foreach alt of local asvlist {
capture mat drop _tmp
if "`V`alt''" != "" {
mat _tmp = J(1, `numcats', `V`alt'')
}
else {
forvalues i = 1(1)`numcats' {
mat _tmp = (nullmat(_tmp) , `V`alt'V`i'')
}
}
mat asvals = (nullmat(asvals) \ _tmp)
}
mat rownames asvals = `asvlist'
mat colnames asvals = `catslist'
if "`brief'" == "" {
di _n as txt "alternative-specific variables"
if "`diff'" != "" {
tempname curasv
mat `curasv' = asvals
tempname savedasv
mat `savedasv' = _ASPRVasv
mat changeasv = asvals - `savedasv'
mat roweq `curasv' = Current
mat roweq `savedasv' = Saved
mat roweq changeasv = Dif
tempname displayasv
mat `displayasv' = (`curasv' \ `savedasv' \ changeasv)
mat list `displayasv', noh
}
else {
mat list asvals, noh
}
}
}
* display all added observations and values if desired
if "`full'" != "" {
list `allnames' if _addedobs == 1, noobs
}
if "`save'" != "" {
mat _ASPRVsav = asprvres
if "`csvlist'" != "" {
mat _ASPRVcsv = csvals
}
if "`asvlist'" != "" {
mat _ASPRVasv = asvals
}
}
* return results
capture return matrix p = asprvres, copy
capture return matrix csv = csvals, copy
capture return matrix asv = asvals, copy
restore
end
exit
* 0.2.0 - jf - 5/26/06 - workaround for bug in Stata where predict resorts
* 0.1.9 - jf - 12/19/05 - add returns
* 0.1.8 - jf - 9/8/05 - warning but not error with cat() or base() with asmprobit
* 0.1.7 - jf - 7/24/05 - fix asmean for asmprobit bug
* 0.1.6 - jf - 7/19/05 - add heading to output
* 0.1.5 - jf - 7/18/05 - bug fix
* 0.1.4 - jf - 7/15/05 - add asmprobit (kludgy) - jf
* 0.1.3 - jf - 7/15/05 - fix to allow = in x()
* 0.1.2 - jf - 7/11/05 - bug fix
* 0.1.1 - jf - 6/15/05 - change refcat() to base()
* 0.1.0 - jf - 6/11/05
* 0.2.1 - jf - 7/2/07 - fix for changes in stata 7 asmprobit routine
* 0.3.0a - bj 24jul2008 for work with estout
* 0.3.0 2008-06-15 jsl
* 0.3.1 2009-03-14

View File

@ -1,122 +0,0 @@
{smcl}
{* 03Nov2005}{...}
{hline}
help for {hi:asprvalue}{right:03Nov2005}
{hline}
{title:Predicted probabilities for models with alternative-specific variables}
{p 8 15 2}{cmd:asprvalue} [{cmd:,}
{cmd:x(}{it:variables_and_values}{cmd:)}
{cmdab:r:est(}{it:stat}{cmd:)}
{cmdab:b:ase(}{it:refcatname}{cmd:)}
{cmdab:c:at(}{it:catnames}{cmd:)}
{cmdab:s:ave}
{cmdab:d:iff}
{cmdab:br:ief}
{p 4 4 2}
where {it:variables_and_values} is an alternating list of variables
and numeric values
{p 4 4 2}
{it:stat} is either mean or asmean (alternative-specific means for alternative-specific variables)
{p 4 4 2}
{cmd:asprvalue} is intended to be used to compute predicted probabilities for logit or probit models
that can combine case- and alternative-specific variables. For these models, predicted probabilities
depend on the values of the independent variables, which may or may not vary over the alternatives for
a particular case. {cmd:asprvalue} allows you to specify the values of the independent variables and
presents predicted probabilities for the different alternatives. The command presently works after
{helpb clogit}, {helpb rologit}, or {helpb asmprobit}.
{p 4 4 2}
{cmd:IMPORTANT:} For {helpb clogit} and {helpb rologit} models, case-specific variables are specified
by a set of interactions with dummy variables for the alternatives. {cmd:asprvalue} can only be used
if these interaction variables are named {it:alternative_name}X{it:case_specific_varname}. In other
words, if the dummy variables for the alternatives are named "car" and "bus" and a case-specific
variable is "male", the interactions must be named "carXmale" and "busXmale". These names for the
interactions correspond with the names used if the data have been arranged for estimation using
the command {cmd:case2choice}. A capital "X" cannot be used in the names of any of the other
variables in the model.
{title:Options}
{p 4 8 2}
{cmd:save} saves current values of indepenent variables and predictions
for computing changes using the diff option.
{p 4 8 2}
{cmd:diff} computes difference between current predictions and those
that were saved.
{p 4 8 2}
{cmd:x()} sets the values of independent variables for calculating
predicted values. For case-specific variables, the list must alternate
variable names and values. For alternative-specific variables, the list
may either be followed by a single value to be assigned to all alternatives
or J values if there are J alternatives. For {helpb clogit} or {helpb rologit}
, when J values are specified, these
are assigned to the alternatives in the order they have been specified by
{cmd:cat()} or in the estimation command, with the value to be assigned to the
reference category being last. For {helpb asmprobit}, the different alternatives are specified
using a single variable rather than a series of dummy variables, and values for
alternative-specific variables should be ordered to correspond with the ascending
values of the variable.
{p 4 8 2}
{cmd:rest()} sets the values for variables unspecified in {cmd:x()}. The default
is {it:mean}, which holds all unspecified variables to their case-specific means.
One can also specific "asmean", which holds unspecified alternative-specific
variables to their alternative-specific means. For example, if "time" was an
alternative-specific variable, {it:mean} would assign all alternatives the
mean of "time" over all individuals and alternatives, while {it:asmean} would assign
each alternative the mean of "time" for that alternative.
{p 4 8 2}
{cmd:base()} specifies the name of the base (reference) category. If this is not
specified, "base" will be used to refer to this category in the output. This option
should not be used after {helpb asmprobit}.
{p 4 8 2}
{cmd:cat()} specifies the names of the dummy variables in the model used to
indicate different alternatives (the alternative-specific intercepts). {cmd:cat()} only
needs to be specified if the model includes no case-specific variables, as otherwise
this list is inferred from the names of the interaction terms for case-specific
variables. The name of the reference category should not be included in {cmd:cat()}. This option
should not be used after {helpb asmprobit}.
{p 4 8 2}
{cmd:brief} prints only limited output.
{title:Examples}
{p 4 4 2}
{cmd:. use "http://www.stata-press.com/data/lfr/nomocc2.dta", clear}{break}
{cmd:. gen busXhinc = bus*hinc}{break}
{cmd:. gen trainXhinc = train*hinc}{break}
{cmd:. gen busXpsize = bus*psize}{break}
{cmd:. gen trainXpsize = train*psize}{break}
{cmd:. clogit choice train* bus* time invc , group(id)}{break}
{cmd:. asprvalue, x(time 600 invc 30 hinc 40 psize 0) base(car)}{break}
{p 4 4 2}
{cmd:. asprvalue, x(psize 0) base(car) save}{break}
{cmd:. asprvalue, x(psize 1) base(car) dif}{break}
{p 4 4 2}
{cmd:. asprvalue, x(psize 0) base(car) rest(asmean) save}{break}
{cmd:. asprvalue, x(psize 1) base(car) rest(asmean) dif}{break}
{p 4 4 2}
{cmd:. asprvalue, x(time 600 hinc 40 psize 1) base(car) save}{break}
{cmd:. asprvalue, x(time 700 600 600 hinc 40 psize 1) base(car) dif}{break}
{cmd:. asprvalue, x(time 600 700 600 hinc 40 psize 1) base(car) dif}{break}
{cmd:. asprvalue, x(time 600 600 700 hinc 40 psize 1) base(car) dif}{break}
{title:Authors}
Jeremy Freese and J. Scott Long
{browse www.indiana.edu/~jslsoc/spost.htm}
spostsup@indiana.edu