Displaying 20 results from an estimated 68 matches for "dlnorm".
Did you mean:
rlnorm
2002 Jul 12
1
Minor bug in dlnorm (PR#1781)
The density of a lognormal should be 0 for negative arguments, but
> dlnorm(-1)
[1] NaN
Warning message:
NaNs produced in: dlnorm(x, meanlog, sdlog, log)
A simple fix is to change dlnorm's definition to:
function (x, meanlog = 0, sdlog = 1, log = FALSE)
.Internal(dlnorm(x*(x>0), meanlog, sdlog, log))
It might be faster to put the same sort of adjustment into t...
2014 Jun 11
0
infelicity in dlnorm, plnorm
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, "dl...
2007 Oct 08
3
embedFonts rotates figure
Dear All,
Consider the following code:
pdf(file="figure.pdf",family="URWPalladio")
curve(dlnorm(x,0,1.5),0,10,xlim=c(0,10),ylim=c(0,0.85),axes=F,xlab="",ylab="f")
segments(exp(-1.5^2),0,exp(-1.5^2),dlnorm(exp(-1.5^2),0,1.5),lty="dashed")
segments(1,0,1,dlnorm(1,0,1.5),lty="dashed")
segments(exp(1.5^2),0,exp(1.5^2),dlnorm(exp(1.5^2),0,1.5),lty="dash...
2005 Jun 29
2
MLE with optim
Hello,
I tried to fit a lognormal distribution by using optim. But sadly the output
seems to be incorrect.
Who can tell me where the "bug" is?
test = rlnorm(100,5,3)
logL = function(parm, x,...) -sum(log(dlnorm(x,parm,...)))
start = list(meanlog=5, sdlog=3)
optim(start,logL,x=test)$par
Carsten.
[[alternative HTML version deleted]]
2017 Jul 05
0
bug with dlnorm
I've found some funny behavior in the dlnorm() function that I believe to be a bug. For example, the following command:
> dlnorm( c(5e-323, 5e-324, 5e-325), 0, 0.3 )
Produces the output below, including the NaN value that should (ideally would be) zero.
[1] 0 NaN 0
Warning message:
In dlnorm(c(4.94065645841247e-323, 4.94065645841247...
2011 Jan 02
1
How to compute the density of a variable that follows a proportional error distribution
...I am trying to compute the density of a variable k that is either (1)
Normally distributed; (2) Log-Normally distributed; or (3) follows
proportional error distribution. I tried to search R-help and the answer for
normal distribution was easy to find (please see 1c). I am not sure if my
formula for dlnorm is correct (please see 2c below)? I really don't know
what function to use for the density of k with a proportional error
distribution.
Please help,
Mahesh
1. Normal distribution:
*a) *k=qk+h, hÎN(0, w)
*b) *then kÎN(qk, w)
*c) *density of a variable k: dnorm(x,mean=qk,sd=w,l...
2005 Mar 12
1
MLE for two random variables
...n other source with left-truncation at threshold u (xu)
I have to fit a model on these these two sources, thereby I assume that both
are "drawn" from the same distribution (eg lognormal). In a MLE I would sum
the densities and maximize. The R-Function could be:
function(x,xu,u,mu,sigma)
dlnorm(x,mu,sigma)+(dlnorm(xu,mu,sigma)/(plnorm(u,mu,sigma)))
So I tried to use the function FITDISTR for the MLE. But unfortunately it
only accepts ONE random variable.
Then I tried to combine x and xu in a vector, but that doesn't work, too,
because the length of x and xu differs.
Does anybody has...
2012 May 22
4
Need to help to get value for bigger calculation
Hello R-Experts,
I want to calculate values like 15^200 or 17^300 in R. In normal case it can calculate the small values of b (a^b). I have fixed width = 10000 and digits = 22 but still answers are Inf.
How to deal the cases like these? Thanks in advance.
Regards,
rehena
[[alternative HTML version deleted]]
2000 Apr 04
1
Question about the proper use of outer()
...not have a clue with is the following NOT working like I expect to
do...
(and I cannot find any answer at CRAN)...
# This one is for my sample
> x _ seq(3,10)
# This two for parameters
> a _ seq(2,4)
> b _ seq(2,5)
# This one for the likelihood of a sample
>f _ function(a,b) {
+ prod(dlnorm(x,meanlog=a,sdlog=b))
+ }
> outer(a,b,f)
[,1] [,2] [,3] [,4]
[1,] 2.301348e-21 2.301348e-21 2.301348e-21 2.301348e-21
[2,] 2.301348e-21 2.301348e-21 2.301348e-21 2.301348e-21
[3,] 2.301348e-21 2.301348e-21 2.301348e-21 2.301348e-21
# interestingly, the foll...
2008 Aug 21
1
pnmath compilation failure; dylib issue?
...u99 -dynamiclib -Wl,-
headerpad_max_install_names -mmacosx-version-min=10.4 -undefined
dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/
lib -o pnmath.so bd0.o beta.o chebyshev.o choose.o d1mach.o dbeta.o
dbinom.o dcauchy.o dchisq.o dexp.o df.o dgamma.o dgeom.o dhyper.o
dlnorm.o dlogis.o dnbeta.o dnbinom.o dnchisq.o dnf.o dnorm.o dnt.o
dpois.o dt.o dunif.o dweibull.o fmax2.o fmin2.o ftrunc.o gamma.o
gamma_cody.o i1mach.o imax2.o imin2.o lbeta.o lgamma.o lgammacor.o
mlutils.o pbeta.o pbinom.o pcauchy.o pchisq.o pexp.o pf.o pgamma.o
pgeom.o phyper.o plnorm.o plogis...
2013 Mar 18
2
Fit a mixture of lognormal and normal distributions
Hello
I am trying to find an automated way of fitting a mixture of normal and log-normal distributions to data which is clearly bimodal.
Here's a simulated example:
x.1<-rnorm(6000, 2.4, 0.6)x.2<-rlnorm(10000, 1.3,0.1)X<-c(x.1, x.2)
hist(X,100,freq=FALSE, ylim=c(0,1.5))lines(density(x.1), lty=2, lwd=2)lines(density(x.2), lty=2, lwd=2)lines(density(X), lty=4)
Currently i am using
2008 Feb 18
0
Solved (??) Behaviour of integrate (was 'Poisson-lognormal probab ility calculations')
...#-
require(stats)
mapply(function(x, meanlog, sdlog, ...){
lower <- min(max(0, x-sdlim*sqrt(x)), exp(meanlog-sdlim*sdlog))
upper <- max(x+sdlim*sqrt(x), exp(meanlog+sdlim*sdlog))
integrate(function(t, x, meanlog, sdlog)
exp(dpois(x,t,TRUE) + dlnorm(t, meanlog, sdlog, TRUE)),
lower = lower, upper = upper, x = x, meanlog = meanlog, sdlog
= sdlog,
rel.tol = rel.tol, ...)$value
},
x, meanlog, sdlog, ...
)
}
----...
2008 Oct 23
0
If I known d1 (density1), and dmix is a mix between d1 and d2 (d2 is unknown), can one infer d2?
...they achieve a unit distance in another
distribution of longer times (d2), cf example below.
If I have a mixed sample that contain X% of fast walkers and (100-X)%
of slow walkers, *is it possible to use it to estimate d2, as well as
X?*
R example:
walk.fast = sample(seq(1,5,length.out=1000),
prob=dlnorm(seq(1,5,length.out=1000)), replace=T)
walk.slow = sample(seq(1,5,length.out=1000),
prob=dlnorm(seq(1,5,length.out=1000), meanlog=1.2), replace=T)
percentage.fast =0.8
walk.all = c(sample(walk.fast, percentage.fast*1000),
sample(walk.slow, (1-percentage.fast)*1000 ) )
plot(density(walk.fast, from=...
2010 Apr 28
0
Truncated Lognormal Distribution
...136.html)
library(MASS)
x <- c(600.62,153.05,70.26,530.42,3440.29,97.45,174.51,168.47, 116.63,36.51, 219.77, 231.67,110.62,173.11,202.85,689.27,23.82,234.15,625.89,192.88,29.53,109.99, 80.53, 46.85,82.69,231.53,75.38,217.52,85.29,182.18)
ltlnorm <- function(x, meanlog, sdlog, log=FALSE)
{
dlnorm(x, meanlog, sdlog, log = FALSE) / plnorm(1, meanlog, sdlog, lower.tail = TRUE, log.p = FALSE)
}
meanlog = mean(log(x))
sdlog = sd(log(x))
ltlnormfit <- fitdistr(x,ltlnorm, start=list(meanlog,sdlog))
I get following error -
Error in dlnorm(x, meanlog, sdlog, log = FALSE) : element 3 is empt...
2006 Aug 26
4
Can R compute the expected value of a random variable?
Dear All
Can R compute the expected value of a random variable?
Thanks in advance,
Paul
2005 Jan 31
2
ML-Fit for truncated distributions
Hello,
maybe that my Question is a "beginner"-Question, but up to now, my research
didn't bring any useful result.
I'm trying to fit a distribution (e.g. lognormal) to a given set of data
(ML-Estimation). I KNOW about my data that there is a truncation for all
data below a well known threshold. Is there an R-solution for an
ML-estimation for this kind of data-problem? As
2008 Feb 15
0
Behaviour of integrate (was 'Poisson-lognormal probability calcul ations')
...information to my own query, this function gets to the core
of the problem, which I think lies in the behaviour of 'integrate'.
-------------------------------------
function (x, meanlog = 0, sdlog = 1, ...) {
require(stats)
integrand <- function(t, x, meanlog, sdlog) dpois(x,t)*dlnorm(t,
meanlog, sdlog)
mapply(function(x, meanlog, sdlog, ...)
# (1/gamma(x+1))*
integrate(function(t, x, meanlog, sdlog)
# gamma(x+1)*
integrand(t, x, meanlog, sdlog),
lower = 0, upper = Inf, x = x, meanlog = meanlog, sdlog =
sd...
2008 Apr 26
1
integration error when I use "optim" and "integrate" simultaneously
Dear R users,
When I use two functions, 'optim' and 'integrate', simultaneously, I always
get an error like this
--------------------------------------------------------------------------
numint = function(z) {
dlnorm(z,mu[1],sqrt(exp(g[1]))) *
dnorm((z-mu[2])/sqrt(exp(g[2])))/sqrt(exp(g[2]))
}
integrate(numint,lower=0,upper=Inf)$value
Error in integrate(numint, lower = 0, upper = Inf) : non-finite function
value
-----------------------------------------------------------------------------
Dr. Ripley said fo...
2003 Apr 09
3
plotting the lognormal density curve
I am trying to plot a lognormal density curve on top of an existing
histogram. Can anybody suggest a simple way to do this? Even if someone
could just explain how to plot a regular normal density curve on top of an
existing histogram, it would be a big help.
Also, is there some way to search through the R-help archives other than
simple browsing?
Thank you so much. Your help and time is greatly
2010 Jan 04
1
log normal overlay
....70, 14.90, 6.12, 17.88, 13.72)
breaks<-c(0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44)
hist(app_depths,breaks,freq=FALSE,main="LARV Irrigation Application Depths
(in) 2004-2007",xlab="Application Depth (in)",col="grey")
plot(function(app_depths)
dlnorm(app_depths,meanlog=mean(app_depths),sdlog=sd(app_depths)),0,44,add=TRUE,col="black",lwd=3)
Problem is, I get a plot that doesn't look right,
http://n4.nabble.com/file/n998495/Image3.png
If there is an obvious error as to why the pdf line doesn't fit the data,
I'm unable t...