# [R] Plotting skewed normal distribution with a bar plot

Fri Nov 4 13:41:36 CET 2011

```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)
>>
>> 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