Re: [R] QQ plotting of various distributions...

2009-09-27 Thread Petar Milin
Thanks for the answer. Now, only problem is to to get parameter(s) of a 
given function. For gamma, I shall try with gammafit() from mhsmm 
package. Also, I shall look for others appropriate parameter estimates. 
Will use SuppDists too.


Best,
PM

Sunil Suchindran wrote:

#same shape

some_data - rgamma(500,shape=6,scale=2)
test_data - rgamma(500,shape=6,scale=2)
plot(sort(some_data),sort(test_data))
# You can also use qqplot(some_data,test_data)
abline(0,1)

# different shape

some_data - rgamma(500,shape=6,scale=2)
test_data - rgamma(500,shape=4,scale=2)
plot(sort(some_data),sort(test_data))
abline(0,1)

It is helpful to assess the sampling variability, by
creating repeated sets of test_data, and plotting
all of these along with your observations to create
a confidence envelope.

The SuppDists provides Inverse Gauss.


On Thu, Sep 17, 2009 at 11:46 AM, Petar Milin pmi...@ff.uns.ac.rs wrote:

Hello!
I am trying with this question again:
I would like to test few distributional assumptions for some
behavioral response data. There are few theories about true
distribution of those data, like: normal, lognormal, gamma,
ex-Gaussian (exponential-Gaussian), Wald (inverse Gaussian) etc. The
best way would be via qq-plot, to show to students differences.
First two are trivial:
qqnorm(dat$X)
qqnorm(log(dat$X))
Then, things are getting more hairy. I am not sure how to make
plots for the rest. I tried gamma with:
qqmath(~ X, data=dat, distribution=function(X)
� qgamma(X, shape, scale))
Which should be the same as:
plot(qgamma(ppoints(dat$X), shape, scale), sort(dat$X))
Shape and scale parameters I got via mhsmm package that has
gammafit() for shape and scale parameters estimation.
Am I on right track? Does anyone know how to plot the rest:
ex-Gaussian (exponential-Gaussian), Wald (inverse Gaussian)?

Thanks,
PM

__
R-help@r-project.org mailto:R-help@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
http://www.r-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




__
R-help@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.


Re: [R] QQ plotting of various distributions...

2009-09-27 Thread Eric Thompson
The supposed example of a Q-Q plot is most certainly not how to make a
Q-Q plot. I don't even know where to start

First off, the two Q:s in the title of the plot stand for quantile,
not random. The answer supplied simply plots two sorted samples of
a distribution against each other. While this may resemble the general
shape of a QQ plot, that is where the similarities end.

Some general advice: be careful who you take advice from on the
internet. The Wikipedia entry for Q-Q plot may be a good start if you
don't know what a Q-Q plot is, although you should also use it with
caution.

Lets say you have some samples that may be normally distributed:

set.seed(1)
x - rnorm(30)

# now try with R's built in function
qqnorm(x, xlim = c(-3, 3), ylim = c(-3, 3))

# Now try Sunil's Q-Q plot method, but for rnorm
# rather than rgamma
some_data - x
test_data - rnorm(30)
points(sort(some_data),sort(test_data), col = blue)

# Note that the points are NOT the same!

This should have been obvious for the simple reason that the QQ plot
should not be influenced by the random number generator that you are
using! A QQ plot is uniquely reproducible. The more general (and
correct) way to get the QQ plot involves choosing a plotting position
and the quantile function (e.g. qnorm or qgamma functions in R) of the
pertinent distribution:

# Sort the data:
x.s - sort(x)
n - length(x)

# Plotting position (must be careful here in general!)
p - ppoints(n)

# Compute the quantile
x.q - qnorm(p)

points(x.q, x.s, col = red)

# and they fall exactly on the points generated by qqnorm().

Now, you should be able to generalize this for any distribution. Hope
this helps.


Eric Thompson




2009/9/27 Petar Milin pmi...@ff.uns.ac.rs:
 Thanks for the answer. Now, only problem is to to get parameter(s) of a
 given function. For gamma, I shall try with gammafit() from mhsmm package.
 Also, I shall look for others appropriate parameter estimates. Will use
 SuppDists too.

 Best,
 PM

 Sunil Suchindran wrote:

 #same shape

 some_data - rgamma(500,shape=6,scale=2)
 test_data - rgamma(500,shape=6,scale=2)
 plot(sort(some_data),sort(test_data))
 # You can also use qqplot(some_data,test_data)
 abline(0,1)

 # different shape

 some_data - rgamma(500,shape=6,scale=2)
 test_data - rgamma(500,shape=4,scale=2)
 plot(sort(some_data),sort(test_data))
 abline(0,1)

 It is helpful to assess the sampling variability, by
 creating repeated sets of test_data, and plotting
 all of these along with your observations to create
 a confidence envelope.

 The SuppDists provides Inverse Gauss.


 On Thu, Sep 17, 2009 at 11:46 AM, Petar Milin pmi...@ff.uns.ac.rs wrote:

    Hello!
    I am trying with this question again:
    I would like to test few distributional assumptions for some
    behavioral response data. There are few theories about true
    distribution of those data, like: normal, lognormal, gamma,
    ex-Gaussian (exponential-Gaussian), Wald (inverse Gaussian) etc. The
    best way would be via qq-plot, to show to students differences.
    First two are trivial:
    qqnorm(dat$X)
    qqnorm(log(dat$X))
    Then, things are getting more hairy. I am not sure how to make
    plots for the rest. I tried gamma with:
    qqmath(~ X, data=dat, distribution=function(X)
    � qgamma(X, shape, scale))
    Which should be the same as:
    plot(qgamma(ppoints(dat$X), shape, scale), sort(dat$X))
    Shape and scale parameters I got via mhsmm package that has
    gammafit() for shape and scale parameters estimation.
    Am I on right track? Does anyone know how to plot the rest:
    ex-Gaussian (exponential-Gaussian), Wald (inverse Gaussian)?

    Thanks,
    PM

    __
    r-h...@r-project.org mailto:R-help@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
    http://www.r-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.



 __
 R-help@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@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.


Re: [R] QQ plotting of various distributions...

2009-09-27 Thread Duncan Murdoch

Eric Thompson wrote:

The supposed example of a Q-Q plot is most certainly not how to make a
Q-Q plot. I don't even know where to start

First off, the two Q:s in the title of the plot stand for quantile,
not random. The answer supplied simply plots two sorted samples of
a distribution against each other. While this may resemble the general
shape of a QQ plot, that is where the similarities end.
  


The empirical quantiles of a sample are simply the sorted values.  You 
can plot empirical quantiles of one sample versus some version of 
quantiles from a distribution (what qqnorm does) or versus empirical 
quantiles of another sample (what Sunil did).  The randomness in his 
demonstration did two things: it generated some data, and it showed the 
variability of the plot under repeated sampling.

Some general advice: be careful who you take advice from on the
internet. 


That's good advice.

Duncan Murdoch


The Wikipedia entry for Q-Q plot may be a good start if you
don't know what a Q-Q plot is, although you should also use it with
caution.

Lets say you have some samples that may be normally distributed:

set.seed(1)
x - rnorm(30)

# now try with R's built in function
qqnorm(x, xlim = c(-3, 3), ylim = c(-3, 3))

# Now try Sunil's Q-Q plot method, but for rnorm
# rather than rgamma
some_data - x
test_data - rnorm(30)
points(sort(some_data),sort(test_data), col = blue)

# Note that the points are NOT the same!

This should have been obvious for the simple reason that the QQ plot
should not be influenced by the random number generator that you are
using! A QQ plot is uniquely reproducible. The more general (and
correct) way to get the QQ plot involves choosing a plotting position
and the quantile function (e.g. qnorm or qgamma functions in R) of the
pertinent distribution:

# Sort the data:
x.s - sort(x)
n - length(x)

# Plotting position (must be careful here in general!)
p - ppoints(n)

# Compute the quantile
x.q - qnorm(p)

points(x.q, x.s, col = red)

# and they fall exactly on the points generated by qqnorm().

Now, you should be able to generalize this for any distribution. Hope
this helps.


Eric Thompson




2009/9/27 Petar Milin pmi...@ff.uns.ac.rs:
  

Thanks for the answer. Now, only problem is to to get parameter(s) of a
given function. For gamma, I shall try with gammafit() from mhsmm package.
Also, I shall look for others appropriate parameter estimates. Will use
SuppDists too.

Best,
PM

Sunil Suchindran wrote:


#same shape

some_data - rgamma(500,shape=6,scale=2)
test_data - rgamma(500,shape=6,scale=2)
plot(sort(some_data),sort(test_data))
# You can also use qqplot(some_data,test_data)
abline(0,1)

# different shape

some_data - rgamma(500,shape=6,scale=2)
test_data - rgamma(500,shape=4,scale=2)
plot(sort(some_data),sort(test_data))
abline(0,1)

It is helpful to assess the sampling variability, by
creating repeated sets of test_data, and plotting
all of these along with your observations to create
a confidence envelope.

The SuppDists provides Inverse Gauss.


On Thu, Sep 17, 2009 at 11:46 AM, Petar Milin pmi...@ff.uns.ac.rs wrote:

   Hello!
   I am trying with this question again:
   I would like to test few distributional assumptions for some
   behavioral response data. There are few theories about true
   distribution of those data, like: normal, lognormal, gamma,
   ex-Gaussian (exponential-Gaussian), Wald (inverse Gaussian) etc. The
   best way would be via qq-plot, to show to students differences.
   First two are trivial:
   qqnorm(dat$X)
   qqnorm(log(dat$X))
   Then, things are getting more hairy. I am not sure how to make
   plots for the rest. I tried gamma with:
   qqmath(~ X, data=dat, distribution=function(X)
   � qgamma(X, shape, scale))
   Which should be the same as:
   plot(qgamma(ppoints(dat$X), shape, scale), sort(dat$X))
   Shape and scale parameters I got via mhsmm package that has
   gammafit() for shape and scale parameters estimation.
   Am I on right track? Does anyone know how to plot the rest:
   ex-Gaussian (exponential-Gaussian), Wald (inverse Gaussian)?

   Thanks,
   PM

   __
   R-help@r-project.org mailto:R-help@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
   http://www.r-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.


  

__
R-help@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@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, 

Re: [R] QQ plotting of various distributions...

2009-09-27 Thread Juliet Hannah
I think it's helpful to show the sampling variability in a QQ plot
under repeated
sampling. An example is given
in Venables, Ripley pg 86. The variance is higher at the tails. Even when the
distributions are the same, the QQ plot does not have to resemble a straight
line because of sampling. I don't think you can think of any one of these as the
correct plot.

Also, if the two
data sets have an equal number of points, the empirical qq plot is
simply a plot of
one sorted data set against the other. (Kundu, Statistical Computing, pg 42).


On Sun, Sep 27, 2009 at 9:06 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:
 Eric Thompson wrote:

 The supposed example of a Q-Q plot is most certainly not how to make a
 Q-Q plot. I don't even know where to start

 First off, the two Q:s in the title of the plot stand for quantile,
 not random. The answer supplied simply plots two sorted samples of
 a distribution against each other. While this may resemble the general
 shape of a QQ plot, that is where the similarities end.


 The empirical quantiles of a sample are simply the sorted values.  You can
 plot empirical quantiles of one sample versus some version of quantiles from
 a distribution (what qqnorm does) or versus empirical quantiles of another
 sample (what Sunil did).  The randomness in his demonstration did two
 things: it generated some data, and it showed the variability of the plot
 under repeated sampling.


__
R-help@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.


Re: [R] QQ plotting of various distributions...

2009-09-27 Thread Petar Milin
Thanks all! I did not want to cause any trouble and, God forbid, 
offense. I thought, I asked a simple question to improve my 
understanding and R-skills.


It seems that there ain't single gospel truth about QQs. :-)

Thanks, again!
Best,
PM

Juliet Hannah wrote:

I think it's helpful to show the sampling variability in a QQ plot
under repeated
sampling. An example is given
in Venables, Ripley pg 86. The variance is higher at the tails. Even when the
distributions are the same, the QQ plot does not have to resemble a straight
line because of sampling. I don't think you can think of any one of these as the
correct plot.

Also, if the two
data sets have an equal number of points, the empirical qq plot is
simply a plot of
one sorted data set against the other. (Kundu, Statistical Computing, pg 42).


On Sun, Sep 27, 2009 at 9:06 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:

Eric Thompson wrote:

The supposed example of a Q-Q plot is most certainly not how to make a
Q-Q plot. I don't even know where to start

First off, the two Q:s in the title of the plot stand for quantile,
not random. The answer supplied simply plots two sorted samples of
a distribution against each other. While this may resemble the general
shape of a QQ plot, that is where the similarities end.


The empirical quantiles of a sample are simply the sorted values. �You can
plot empirical quantiles of one sample versus some version of quantiles from
a distribution (what qqnorm does) or versus empirical quantiles of another
sample (what Sunil did). �The randomness in his demonstration did two
things: it generated some data, and it showed the variability of the plot
under repeated sampling.




__
R-help@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.


Re: [R] QQ plotting of various distributions...

2009-09-27 Thread Eric Thompson
It seems I misunderstood Sunil's response and somewhat freaked out
because it appeared that he was giving the wrong method for making a
QQ plot, but was actually demonstrating the sampling variability. My
apologies to Sunil.



2009/9/27 Duncan Murdoch murd...@stats.uwo.ca:
 Eric Thompson wrote:

 The supposed example of a Q-Q plot is most certainly not how to make a
 Q-Q plot. I don't even know where to start

 First off, the two Q:s in the title of the plot stand for quantile,
 not random. The answer supplied simply plots two sorted samples of
 a distribution against each other. While this may resemble the general
 shape of a QQ plot, that is where the similarities end.


 The empirical quantiles of a sample are simply the sorted values.  You can
 plot empirical quantiles of one sample versus some version of quantiles from
 a distribution (what qqnorm does) or versus empirical quantiles of another
 sample (what Sunil did).  The randomness in his demonstration did two
 things: it generated some data, and it showed the variability of the plot
 under repeated sampling.

 Some general advice: be careful who you take advice from on the
 internet.

 That's good advice.

 Duncan Murdoch

 The Wikipedia entry for Q-Q plot may be a good start if you
 don't know what a Q-Q plot is, although you should also use it with
 caution.

 Lets say you have some samples that may be normally distributed:

 set.seed(1)
 x - rnorm(30)

 # now try with R's built in function
 qqnorm(x, xlim = c(-3, 3), ylim = c(-3, 3))

 # Now try Sunil's Q-Q plot method, but for rnorm
 # rather than rgamma
 some_data - x
 test_data - rnorm(30)
 points(sort(some_data),sort(test_data), col = blue)

 # Note that the points are NOT the same!

 This should have been obvious for the simple reason that the QQ plot
 should not be influenced by the random number generator that you are
 using! A QQ plot is uniquely reproducible. The more general (and
 correct) way to get the QQ plot involves choosing a plotting position
 and the quantile function (e.g. qnorm or qgamma functions in R) of the
 pertinent distribution:

 # Sort the data:
 x.s - sort(x)
 n - length(x)

 # Plotting position (must be careful here in general!)
 p - ppoints(n)

 # Compute the quantile
 x.q - qnorm(p)

 points(x.q, x.s, col = red)

 # and they fall exactly on the points generated by qqnorm().

 Now, you should be able to generalize this for any distribution. Hope
 this helps.


 Eric Thompson




 2009/9/27 Petar Milin pmi...@ff.uns.ac.rs:


 Thanks for the answer. Now, only problem is to to get parameter(s) of a
 given function. For gamma, I shall try with gammafit() from mhsmm
 package.
 Also, I shall look for others appropriate parameter estimates. Will use
 SuppDists too.

 Best,
 PM

 Sunil Suchindran wrote:


 #same shape

 some_data - rgamma(500,shape=6,scale=2)
 test_data - rgamma(500,shape=6,scale=2)
 plot(sort(some_data),sort(test_data))
 # You can also use qqplot(some_data,test_data)
 abline(0,1)

 # different shape

 some_data - rgamma(500,shape=6,scale=2)
 test_data - rgamma(500,shape=4,scale=2)
 plot(sort(some_data),sort(test_data))
 abline(0,1)

 It is helpful to assess the sampling variability, by
 creating repeated sets of test_data, and plotting
 all of these along with your observations to create
 a confidence envelope.

 The SuppDists provides Inverse Gauss.


 On Thu, Sep 17, 2009 at 11:46 AM, Petar Milin pmi...@ff.uns.ac.rs
 wrote:

   Hello!
   I am trying with this question again:
   I would like to test few distributional assumptions for some
   behavioral response data. There are few theories about true
   distribution of those data, like: normal, lognormal, gamma,
   ex-Gaussian (exponential-Gaussian), Wald (inverse Gaussian) etc. The
   best way would be via qq-plot, to show to students differences.
   First two are trivial:
   qqnorm(dat$X)
   qqnorm(log(dat$X))
   Then, things are getting more hairy. I am not sure how to make
   plots for the rest. I tried gamma with:
   qqmath(~ X, data=dat, distribution=function(X)
   � qgamma(X, shape, scale))
   Which should be the same as:
   plot(qgamma(ppoints(dat$X), shape, scale), sort(dat$X))
   Shape and scale parameters I got via mhsmm package that has
   gammafit() for shape and scale parameters estimation.
   Am I on right track? Does anyone know how to plot the rest:
   ex-Gaussian (exponential-Gaussian), Wald (inverse Gaussian)?

   Thanks,
   PM

   __
   R-help@r-project.org mailto:R-help@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
   http://www.r-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.




 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 

Re: [R] QQ plotting of various distributions...

2009-09-25 Thread Sunil Suchindran
#same shape

some_data - rgamma(500,shape=6,scale=2)
test_data - rgamma(500,shape=6,scale=2)
plot(sort(some_data),sort(test_data))
# You can also use qqplot(some_data,test_data)
abline(0,1)

# different shape

some_data - rgamma(500,shape=6,scale=2)
test_data - rgamma(500,shape=4,scale=2)
plot(sort(some_data),sort(test_data))
abline(0,1)

It is helpful to assess the sampling variability, by
creating repeated sets of test_data, and plotting
all of these along with your observations to create
a confidence envelope.

The SuppDists provides Inverse Gauss.


On Thu, Sep 17, 2009 at 11:46 AM, Petar Milin pmi...@ff.uns.ac.rs wrote:

 Hello!
 I am trying with this question again:
 I would like to test few distributional assumptions for some behavioral
 response data. There are few theories about true distribution of those data,
 like: normal, lognormal, gamma, ex-Gaussian (exponential-Gaussian), Wald
 (inverse Gaussian) etc. The best way would be via qq-plot, to show to
 students differences. First two are trivial:
 qqnorm(dat$X)
 qqnorm(log(dat$X))
 Then, things are getting more hairy. I am not sure how to make plots for
 the rest. I tried gamma with:
 qqmath(~ X, data=dat, distribution=function(X)
   qgamma(X, shape, scale))
 Which should be the same as:
 plot(qgamma(ppoints(dat$X), shape, scale), sort(dat$X))
 Shape and scale parameters I got via mhsmm package that has gammafit() for
 shape and scale parameters estimation.
 Am I on right track? Does anyone know how to plot the rest: ex-Gaussian
 (exponential-Gaussian), Wald (inverse Gaussian)?

 Thanks,
 PM

 __
 R-help@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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@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.