Suppose I have a random variable which I suspect is the product of a lognormally distributed random variable $X$ and an independent uniformly distributed variable $U(0, 1)$. (The variables are the total incomes of workers in a calendar year who started on a random day in that year. The logic is that workers' annual salary is lognormal but they start on a random day of the year)
I'm interested in estimating the parameters mu
and sigma
for the lognormal distribution.
x <- runif(10e3) * rlnorm(10e3, 9, 1)
If we assume $X \sim U(0, 1) \times \mathrm{LogNormal}(\mu, \sigma)$ then my understanding is $$\log(X) \sim -\mathrm{Exp}(1) + N(\mu, \sigma)$$
and that this is an exponentially-modified Gaussian distribution. However, when I estimate the parameters using fitdistr
, it seems to systematically underestimate mu
or fail to estimate for some other reason (for example trying to estimate beta
beyond the bounds).
set.seed(810)
library(MASS)
library(brms)
#> Loading required package: Rcpp
#> Registered S3 method overwritten by 'xts':
#> method from
#> as.zoo.xts zoo
#> Loading 'brms' package (version 2.10.0). Useful instructions
#> can be found by typing help('brms'). A more detailed introduction
#> to the package is available through vignette('brms_overview').
x <- runif(10e3) * rlnorm(10e3, 10, 1)
logx <- log(x)
fitdistr(logx,
dexgaussian,
start = list(mu = 7,
sigma = 1,
beta = 1),
lower = c(5, 0.9, 1/10e3),
upper = c(15, 1.1, Inf))
#> mu sigma beta
#> 9.00146956 1.10000000 0.68489168
#> (0.01295792) (0.01039890) (0.02761565)
Created on 2019-10-08 by the reprex package (v0.3.0)
How should I best try to estimate these parameters?