Steve_Friedman at nps.gov
2011-Nov-03 18:54 UTC
[R] Plotting skewed normal distribution with a bar plot
Hi, I need to create a plot (type = "h") and then overlay a skewed-normal curve on this distribution, but I'm not finding a procedure to accomplish this. I want to use the plot function here in order to control the bin distributions. I have explored the sn library and found the dsn function. dsn uses known location, scaling and shape parameters associated with a given input vector of probabilities. However, how can I calculate the skewed-normal curve if I don't know these parameters in advance? Is there another function to calculate the skew-normal, perhaps in a different package? I'm working with R 2.13.2 on a windows based machine. Steve Friedman Ph. D. Ecologist / Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 Steve_Friedman at nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147
R. Michael Weylandt
2011-Nov-04 02:39 UTC
[R] Plotting skewed normal distribution with a bar plot
It seems like you'll need to apply some sort of MLE to estimate the parameters directly from the data before using dsn() to get the density. This might help with some of it: http://help.rmetrics.org/fGarch/html/snorm.html Michael On Thu, Nov 3, 2011 at 2:54 PM, <Steve_Friedman at nps.gov> wrote:> > Hi, > > I need to create a plot (type = "h") ?and then overlay a skewed-normal > curve on this distribution, but I'm not finding a procedure to accomplish > this. I want to use the plot function here in order to control the bin > distributions. > > I have explored the sn library and found the dsn function. ?dsn uses known > location, scaling and shape parameters associated with a given input vector > of probabilities. ?However, how can I calculate the skewed-normal curve if > I don't know these parameters in advance? > > Is there another function to calculate the skew-normal, perhaps in a > different package? > > > I'm working with R 2.13.2 on a windows based machine. > > Steve Friedman Ph. D. > Ecologist ?/ Spatial Statistical Analyst > Everglades and Dry Tortugas National Park > 950 N Krome Ave (3rd Floor) > Homestead, Florida 33034 > > Steve_Friedman at nps.gov > Office (305) 224 - 4282 > Fax ? ? (305) 224 - 4147 > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
boylangc at earthlink.net
2011-Nov-04 12:41 UTC
[R] Plotting skewed normal distribution with a bar plot
Steve, I don't profess to be an expert in R (by ANY means), but I've used the sn.mle function in package sn to do something similar. So, for example, if you have data (y), you can do the following: y = c(5,4,6,4,5,6,7,7,55,64,23,13,1,4,1,14,1,15,11,12) sn.mle(y=y) I just made up this stream of data, so please forgive if it doesn't make sense. The function will produce a number of things, including the mles for the mean, sd, and skew, as well as a histogram with the density overlayed onto it. Maybe this helps? Hope so. Greg -----Original Message----->From: "R. Michael Weylandt" <michael.weylandt at gmail.com> >Sent: Nov 3, 2011 10:39 PM >To: Steve_Friedman at nps.gov >Cc: r-help at r-project.org >Subject: Re: [R] Plotting skewed normal distribution with a bar plot > >It seems like you'll need to apply some sort of MLE to estimate the >parameters directly from the data before using dsn() to get the >density. This might help with some of it: >http://help.rmetrics.org/fGarch/html/snorm.html > >Michael > >On Thu, Nov 3, 2011 at 2:54 PM, <Steve_Friedman at nps.gov> wrote: >> >> Hi, >> >> I need to create a plot (type = "h") ?and then overlay a skewed-normal >> curve on this distribution, but I'm not finding a procedure to accomplish >> this. I want to use the plot function here in order to control the bin >> distributions. >> >> I have explored the sn library and found the dsn function. ?dsn uses known >> location, scaling and shape parameters associated with a given input vector >> of probabilities. ?However, how can I calculate the skewed-normal curve if >> I don't know these parameters in advance? >> >> Is there another function to calculate the skew-normal, perhaps in a >> different package? >> >> >> I'm working with R 2.13.2 on a windows based machine. >> >> Steve Friedman Ph. D. >> Ecologist ?/ Spatial Statistical Analyst >> Everglades and Dry Tortugas National Park >> 950 N Krome Ave (3rd Floor) >> Homestead, Florida 33034 >> >> Steve_Friedman at nps.gov >> Office (305) 224 - 4282 >> Fax ? ? (305) 224 - 4147 >> >> ______________________________________________ >> R-help at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > >______________________________________________ >R-help at r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.
R. Michael Weylandt
2011-Nov-04 17:57 UTC
[R] Plotting skewed normal distribution with a bar plot
You might want to check again: I'm running fGarch on 2.13.2, Mac OSX 10.5.8. Michael On Fri, Nov 4, 2011 at 9:36 AM, Steve Friedman <skfglades at gmail.com> wrote:> Hi Michael, > > Thanks for pointing me fGarch.? I actually started there, but it is not yet > available for 2.13.2 so I went directly to the (sn-package). > > I've briefly explored your suggestion and think it will work. > > Thanks > Steve > > On Nov 3, 2011 10:41 PM, "R. Michael Weylandt" <michael.weylandt at gmail.com> > wrote: >> >> It seems like you'll need to apply some sort of MLE to estimate the >> parameters directly from the data before using dsn() to get the >> density. This might help with some of it: >> http://help.rmetrics.org/fGarch/html/snorm.html >> >> Michael >> >> On Thu, Nov 3, 2011 at 2:54 PM, ?<Steve_Friedman at nps.gov> wrote: >> > >> > Hi, >> > >> > I need to create a plot (type = "h") ?and then overlay a skewed-normal >> > curve on this distribution, but I'm not finding a procedure to >> > accomplish >> > this. I want to use the plot function here in order to control the bin >> > distributions. >> > >> > I have explored the sn library and found the dsn function. ?dsn uses >> > known >> > location, scaling and shape parameters associated with a given input >> > vector >> > of probabilities. ?However, how can I calculate the skewed-normal curve >> > if >> > I don't know these parameters in advance? >> > >> > Is there another function to calculate the skew-normal, perhaps in a >> > different package? >> > >> > >> > I'm working with R 2.13.2 on a windows based machine. >> > >> > Steve Friedman Ph. D. >> > Ecologist ?/ Spatial Statistical Analyst >> > Everglades and Dry Tortugas National Park >> > 950 N Krome Ave (3rd Floor) >> > Homestead, Florida 33034 >> > >> > Steve_Friedman at nps.gov >> > Office (305) 224 - 4282 >> > Fax ? ? (305) 224 - 4147 >> > >> > ______________________________________________ >> > R-help at r-project.org mailing list >> > https://stat.ethz.ch/mailman/listinfo/r-help >> > PLEASE do read the posting guide >> > http://www.R-project.org/posting-guide.html >> > and provide commented, minimal, self-contained, reproducible code. >> > >> >> ______________________________________________ >> R-help at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >