Re: [R] Plot histogram and lognormal fit on the same time

2021-01-22 Thread Bert Gunter
OK, but that's not the point of my comment. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Jan 22, 2021 at 5:03 PM Abby Spurdle wrote: > Sorry, Bert. >

Re: [R] Plot histogram and lognormal fit on the same time

2021-01-22 Thread Abby Spurdle
Sorry, Bert. The fitdistr function estimates parameters via maximum likelihood. (i.e. The "lognormal" part of this, is not a kernel). On Fri, Jan 22, 2021 at 5:14 AM Bert Gunter wrote: > > In future, you should try to search before posting. I realize that getting > good search terms can sometime

Re: [R] Plot histogram and lognormal fit on the same time

2021-01-21 Thread Rui Barradas
Hello, A solution based on Marc's first one, maybe easier? (It doesn't rely on multiplying the dlnorm values by 400 since it plots the histogram with freq = FALSE.) set.seed(2020) data <- rlnorm(100, meanlog = 1, sdlog = 1) library(MASS) f <- fitdistr(data, "lognormal") f$estimate p <- pr

Re: [R] Plot histogram and lognormal fit on the same time

2021-01-21 Thread Bert Gunter
In future, you should try to search before posting. I realize that getting good search terms can sometimes be tricky, but not in this case: 'plot density with histogram in R' or similar on rseek.org or just on your usual search platform brought up several ways to do it. As a (slightly offtopic) si

Re: [R] Plot histogram and lognormal fit on the same time

2021-01-21 Thread Marc Girondot via R-help
Two solutions not exactly equivalent ; data <- rlnorm(100, meanlog = 1, sdlog = 1) histdata <- hist(data, ylim=c(0, 100)) library(MASS) f <- fitdistr(data, "lognormal") f$estimate lines(x=seq(from=0, to=50, by=0.1), � y=dlnorm(x=seq(from=0, to=50, by=0.1), meanlog = f$estimate["meanlog"], sdl

[R] Plot histogram and lognormal fit on the same time

2021-01-21 Thread Eric Leroy
Hi, I would like to plot the histogram of data and fit it with a lognormal distribution. The ideal, would be to superimpose the fit on the histogram and write the results of the fit on the figure. Right now, I was able to plot the histogram and fit the density with a lognormal, but I can't