Skip to content
Prev 366030 / 398502 Next

Log plus one transformation in R

David,
 
I did read the help page. All it says is
log1p(x) computes log(1+x) accurately also for |x| << 1 (and less
accurately when x is approximately -1). 
This gives me pause. Does it mean that log(x) does not give accurate
results? If log1p gives more accurate values than log, why is the log
function not written to use the more accurate computation performed by
log1p. I don't believe I can look directly at the code for log and
log1p, so I need to rely on the kindness of others to explain the
differences between the computations performed by the functions. I guess
the test I ran, log1p(0.000001)/log(0.000001+1), did not have enough
precision to demonstrate a difference between the two functions.
John



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
wrote:
Read the help page more carefully.