[Rd] infelicity in dlnorm, plnorm

Spencer Graves spencer.graves at structuremonitoring.com
Wed Jun 11 07:02:53 CEST 2014


In theory, dlnorm(x, ...) == dnorm(log(x), ...)/x, x>0.


Unfortunately, when sd=0, dlnorm and plnorm return NaN, while dnorm 
returns (if(x != mean)0 else Inf) and pnorm returns (if(x<mean)0 else 
1). [A numerical optimization, maxLik{maxLik}, reported the NaNs for me.]


help('dlnorm') says, "dlnorm is calculated from the definition (in 
‘Details’). [pqr]lnorm are based on the relationship to the normal." 
This seems not completely accurate, because plnorm(2, 1, 0) returns NaN, 
while pnorm(log(2), 1, 0) returns 0.


Obviously, this is not very important. However, I felt a need to report it.


Thanks for all you do to make R the great product it is.


Spencer Graves


 > dlnorm(2, 1, 0)
[1] NaN
Warning message:
In dlnorm(2, 1, 0) : NaNs produced
 > dnorm(log(2), 1, 0)/2
[1] 0
 >
 > dlnorm(2, 1, 1)
[1] 0.1902978
 > dnorm(log(2), 1, 1)/2
[1] 0.1902978
 >
 > dlnorm(exp(1), 1, 0)
[1] NaN
Warning message:
In dlnorm(exp(1), 1, 0) : NaNs produced
 > dnorm(1, 1, 0)/exp(1)
[1] Inf
 >
 > sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base



More information about the R-devel mailing list