Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: significant digits format


From   Roy Wada <[email protected]>
To   [email protected]
Subject   Re: st: significant digits format
Date   Mon, 11 Jan 2010 20:31:46 -0800

And pray tell me what exactly is "inspired" here? I take people at
their word and do not have a habit of looking through their program.

"inspired" is supposed to mean you got the general idea and did your
own writing. This is what I was led to believe. But that is not the
case here. There is nothing "inspired" about copying and transplanting
other people's codes. See below.

If that person went back and recently rewrote them, that's called
paraphrasing. See the previous post.

Mistakes can be made and people forget things, but it becomes a
serious issue when someone with a reputation for knocking off other
people's programs continue to distribute such work without full and
proper acknowldgements of the source.

Open source means you may use them and learn from them. It doesn't
mean you can cherry pick other people's work and ideas and present
them as your own work. Public domain does not mean you may republish
them under your name.

Once is bad enough, but for the same person to do it again is beyond pale.

Roy



*! version 2.65, Ben Jann, 29may2007

program SignificantDigits // idea stolen from outreg2.ado
        args fmt value
        local d = substr("`fmt'", 2, .)
        capt confirm integer number `d'
        if _rc {
                di as err `"`fmt' not allowed"'
                exit 198
        }
// missing: format does not matter
        if `value'>=. local fmt "%9.0g"
// integer: print no decimal places
        else if (`value'-int(`value'))==0 {
                local fmt "%12.0f"
        }
// value in (-1,1): display up to 9 decimal places with d significant
// digits, then switch to e-format with d-1 decimal places
        else if abs(`value')<1 {
                local right = -int(log10(abs(`value'-int(`value'))))
// zeros after dp
                local dec = max(1,`d' + `right')
                if `dec'<=9 {
                        local fmt "%12.`dec'f"
                }
                else {
                        local fmt "%12.`=min(9,`d'-1)'e"
                }
        }
// |values|>=1: display d+1 significant digits or more with at least one
// decimal place and up to nine digits before the decimal point, then
// switch to e-format
        else {
                local left = int(log10(abs(`value'))+1) // digits before dp
                if `left'<=9 {
                        local fmt "%12.`=max(1,`d' - `left' + 1)'f"
                }
                else {
                        local fmt "%12.0e" // alternatively:
"%12.`=min(9,`d'-1)'e"
                }
        }
        c_local fmt "`fmt'"
end



*! November 2005
*! by [email protected]
*
* (based on -outreg- by [email protected], versions
3.0.6 and 4.0.0)

program define autodigits2, rclass
version 8.2
* getting the significant digits
args input auto less

if `input'~=. {
	local times=0
	local left=0

	* integer checked by modified mod function
	if round((`input' - int(`input')),0.0000000001)==0 {
		local whole=1
	}
	else {
		local whole=0
		* non-interger
		 if `input'<. {
			
			* digits that need to be moved if it were only decimals: take the
ceiling of log 10 of absolute value of decimals
			local times=abs(int(ln(abs(`input'-int(`input')))/ln(10)-1))	
			
			* the whole number: take the ceiling of log 10 of absolute value
			local left=int(ln(abs(`input'))/ln(10)+1)
		}
	}
	
	
	* assign the fixed decimal values into aadec
	if `whole'==1 {
		local aadec=0
	}
	else if .>`left' & `left'>0 {
		* reduce the left by one if more than zero to accept one extra digit
		if `left'<=`auto' {
			local aadec=`auto'-`left'+1
		}
		else {
			local aadec=0
		}
	}
	else {
		local aadec=`times'+`auto'-1
	}

	if "`less'"=="" {
		* needs to between 0 and 11
		if `aadec'<0 {
			local aadec=0
		}
		if `aadec'<11 {
			* use fixed
			local valstr "`aadec'f"
		}
		else {
			* use exponential
			local valstr "`=`auto'-1'e"
		}
	}
	else {
		* needs to between 0 and 11
		local aadec=`aadec'-`less'
		if `aadec'<0 {
			local aadec=0
		}
		if `aadec'<10 {
			* use fixed
			local valstr "`aadec'f"
		}
		else {
			* use exponential
			local valstr "`=`auto'-1'e"
		}
	}

	return scalar value=`aadec'
	return local valstr="`valstr'"
}
else {
	* it is a missing value
	return scalar value=.
	return local valstr="missing"
}
end



On Mon, Jan 11, 2010 at 4:42 PM, Roy Wada <[email protected]> wrote:
>> A google search brings up -esttab-, which evidently creates nice
>> tables of output from regression models. I had in mind however a more general tool.
>
> What you seek has been distributed as -autofmt- from ssc.
>
> There is no problem with programs gettting "inspired." However, there
> is a problem when someone distributes such work without explicitly
> saying so in the help file. Had such references made available, Jacob
> may have discovered -outreg2- and possibly led to -autofmt-.
>
> -esttab- is a work largely based on the functionality of -outreg2-.
> The fact that this disclaimer has not been distributed with the
> program is a discredit to the author of -esttab-.
>
> Roy
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index