0

I have a list of fitdist objects, which I have stored using this piece of code.

norm_dist_res <- list()
for(i in 1:10)
{
  x <- 1+(8000*(i-1))
  y <- 8000*i
  print (x)
  print(y)
  norm_dist_res[[i]] = norm_dist_res[[i]] <- fitdist(data=as.vector(g_all_p$data[x:y,]), distr="norm")

}

Is there a way to plot all the normal distributions extracted from fittest with a different color to show how the data is distributed?

Or in general how to visualize multiple normal distributions?

lmo
  • 37,904
  • 9
  • 56
  • 69
Lamda
  • 914
  • 3
  • 13
  • 39
  • What is the content of a `fitdist` object? This function is not part of base R. – lmo Apr 19 '16 at 11:51

1 Answers1

1

You are estimating the parameters of a normal distribution, so just plot the densities.

## Don't no what g_all_p is, so simplifying the data
library(fitdistrplus)
norm_dist_res <- list()
for(i in 1:10)
{
  norm_dist_res[[i]] = norm_dist_res[[i]] <- fitdist(data=rnorm(10), distr="norm")

}

Then just plot using lines and changing the colour

x = seq(-5, 5, length.out=100)
plot(x, type="n", ylim=c(0, 1), xlim=range(x))
for(i in 1:10) {
  est = norm_dist_res[[i]]$estimate
  lines(x, dnorm(x, est[1], est[2]), col="grey90")
}

To get

enter image description here

csgillespie
  • 59,189
  • 14
  • 150
  • 185