[R] HPD credible sets

2005-08-10 Thread pantd
Hi R users
Is there a function in R that gives HPD credible sets.  i googled it but was in
vain!

- dev

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


Re: [R] gamma distribution

2005-07-28 Thread pantd
thanks for your response. btw i am calculating the power of the wilcoxon test. i
divide the total no. of rejections by the no. of simulations. so for 1000
simulations, at 0.05 level of significance if the no. of rejections are 50 then
the power will be 50/1000 = 0.05. thats y im importing in excel the p values.

is my approach correct??

thanks n regards
-dev


Quoting Uwe Ligges [EMAIL PROTECTED]:

 Answering both messges here:


 1. [EMAIL PROTECTED] wrote:
   Hi I appreciate your response. This is what I observed..taking
   the log transform of the raw gamma does change the p value of
   the test. That is what I am importing into excel (the p - values)

 Well, so you made a mistake! And I still do not know why anybody realy
 want to import data to Excel, if the data is already in R.

 For me, the results are identical (and there is no reason why not).


   and then calculating the power of the test (both raw and
   transformed).
  
   can you tell me what exactly your code is doing?

 See below.


 2. [EMAIL PROTECTED] wrote:
  Hi
  I ran your code. I think it should give me the number of p values below
 0.05
  significance level  (thats what i could understand from your code), but
 after
  running your code there is neither any error that shows up nor any value
 that
  the console displays.

 You are right in the point what the code I sent does:

erg - replicate(1000, {
 x-rgamma(10, 2.5, scale = 10)
 y-rgamma(10, 2.5, scale = 10)
 wilcox.test(x, y, var.equal = FALSE)$p.value
 })
 sum(erg  0.05) # 45


 and it works for me. It results in a random number close to 50, hopefully.

 Since both points above seem to be very strange on your machine: Which
 version of R are you using? We assume the most recent one which is R-2.1.1.

 Uwe Ligges



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


Re: [R] gamma distribution

2005-07-28 Thread pantd
Hi Christopher and Uwe. thanks for your time and guidance.
I deeply appreciate it.


-dev


Quoting Christoph Buser [EMAIL PROTECTED]:

 Hi

 As Uwe mentioned be careful about the difference the
 significance level alpha and the power of a test.

 To do power calculations you should specify and alternative
 hypothesis H_A, e.g. if you have two populations you want to
 compare and we assume that they are normal distributed (equal
 unknown variance for simplicity). We are interested if there is
 a difference in the mean and want to use the t.test.
 Our Null hypothesis H_0: there is no difference in the means

 To do a power calculation for our test, we first have to specify
 and alternative H_A: the mean difference is 1 (unit)
 Now for a fix number of observations we can calculate the power
 of our test, which is in that case the probability that (if the
 true unknown difference is 1, meaning that H_A is true) our test
 is significant, meaning if I repeat the test many times (always
 taking samples with mean difference of 1), the number of
 significant test divided by the total number of tests is an
 estimate for the power.


 In you case the situation is a little bit more complicated. You
 need to specify an alternative hypothesis.
 In one of your first examples you draw samples from two gamma
 distributions with different shape parameter and the same
 scale. But by varying the shape parameter the two distributions
 not only differ in their mean but also in their form.

 I got an email from Prof. Ripley in which he explained in
 details and very precise some examples of tests and what they
 are testing. It was in addition to the first posts about t tests
 and wilcoxon test.
 I attached the email below and recommend to read it carefully. It
 might be helpful for you, too.

 Regards,

 Christoph Buser

 --
 Christoph Buser [EMAIL PROTECTED]
 Seminar fuer Statistik, LEO C13
 ETH (Federal Inst. Technology)8092 Zurich  SWITZERLAND
 phone: x-41-44-632-4673   fax: 632-1228
 http://stat.ethz.ch/~buser/
 --

 

 From: Prof Brian Ripley [EMAIL PROTECTED]
 To: Christoph Buser [EMAIL PROTECTED]
 cc: Liaw, Andy [EMAIL PROTECTED]
 Subject: Re: [R] Alternatives to t-tests (was Code Verification)
 Date: Thu, 21 Jul 2005 10:33:28 +0100 (BST)

 I believe there is a rather more to this than Christoph's account.  The
 Wilcoxon test is not testing the same null hypothesis as the t-test, and
 that may very well matter in practice and it does in the example given.

 The (default in R) Welch t-test tests a difference in means between two
 samples, not necessarily of the same variance or shape.  A difference in
 means is simple to understand, and is unambiguously defined at least if
 the distributions have means, even for real-life long-tailed
 distributions.  Inference from the t-test is quite accurate even a long
 way from normality and from equality of the shapes of the two
 distributions, except in very small sample sizes.  (I point my beginning
 students at the simulation study in `The Statistical Sleuth' by Ramsey and
 Schafer, stressing that the unequal-variance t-test ought to be the
 default choice as it is in R.  So I get them to redo the simulations.)

 The Wilcoxon test tests a shift in location between two samples from
 distributions of the same shape differing only by location.  Having the
 same shape is part of the null hypothesis, and so is an assumption that
 needs to be verified if you want to conclude there is a difference in
 location (e.g. in means).  Even if you assume symmetric distributions (so
 the location is unambiguously defined) the level of the test depends on
 the shapes, tending to reject equality of location in the presence of
 difference of shape.  So you really are testing equality of distribution,
 both location and shape, with power concentrated on location-shift
 alternatives.

 Given samples from a gamma(shape=2) and gamma(shape=20) distributions, we
 know what the t-test is testing (equality of means).  What is the Wilcoxon
 test testing?  Something hard to describe and less interesting, I believe.

 BTW, I don't see the value of the gamma simulation as this
 simultaneously changes mean and shape between the samples.  How about
 checking holding the mean the same:

 n - 1000
 z1 - z2 - numeric(n)
 for (i in 1:n) {
x - rgamma(40, 2.5, 0.1)
y - rgamma(40, 10, 0.1*10/2.5)
z1[i] - t.test(x, y)$p.value
z2[i] - wilcox.test(x, y)$p.value
 }
 ## Level
 1 - sum(z10.05)/1000  ## 0.049
 1 - sum(z20.05)/1000  ## 0.15

 ? -- the Wilcoxon test is shown to be a poor test of equality of means.
 Christoph's simulation shows that it is able to use difference in shape as
 well as location in the test of these two distributions, whereas the
 t-test is designed only to use the 

Re: [R] gamma distribution

2005-07-27 Thread pantd
Hi
You are right but here I am taking into account the p values I get from the
tests on the raw and the transformed samples. And then I calculate the power of
the tests based on the # of rejections of the p values.
DO you think its a good way to determine the power of a test?

thanks

-dev


Quoting Christoph Buser [EMAIL PROTECTED]:

 Hi

 I am a little bit confused. You create two sample (from a gamma
 distribution) and you do a wilcoxon test with this two samples.
 Then you use the same monotone transformation (log) for both
 samples and redo the wilcoxon test.
 But since the transformations keeps the order of your samples
 the second wilcoxon test is identical to the first one:

 x-rgamma(10, 2.5, scale = 10)
 y-rgamma(10, 2.5, scale = 10)
 wilcox.test(x, y, var.equal = FALSE)
 x1-log(x)
 y1-log(y)
 wilcox.test(x1, y1, var.equal = FALSE)

 Maybe you can give some more details about the hypothesis you'd
 like to test.

 Regards,

 Christoph Buser

 --
 Christoph Buser [EMAIL PROTECTED]
 Seminar fuer Statistik, LEO C13
 ETH (Federal Inst. Technology)8092 Zurich  SWITZERLAND
 phone: x-41-44-632-4673   fax: 632-1228
 http://stat.ethz.ch/~buser/
 --



 [EMAIL PROTECTED] writes:
   Hi R Users
  
  
   This is a code I wrote and just want to confirm if the first 1000 values
 are raw
   gamma (z) and the next 1000 values are transformed gamma (k) or not. As I
 get
   2000 rows once I import into excel, the p - values beyond 1000 dont look
 that
   good, they are very high.
  
  
   --
   sink(a1.txt);
  
   for (i in 1:1000)
   {
   x-rgamma(10, 2.5, scale = 10)
   y-rgamma(10, 2.5, scale = 10)
   z-wilcox.test(x, y, var.equal = FALSE)
   print(z)
   x1-log(x)
   y1-log(y)
   k-wilcox.test(x1, y1, var.equal = FALSE)
   print(k)
   }
  
   ---
   any suggestions are welcome
  
   thanks
  
   -devarshi
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html


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


Re: [R] gamma distribution

2005-07-27 Thread pantd
Hi
I ran your code. I think it should give me the number of p values below 0.05
significance level  (thats what i could understand from your code), but after
running your code there is neither any error that shows up nor any value that
the console displays.


thanks in advance

-dev.

Quoting Uwe Ligges [EMAIL PROTECTED]:
 [EMAIL PROTECTED] wrote:

  Hi R Users
 
 
  This is a code I wrote and just want to confirm if the first 1000 values
 are raw
  gamma (z) and the next 1000 values are transformed gamma (k) or not. As I
 get
  2000 rows once I import into excel, the p - values beyond 1000 dont look
 that
  good, they are very high.

 He?
 - log() transforming the data does not change the Wilcoxon statistics
 (based on ranks!)!
 - Why is this related to Excel?
 - What are you going to show?

 I get

   erg - replicate(1000, {
   x-rgamma(10, 2.5, scale = 10)
   y-rgamma(10, 2.5, scale = 10)
   wilcox.test(x, y, var.equal = FALSE)$p.value
   })
   sum(erg  0.05) # 45

 which seems plausible to me.


 Uwe Ligges



 
  --
  sink(a1.txt);
 
  for (i in 1:1000)
  {
  x-rgamma(10, 2.5, scale = 10)
  y-rgamma(10, 2.5, scale = 10)
  z-wilcox.test(x, y, var.equal = FALSE)
  print(z)
  x1-log(x)
  y1-log(y)
  k-wilcox.test(x1, y1, var.equal = FALSE)
  print(k)
  }
 
  ---
  any suggestions are welcome
 
  thanks
 
  -devarshi
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html


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


[R] gamma distribution

2005-07-26 Thread pantd
Hi R Users


This is a code I wrote and just want to confirm if the first 1000 values are raw
gamma (z) and the next 1000 values are transformed gamma (k) or not. As I get
2000 rows once I import into excel, the p - values beyond 1000 dont look that
good, they are very high.


--
sink(a1.txt);

for (i in 1:1000)
{
x-rgamma(10, 2.5, scale = 10)
y-rgamma(10, 2.5, scale = 10)
z-wilcox.test(x, y, var.equal = FALSE)
print(z)
x1-log(x)
y1-log(y)
k-wilcox.test(x1, y1, var.equal = FALSE)
print(k)
}

---
any suggestions are welcome

thanks

-devarshi

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


[R] A Question About Inverse Gamma

2005-07-21 Thread pantd
Hi R users,


I am having a little problem finding the the solution to this problem in R:

1. I need to generate normal distribution of sample size 30, mean = 50, sd = 5.
2. From the statistics obtained in step 1, I need to generate the Inverse Gamma
distribution.

Your views and help will be appreciated.

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


[R] Code Verification

2005-07-19 Thread pantd
Hi R Users
I have a code which I am running for my thesis work. Just want to make sure that
its ok. Its a t test I am conducting between two gamma distributions with
different shape parameters.

the code looks like:

sink(a1.txt);

for (i in 1:1000)
{
x-rgamma(40, 2.5, 10)  # n = 40, shape = 2.5, Scale = 10
y-rgamma(40, 2.8, 10)  # n = 40, shape = 2.8, Scale = 10
z-t.test(x, y)
print(z)
}


I will appreciate it if someone could tell me if its alrite or not.

thanks

-dev

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


[R] question from environmental statistics

2005-07-15 Thread pantd
thanks Fran. that was useful but Im still in a fix. its a real life data which
looks like this:
0.9
10.9
24.0
6.7
0.6
1.0
2.4
12.4
7.9
15.8
1.4
7.9
11000.0

(benzene conc. taken after WTC attacks)..its just a small chunk of data i pasted
for you to look at.
its neither normal nor lognormal. someone told me that qq plot does help in
determining the distribution. im not sure how to get it.

can someone help me in this.

thanks



Take a look at this document by Vito Ricci:
http://cran.r-project.org/doc/contrib/Ricci-distributions-en.pdf

Did you try RSiteSearch(Fit distribution) or a Google search?  That will
lead you to fit.dist{gnlm} and fitdistr{MASS}

Cheers

Francisco


From: [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject: [R] question from environmental statistics
Date: Thu, 14 Jul 2005 14:06:45 -0700



Dear R users
I want to knw if there is a way in which a raw dataset can be modelled by
some
distribution. besides the gof test is there any test involving gamma or
lognormal that would fit the data.

thank you

-dev

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


[R] question from environmental statistics

2005-07-14 Thread pantd


Dear R users
I want to knw if there is a way in which a raw dataset can be modelled by some
distribution. besides the gof test is there any test involving gamma or
lognormal that would fit the data.

thank you

-dev

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