Re: [R] test
You probably should check this section in your R-help subscription options (via https://stat.ethz.ch/mailman/options/r-help/, I think): Receive your own posts to the list? Ordinarily, you will get a copy of every message you post to the list. If you don't want to receive this copy, set this option to No. I see 5 identical posts with the subject "Several questions about MCMClogit" on R-help recently. -- Tony Plate j t wrote: Sorry to bother your. I am trying to post my question for more than 10 times, but I still didn't see it. It drives my crazy!!! It is a test for posting some simple pure text. Chao __ 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] test
Tony Plate wrote: You probably should check this section in your R-help subscription options (via https://stat.ethz.ch/mailman/options/r-help/, I think): Receive your own posts to the list? Tony, Like jt I too have it set to receive my own messages, but I too don't see them. I wonder if it has to do with the fact that both of us use gmail to post to the list? In any case, regardless if we see them, they are getting posted, which is what matters :) Cheers, Esmail __ 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] test
On May 13, 2008, at 5:52 AM, Esmail Bonakdarian wrote: Tony Plate wrote: You probably should check this section in your R-help subscription options (via https://stat.ethz.ch/mailman/options/r-help/, I think): Receive your own posts to the list? Tony, Like jt I too have it set to receive my own messages, but I too don't see them. I wonder if it has to do with the fact that both of us use gmail to post to the list? Bingo! Well, I don't know if this happens with the web interface to gmail, but if you use POP to access your gmail account, then any emails you send to any kind of list will not get back to you (Problem being, sort of, that gmail groups things in "Conversations", and in this case will remember the email you sent out and use that copy in the conversation, instead of the one sent through the list. Not a very good excuse in my opinion, and a particularly irritating "feature".). I wouldn't really expect them to "fix" it any time soon. In the rare occasions where my waiting powers get exhausted before someone on this very helpful list replies to my email, I just use the online archives to check whether my email was sent or not. In any case, regardless if we see them, they are getting posted, which is what matters :) Cheers, Esmail Haris Skiadas Department of Mathematics and Computer Science Hanover College __ 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] test
Charilaos Skiadas wrote: On May 13, 2008, at 5:52 AM, Esmail Bonakdarian wrote: Tony Plate wrote: You probably should check this section in your R-help subscription options (via https://stat.ethz.ch/mailman/options/r-help/, I think): Receive your own posts to the list? Tony, Like jt I too have it set to receive my own messages, but I too don't see them. I wonder if it has to do with the fact that both of us use gmail to post to the list? Bingo! Well, I don't know if this happens with the web interface to gmail, but if you use POP to access your gmail account, then any emails you send to any kind of list will not get back to you Yup, I use Thunderbird to read/process my gmail :-) (Problem being, sort of, that gmail groups things in "Conversations", and in this case will remember the email you sent out and use that copy in the conversation, instead of the one sent through the list. Except that part of the conversation sits in my "sent" folder rather than being nicely threaded into the conversation. Not a very good excuse in my opinion, and a particularly irritating "feature".). agreed! In the rare occasions where my waiting powers get exhausted before someone on this very helpful list replies to my email, I just use the online archives to check whether my email was sent or not. Yes, I did that initially when I wasn't sure if my message was getting out. Often thought I don't have to do this because the helpful folks on this list have already replied to my posting. Best, Esmail __ 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] test
Hi Everyone, As I expected, posting via the news.gmane.org newsserver with a spam-trap e-mail address (see below) didn't work. I think this post, with my real e-mail address, should work. If so, please accept the apology below! If it does work I'll also find out if the e-mail address obfuscation of gmane works. Best regards, Keith Jewell -- Sorry to burden the list with a test message (if it gets through!), but at least this is an existing thread called "test". I read the list via a Usenet newsreader (Microsoft Outlook Express) and news.gmane.org (power to their elbow), but in the past have posted messages via e-mail. This message is posted from the newsreader and I suspect it will fail because I'm using a bogus, spam-trap, e-mail address. If you see this message you'll know that such spam-trap addresses work with gmane! Best regards "Esmail Bonakdarian" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Charilaos Skiadas wrote: >> On May 13, 2008, at 5:52 AM, Esmail Bonakdarian wrote: >> >>> Tony Plate wrote: You probably should check this section in your R-help subscription options (via https://stat.ethz.ch/mailman/options/r-help/, I think): > Receive your own posts to the list? >>> >>> Tony, >>> >>> Like jt I too have it set to receive my own messages, but I too >>> don't see them. I wonder if it has to do with the fact that both >>> of us use gmail to post to the list? >> >> Bingo! Well, I don't know if this happens with the web interface to >> gmail, but if you use POP to access your gmail account, then any emails >> you send to any kind of list will not get back to you > > Yup, I use Thunderbird to read/process my gmail :-) > >> (Problem being, sort of, that gmail groups things in "Conversations", and >> in this case will remember the email you sent out and use that copy in >> the conversation, instead of the one sent through the list. > > Except that part of the conversation sits in my "sent" folder rather > than being nicely threaded into the conversation. > >> Not a very good excuse in my opinion, and a particularly irritating >> "feature".). > > agreed! > >> In the rare occasions where my waiting powers get exhausted before >> someone on this very helpful list replies to my email, I just use the >> online archives to check whether my email was sent or not. > > Yes, I did that initially when I wasn't sure if my message was getting > out. Often thought I don't have to do this because the helpful folks on > this list have already replied to my posting. > > Best, > Esmail > > __ > 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] Test Set Deviances
Thomas Allen wrote: Dear all I'm building logistic regression models using glm() and then validating their predictive ability on a test set using predict() to get the probabilities. I understand how to attain the deviance of the model fitted to the training set. But is there a way to get the deviance within the test set? Cheers Tom This is essentially the index "D" reported by validate.lrm in the Design package. Don't use just one test set unless it has more than 15,000 subjects in it. validate.lrm will do resampling for you. Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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] test for bimodality
On 31/08/2009, at 9:40 AM, John Sansom wrote: Has a test for bimodality been implemented in R? Doing RSiteSearch("test for bimodality") yields one hit, which points to http://finzi.psych.upenn.edu/Rhelp08/2008-September/173308.html It looks like it might be *some* help to you. cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ 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] test for bimodality
Dear John, you may check dip in package diptest, which tests unimodality vs. multimuodality (you'll need qDiptab for that, too). Apologies if this misses the point; I only saw the last responses but not the original question so this may not be what you are after, or already mentioned, but I decided that I risk making a fool of myself for a small chance that it helps you. Cheers, Christian On Mon, 31 Aug 2009, Rolf Turner wrote: On 31/08/2009, at 9:40 AM, John Sansom wrote: Has a test for bimodality been implemented in R? Doing RSiteSearch("test for bimodality") yields one hit, which points to http://finzi.psych.upenn.edu/Rhelp08/2008-September/173308.html It looks like it might be *some* help to you. cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ 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. *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche __ 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] test for bimodality
Rolf Turner wrote: On 31/08/2009, at 9:40 AM, John Sansom wrote: Has a test for bimodality been implemented in R? Doing RSiteSearch("test for bimodality") yields one hit, which points to http://finzi.psych.upenn.edu/Rhelp08/2008-September/173308.html It looks like it might be *some* help to you. cheers, Rolf Turner I have used the dip test for testing if a distribution is *unimodal*. Possibly that is what John needs. See package diptest. David Scott -- _ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142,NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 Director of Consulting, Department of Statistics __ 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] test for multivariate normality?
Yes. You could install "mvnormtest" Package and perform the multivariate normality test. By using mshapiro.test I wish this is helpful! Chunhao Tu Quoting HongSheng Liao <[EMAIL PROTECTED]>: My stat textbook tells me that using Shapiro-Wilk test for each variable one by one is not equal to a test for multivariate normality as a whole. Does R have a function of testing for multivariate normality? Thanks. Hongsheng (Hank) Liao, Ph.D. Lab Manager Center for Quantitative Fisheries Ecology 800 West 46th Street Old Dominion University Norfolk, Virginia 23508 Phone:757.683.4571 Fax:757.683.5293 __ 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] Test of Homogeneity of Variances
What are your hypotheses? Once you state what they are, interpretation should be straightforward. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Daren Tan Sent: Friday, August 22, 2008 11:18 AM To: [EMAIL PROTECTED] Subject: [R] Test of Homogeneity of Variances I am testing the homogeneity of variances via bartlett.test and fligner.test. Using the following example, how should I interpret the p-value in order to accept or reject the null hypothesis ? set.seed(5) x <- rnorm(20) bartlett.test(x, rep(1:5, each=4)) Bartlett test of homogeneity of variances data: x and rep(1:5, each = 4) Bartlett's K-squared = 1.7709, df = 4, p-value = 0.7778 fligner.test(x, rep(1:5, each=4)) Fligner-Killeen test of homogeneity of variances data: x and rep(1:5, each = 4) Fligner-Killeen:med chi-squared = 1.0819, df = 4, p-value = 0.8971 __ 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. This email message, including any attachments, is for th...{{dropped:6}} __ 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] Test of Homogeneity of Variances
I am testing whether the sample variances are equal. When p-value < 0.05 (alpha), should accept null hypothesis (sample variances are equal) or reject it ? The two new examples with each having same sample variances also puzzle me. Why are the p-values different ? bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4)) Bartlett test of homogeneity of variances data: rep(rnorm(5), times = 4) and rep(1:5, each = 4) Bartlett's K-squared = 0.8681, df = 4, p-value = 0.929 bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4)) Bartlett test of homogeneity of variances data: rep(rnorm(5), times = 4) and rep(1:5, each = 4) Bartlett's K-squared = 3.5599, df = 4, p-value = 0.4688 > From: [EMAIL PROTECTED] > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Date: Fri, 22 Aug 2008 11:25:36 -0400 > Subject: RE: [R] Test of Homogeneity of Variances > > What are your hypotheses? Once you state what they are, interpretation should > be straightforward. > > > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Daren Tan > Sent: Friday, August 22, 2008 11:18 AM > To: [EMAIL PROTECTED] > Subject: [R] Test of Homogeneity of Variances > > > I am testing the homogeneity of variances via bartlett.test and fligner.test. > Using the following example, how should I interpret the p-value in order to > accept or reject the null hypothesis ? > > set.seed(5) > x <- rnorm(20) > bartlett.test(x, rep(1:5, each=4)) > > > Bartlett test of homogeneity of variances > > > data: x and rep(1:5, each = 4) > Bartlett's K-squared = 1.7709, df = 4, p-value = 0.7778 > > fligner.test(x, rep(1:5, each=4)) > > Fligner-Killeen test of homogeneity of variances > > > data: x and rep(1:5, each = 4) > Fligner-Killeen:med chi-squared = 1.0819, df = 4, p-value = 0.8971 > > __ > 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. > This email message, including any attachments, is for ...{{dropped:6}} __ 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] Test of Homogeneity of Variances
Have you read the documentation to either of the functions you are using? ?bartlett.test "Performs Bartlett's test of the null that the variances in each of the groups (samples) are the same." This explicitly tells you what is being tested, i.e. the null tested is that var1 = var2. ?rnorm Generates random deviates, so the answer [i.e. p-value] will (almost certainly) differ each time. Only by setting a seed for the random number generator to use will rnorm() generate the same number-set/distribution and therefore the same p-value. ?set.seed ## set.seed(7) bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4)) set.seed(7) bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4)) set(23) bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4)) bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4)) HTH, Mark. Daren Tan wrote: > > > I am testing whether the sample variances are equal. When p-value < 0.05 > (alpha), should accept null hypothesis (sample variances are equal) or > reject it ? > > > The two new examples with each having same sample variances also puzzle > me. Why are the p-values different ? > > bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4)) > > > Bartlett test of homogeneity of variances > > > data: rep(rnorm(5), times = 4) and rep(1:5, each = 4) > Bartlett's K-squared = 0.8681, df = 4, p-value = 0.929 > > > bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4)) > > > Bartlett test of homogeneity of variances > > > data: rep(rnorm(5), times = 4) and rep(1:5, each = 4) > Bartlett's K-squared = 3.5599, df = 4, p-value = 0.4688 > > >> From: [EMAIL PROTECTED] >> To: [EMAIL PROTECTED]; [EMAIL PROTECTED] >> Date: Fri, 22 Aug 2008 11:25:36 -0400 >> Subject: RE: [R] Test of Homogeneity of Variances >> >> What are your hypotheses? Once you state what they are, interpretation >> should be straightforward. >> >> >> >> -Original Message- >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >> On Behalf Of Daren Tan >> Sent: Friday, August 22, 2008 11:18 AM >> To: [EMAIL PROTECTED] >> Subject: [R] Test of Homogeneity of Variances >> >> >> I am testing the homogeneity of variances via bartlett.test and >> fligner.test. Using the following example, how should I interpret the >> p-value in order to accept or reject the null hypothesis ? >> >> set.seed(5) >> x <- rnorm(20) >> bartlett.test(x, rep(1:5, each=4)) >> >> >> Bartlett test of homogeneity of variances >> >> >> data: x and rep(1:5, each = 4) >> Bartlett's K-squared = 1.7709, df = 4, p-value = 0.7778 >> >> fligner.test(x, rep(1:5, each=4)) >> >> Fligner-Killeen test of homogeneity of variances >> >> >> data: x and rep(1:5, each = 4) >> Fligner-Killeen:med chi-squared = 1.0819, df = 4, p-value = 0.8971 >> >> __ >> 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. >> This email message, including any attachments, is for ...{{dropped:6}} > > __ > 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. > > -- View this message in context: http://www.nabble.com/Test-of-Homogeneity-of-Variances-tp19109383p19112613.html Sent from the R help mailing list archive at Nabble.com. __ 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] Test of Homogeneity of Variances
You don't need to test that the _sample_ variances are different: They already are. Statistical tests of hypotheses are not about sample statistics, but distributional charateristics. It seems to me that reinforcement of some basic stat concept may do you quite a bit of good. If you don't have the basics, you're just going to get more and more puzzled every step of the way. Just a frank suggestion. Best, Andy From: Daren Tan > > I am testing whether the sample variances are equal. When > p-value < 0.05 (alpha), should accept null hypothesis (sample > variances are equal) or reject it ? > > > The two new examples with each having same sample variances > also puzzle me. Why are the p-values different ? > > bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4)) > > > Bartlett test of homogeneity of variances > > > data: rep(rnorm(5), times = 4) and rep(1:5, each = 4) > Bartlett's K-squared = 0.8681, df = 4, p-value = 0.929 > > > bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4)) > > > Bartlett test of homogeneity of variances > > > data: rep(rnorm(5), times = 4) and rep(1:5, each = 4) > Bartlett's K-squared = 3.5599, df = 4, p-value = 0.4688 > > > > From: [EMAIL PROTECTED] > > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > > Date: Fri, 22 Aug 2008 11:25:36 -0400 > > Subject: RE: [R] Test of Homogeneity of Variances > > > > What are your hypotheses? Once you state what they are, > interpretation should be straightforward. > > > > > > > > -Original Message- > > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Daren Tan > > Sent: Friday, August 22, 2008 11:18 AM > > To: [EMAIL PROTECTED] > > Subject: [R] Test of Homogeneity of Variances > > > > > > I am testing the homogeneity of variances via bartlett.test > and fligner.test. Using the following example, how should I > interpret the p-value in order to accept or reject the null > hypothesis ? > > > > set.seed(5) > > x <- rnorm(20) > > bartlett.test(x, rep(1:5, each=4)) > > > > > > Bartlett test of homogeneity of variances > > > > > > data: x and rep(1:5, each = 4) > > Bartlett's K-squared = 1.7709, df = 4, p-value = 0.7778 > > > > fligner.test(x, rep(1:5, each=4)) > > > > Fligner-Killeen test of homogeneity of variances > > > > > > data: x and rep(1:5, each = 4) > > Fligner-Killeen:med chi-squared = 1.0819, df = 4, p-value = 0.8971 > > > > __ > > 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. > > This email message, including any attachments, is for > ...{{dropped:6}} > > __ > 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. > Notice: This e-mail message, together with any attachme...{{dropped:12}} __ 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] test for a single variance
Edna Bell gmail.com> writes: > > Dear R Gurus: > > Is there a test for a single variance available in R, please? > > Thanks, > Edna Bell > Do you mean a test for homogeneity of variance? If so, try RSiteSearch("variance homogeneity") and see what you get ... Ben Bolker __ 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] test for a single variance
If you are trying to test the hypotheses: H0: sigma^2 == sigma[0]^2 Ha: sigma^2 != sigma[0]^2 i.e. is the variance of the distribution from which the data came different from the hypothesized value? Then the normal theory test can be done fairly simply (I don't know of any prepackaged equivalents) by something like: > pchisq( var(y)*(length(y)-1)/sigma0, length(y)-1, lower.tail= var(y) < sigma0 > ) * 2 Assuming "sigma0" is the hypothesized variance and I remember the formula correctly. However, this is only valid if the data comes from a distribution that is very close to a normal distribution. Inference on the mean is robust to normality assumptions, but not the variance, hence this is not used much in practice. If you are really interested in the test on the variance (a good thing, many problems really should look at the variance as the 1st outcome of interest, rather than as a nuisance variable), then a possibly better approach would be to calculate a confidence interval on the variance using something that does not depend on distributional assumptions (bootstrap could be one option) and compare that to the hypothesized value. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Edna Bell > Sent: Tuesday, September 09, 2008 4:31 PM > To: [EMAIL PROTECTED] > Subject: [R] test for a single variance > > Dear R Gurus: > > Is there a test for a single variance available in R, please? > > Thanks, > Edna Bell > > __ > 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] Test Driven Development in R
Jose Quesada wrote: Hi, I wonder what kind of interest there is on Test Driven Development (TDD) in R. Test Driven Development consists of writing the test before the function, and iteratively build the function until it passes the test. Python and Ruby (specially Ruby) have very strong test-oriented cultures. In fact, in Ruby at least the custom is to do TDD and lately Behavior-driven development (BDD). In BDD, one writes a story of what one would want the code to do. This story is almost native English, and then the test suite converts it into something that the language understand as tests. There are some posts on the list about this, but they are about testing in general (Runit), not TDD. Example: http://thread.gmane.org/gmane.comp.lang.r.general/85047 Recently, I found there is an alpha, but working implementation of TDD for Komodo edit: www.sciviews.org/SciViews-K/index.html The editor has a green bar that becomes red as soon as one edits a function, and that edit breaks the tests. This is tremendously useful. Using Gmane search, the only mention I could find on svUnit was: http://thread.gmane.org/gmane.comp.lang.r.general/136632/focus=136662 I think this could make a great UseR 2009 talk. Ideally, by someone with more R experience than me, and even more ideally by Philippe Grosjean :), but it push comes to shove, I could prepare such a talk. Would this be interesting at all? Are there any resources that I have missed? There is the RUnit package which is a mature xUnit implementation for R. I don't know of a tight integration into an editor (apart from that it is _planned_ for StatET, the Eclipse R plug-in), but as such it is very useful already. http://cran.r-project.org/web/packages/RUnit/index.html HTH, Tobias __ 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] Test Driven Development in R
Hi, Jose: How does the following I have not studied "Test Driven Development", but I routinely write documentation "*.Rd" files before I write code, and the documentation files include test cases in the "\examples" section. With "\dontshow", I hide tests that I don't think would benefit a user. The source for the 'fda' package includes numerous constructions like the following: \dontshow{stopifnot(} all.equal(fRegressout, knee.hip.f) \dontshow{)} Here, "fRegressout" and "knee.hip.f" are two different objects that should theoretically be equal. I show the user that they are in fact equal, but I don't bother the user with the "stopifnot" call that will stop "R CMD check" to let me know that the code fails this test. I have not used "Runit", but it's on my "to do" list. "Sciviews-K" sounds interesting, but I have not used it. Also, Chambers (2008) Software for Data Analysis (Springer) says that "trustworthy software" is "The Prime Directive". TDD sounds like it would support that goal. I will not be able to attend useR 2009 but would be interested in a further discussion of this issue. Best Wishes, Spencer Graves Tobias Verbeke wrote: Jose Quesada wrote: Hi, I wonder what kind of interest there is on Test Driven Development (TDD) in R. Test Driven Development consists of writing the test before the function, and iteratively build the function until it passes the test. Python and Ruby (specially Ruby) have very strong test-oriented cultures. In fact, in Ruby at least the custom is to do TDD and lately Behavior-driven development (BDD). In BDD, one writes a story of what one would want the code to do. This story is almost native English, and then the test suite converts it into something that the language understand as tests. There are some posts on the list about this, but they are about testing in general (Runit), not TDD. Example: http://thread.gmane.org/gmane.comp.lang.r.general/85047 Recently, I found there is an alpha, but working implementation of TDD for Komodo edit: www.sciviews.org/SciViews-K/index.html The editor has a green bar that becomes red as soon as one edits a function, and that edit breaks the tests. This is tremendously useful. Using Gmane search, the only mention I could find on svUnit was: http://thread.gmane.org/gmane.comp.lang.r.general/136632/focus=136662 I think this could make a great UseR 2009 talk. Ideally, by someone with more R experience than me, and even more ideally by Philippe Grosjean :), but it push comes to shove, I could prepare such a talk. Would this be interesting at all? Are there any resources that I have missed? There is the RUnit package which is a mature xUnit implementation for R. I don't know of a tight integration into an editor (apart from that it is _planned_ for StatET, the Eclipse R plug-in), but as such it is very useful already. http://cran.r-project.org/web/packages/RUnit/index.html HTH, Tobias __ 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] Test Driven Development in R
Hello, As Jose noted, svUnit is fully functional. It is completely written and has recently entered in beta stage. It will be released on CRAN (GPL >= 2) at the end of the beta test, lasting in October 2009. svUnit R package is independent from the SciViews GUI, but it is true there is also a GUI for test-driven development (TDD) in R using svUnit + SciViews-K + Komodo, and it works on Linux/Windows/Mac OS X. It is probably the first one available for R. I am pretty sure other people will release similar tools for Eclipse/StatET and for Emacs/ESS soon. The GUI for TDD on top of svUnit depends on SciViews packages that are in mixed states: some are already on CRAN (svMisc, svSocket, svGUI, svIDE), while others, like svUnit or svTools are still in, respectively, beta and alpha stages. You can install them right now from r-forge only. Use: > install.packages("svUnit", repos="http://R-Forge.R-project.org";) in R to install svUnit. On Mac OS X, if R cannot find the binaries, make: > install.packages("svUnit", repos="http://R-Forge.R-project.org";, + type = "source") I want to remind also that svUnit is "test code compatible" with RUnit. Understand: you can use the same test units both with RUnit and with svUnit (but not simultaneously, of course). I think both packages have strengths. RUnit has (experimental) functions to check code coverage of the tests, while svUnit is much more flexible to define the tests: they can be attached to R objects, on memory, or on a .R file, they can be independent objects, and of course, they can also be contained in test suite on disk files, like for Runit. Also, svUnit proposes a mechanism to automatically locate tests, test units and test suites. It also proposes a central logging feature collecting test results from different test runs, and it fully integrates with the R CMD check mechanism of R for packages checking. Finally, svUnit reports can be pretty formatted using creole wiki language and be integrated in wikis (like http://wiki.r-project.org), say for automatic nightly test of your code. See page 9 of the svUnit vignette for an example. It is this additional flexibility that is exploited in the GUI part for TDD in SciViews-K. There is a vignette associated with the svUnit package detailing all its features. Just make: library(svUnit) vignette("svUnit") once the svUnit package is installed in R. We will be happy to receive comments, bug reports and other suggestions during this beta test. Use the bug and suggestions tracker on: https://r-forge.r-project.org/tracker/?group_id=194 Otherwise, I plan to submit an abstract about svUnit to User!2009 soon. All the best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Tobias Verbeke wrote: Jose Quesada wrote: Hi, I wonder what kind of interest there is on Test Driven Development (TDD) in R. Test Driven Development consists of writing the test before the function, and iteratively build the function until it passes the test. Python and Ruby (specially Ruby) have very strong test-oriented cultures. In fact, in Ruby at least the custom is to do TDD and lately Behavior-driven development (BDD). In BDD, one writes a story of what one would want the code to do. This story is almost native English, and then the test suite converts it into something that the language understand as tests. There are some posts on the list about this, but they are about testing in general (Runit), not TDD. Example: http://thread.gmane.org/gmane.comp.lang.r.general/85047 Recently, I found there is an alpha, but working implementation of TDD for Komodo edit: www.sciviews.org/SciViews-K/index.html The editor has a green bar that becomes red as soon as one edits a function, and that edit breaks the tests. This is tremendously useful. Using Gmane search, the only mention I could find on svUnit was: http://thread.gmane.org/gmane.comp.lang.r.general/136632/focus=136662 I think this could make a great UseR 2009 talk. Ideally, by someone with more R experience than me, and even more ideally by Philippe Grosjean :), but it push comes to shove, I could prepare such a talk. Would this be interesting at all? Are there any resources that I have missed? There is the RUnit package which is a mature xUnit implementation for R. I don't know of a tight integration into an editor (apart from that it is _planned_ for StatET, the Eclipse R plug-in), but as such it is very useful already. http://cran.r-project.org/web/packages/RUnit/index.html HTH, Tobias __ 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
Re: [R] test individual values in rows
keep <- apply( DATA, 1, min ) >= 100 DATA <- DATA[ keep, ] See ?apply for more. Gabor On Fri, Mar 14, 2008 at 01:26:49PM +, IAIN GALLAGHER wrote: > Hi list. > > I have a numerical dataset 22,000 rows deep and 43 columns wide. I would like > to remove those rows which contain only values less than 100 (ie if any value > in the row is greater than 100 the row stays in the dataset). I am unsure how > to test each individual value across the rows and then identify the rows > which meet my criteria. > > Can anyone help? > > Thank you. > > Iain > > [[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. -- Csardi Gabor <[EMAIL PROTECTED]>UNIL DGM __ 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] test individual values in rows
If your data.frame is completely numeric, this is easy. If your data.frame is called df, then do df[apply(df, 1, function(x) !all(x < 100)),] Look at ?apply Best, Erik Iverson IAIN GALLAGHER wrote: > Hi list. > > I have a numerical dataset 22,000 rows deep and 43 columns wide. I would like > to remove those rows which contain only values less than 100 (ie if any value > in the row is greater than 100 the row stays in the dataset). I am unsure how > to test each individual value across the rows and then identify the rows > which meet my criteria. > > Can anyone help? > > Thank you. > > Iain > > [[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. __ 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] test individual values in rows
Of course, it might be clearer if instead of !all(x < 100) I had put, any(x > 100) Erik Iverson wrote: > If your data.frame is completely numeric, this is easy. > > If your data.frame is called df, then do > > df[apply(df, 1, function(x) !all(x < 100)),] > > Look at ?apply > > Best, > Erik Iverson > > IAIN GALLAGHER wrote: >> Hi list. >> >> I have a numerical dataset 22,000 rows deep and 43 columns wide. I would >> like to remove those rows which contain only values less than 100 (ie if any >> value in the row is greater than 100 the row stays in the dataset). I am >> unsure how to test each individual value across the rows and then identify >> the rows which meet my criteria. >> >> Can anyone help? >> >> Thank you. >> >> Iain >> >> [[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. > > __ > 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] Test for multiple comparisons: Nonlinear model, autocorrelation?
The question seems too general for me to offer specific suggestions. What problem are you trying to solve that you think 'multiple comparisons' will answer? Can you produce a similar problem that is completely self-contained example that eliminates complexity that may not be needed to understand your question (similar to the 'Auxiliary Problem' technique in "How to Solve It", http://en.wikipedia.org/wiki/How_to_Solve_It)? If you can, it may lead you to a solution. If you get such an example but still can't see a solution, send that example to this list (following the advice in the posting guide http://www.R-project.org/posting-guide.html). The simpler the example, the more likely someone on this list will reply quickly with a useful suggestion. I know this doesn't solve your problem, but I hope it helps. Spencer J S wrote: Dear R community, I have a nonlinear model describing average daily soil temperature. What test should I use to compare differences in soil temperature of the two studied vegetation types depending upon month? Building linear contrasts for the developed nonlinear model does not help since this model does not include variable “Months” (only “Days”). 1) Just a Student’s test is not probably an option because I would violate an assumption of independency, since the daily soil temperature observations have high autocorrelation. Or maybe I could average the observations for each month and then use this test since I have observations for a few years, and it might overcome the problem of independency? 2) Should I develop a second nonlinear model with months instead of days, but it would considerably increase a number of parameters in the model... Or: 3) ? Thanks for your help, Julia _ It’s a talkathon – but it’s not just talk. [[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. __ 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] Test for multiple comparisons: Nonlinear model, autocorrelation?
Thanks. Here is a similar example from a book by Pinheiro and Bates (2000, chapter 6): library(nlme) data(Soybean) fm1Soy.lis <- nlsList( weight ~ SSlogis(Time, Asym, xmid, scal),data = Soybean ) fm1Soy.nlme <- nlme( fm1Soy.lis ) If we would like to make comparisons among the years we could just simply involve years as a covariate, and later we could use L argument to ANOVA to could compute contrasts. soyFix <- fixef( fm1Soy.nlme ) fm2Soy.nlme <- update( fm1Soy.nlme,fixed = Asym + xmid + scal ~ Year,start = c(soyFix[1], 0, 0, soyFix[2], 0, 0, soyFix[3], 0, 0) ) My question is: How can I compare variety of soybeans in a separate month, i.e. if there was a difference in weight of soybeans F and P in first month, in twelve month? The dataset Soybean: Plot Variety Year Timeweight 1 1988F1 F 1988 14 0.106000 2 1988F1 F 1988 21 0.261000 3 1988F1 F 1988 28 0.666000 4 1988F1 F 1988 35 2.11 5 1988F1 F 1988 42 3.56 . 407 1990P8 P 1990 30 1.478330 408 1990P8 P 1990 37 2.601667 409 1990P8 P 1990 43 6.343330 410 1990P8 P 1990 51 6.131670 411 1990P8 P 1990 64 16.411700 412 1990P8 P 1990 79 16.946700 1) Involving months and variety as a covariates will probably create too many parameters for the model? 2) Is it possible to use some test for comparisons, lets say t test? Perhaps not in case the data are dependent (i.e. previous measurement is dependent on the next measurement, i.e. there is temporal correlation (as in my study of Soil temperature)? What is an alternative suggestion? Thanks, Julia> Date: Fri, 4 Jul 2008 17:36:29 -0700> From: [EMAIL PROTECTED]> To: [EMAIL PROTECTED]> CC: r-help@r-project.org> Subject: Re: [R] Test for multiple comparisons: Nonlinear model, autocorrelation?> > The question seems too general for me to offer specific suggestions.> > What problem are you trying to solve that you think 'multiple > comparisons' will answer?> > Can you produce a similar problem that is completely self-contained > example that eliminates complexity that may not be needed to understand > your question (similar to the 'Auxiliary Problem' technique in "How to > Solve It", http://en.wikipedia.org/wiki/How_to_Solve_It)? If you can, it > may lead you to a solution. If you get such an example but still can't > see a solution, send that example to this list (following the advice in > the posting guide http://www.R-project.org/posting-guide.html). The > simpler the example, the more likely someone on this list will reply > quickly with a useful suggestion.> > I know this doesn't solve your problem, but I hope it helps.> Spencer> > J S wrote:> > Dear R community, > > > > I have a nonlinear model describing average daily soil temperature. What test should I use to compare differences in soil temperature of the two studied vegetation types depending upon month?> > > > Building linear contrasts for the developed nonlinear model does not help since this model does not include variable Months (only Days). > > > > 1) Just a Students test is not probably an option because I would violate an assumption of independency, since the daily soil temperature observations have high autocorrelation. Or maybe I could average the observations for each month and then use this test since I have observations for a few years, and it might overcome the problem of independency?> > > > 2) Should I develop a second nonlinear model with months instead of days, but it would considerably increase a number of parameters in the model...> > > > Or:> > 3) ?> > > > Thanks for your help,> > Julia> > _> > Its a talkathon but its not just talk.> >> > [[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.> > _ The im Talkaton. Can 30-days of conversation change the world? [[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.
Re: [R] Test for multiple comparisons: Nonlinear model, autocorrelation?
If I had only a very limited time to do this, I might include 'month' as another effect, probably coded as 'sin' and 'cos' on an annual cycle rather than as 12 individual Indicators. This would allow you to explore not only main effects but interactions with plots. Before I did that, however, I'd want to generate more plots of data, residuals, and coefficients. For example, qqnorm(resid(fm1Soy.nlme), datax=TRUE) displayed an S shape that indicated inhomogeniety of variance. This suggests that there is something else to be modeled in these data. I would next try plotting residuals by 'month'. I'd also plot the averages and standard deviations by 'month'. This might tell me if I only need to add a fixed annual cycle, and how much of a Fourier series approximation to add. If the standard deviations show a pattern, it suggests I need to model heteroscedasticity. For that see '?varClasses' and the corresponding information in a book by Pinheiro and Bates (2000), mentioned on that help page. You can do 'anova' for any of these effects. [To test changes in fixed effects, you will need to use method='ML', as discussed in a book by Pinheiro and Bates (2000).] Hope this helps. Spencer J S wrote: Thanks. Here is a similar example from a book by Pinheiro and Bates (2000, chapter 6): library(nlme) data(Soybean) fm1Soy.lis <- nlsList( weight ~ SSlogis(Time, Asym, xmid, scal), data = Soybean ) fm1Soy.nlme <- nlme( fm1Soy.lis ) *If we would like to make comparisons among the years we could just simply involve years as a covariate, and later we could use L argument to ANOVA to could compute contrasts. * soyFix <- fixef( fm1Soy.nlme ) fm2Soy.nlme <- update( fm1Soy.nlme, fixed = Asym + xmid + scal ~ Year, start = c(soyFix[1], 0, 0, soyFix[2], 0, 0, soyFix[3], 0, 0) ) * * *My question is: How can I compare variety of soybeans in a separate month, i.e. if there was a difference in weight of soybeans F and P in first month, …in twelve month?* The dataset “Soybean”: Plot Variety Year Timeweight 1 1988F1 F 1988 14 0.106000 2 1988F1 F 1988 21 0.261000 3 1988F1 F 1988 28 0.666000 4 1988F1 F 1988 35 2.11 5 1988F1 F 1988 42 3.56 …. 407 1990P8 P 1990 30 1.478330 408 1990P8 P 1990 37 2.601667 409 1990P8 P 1990 43 6.343330 410 1990P8 P 1990 51 6.131670 411 1990P8 P 1990 64 16.411700 412 1990P8 P 1990 79 16.946700 1) Involving months and variety as a covariates will probably create too many parameters for the model? 2) Is it possible to use some test for comparisons, let’s say t test? Perhaps not in case the data are dependent (i.e. previous measurement is dependent on the next measurement, i.e. there is temporal correlation (as in my study of Soil temperature)? What is an alternative suggestion? Thanks, Julia > Date: Fri, 4 Jul 2008 17:36:29 -0700 > From: [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > CC: r-help@r-project.org > Subject: Re: [R] Test for multiple comparisons: Nonlinear model, autocorrelation? > > The question seems too general for me to offer specific suggestions. > > What problem are you trying to solve that you think 'multiple > comparisons' will answer? > > Can you produce a similar problem that is completely self-contained > example that eliminates complexity that may not be needed to understand > your question (similar to the 'Auxiliary Problem' technique in "How to > Solve It", http://en.wikipedia.org/wiki/How_to_Solve_It)? If you can, it > may lead you to a solution. If you get such an example but still can't > see a solution, send that example to this list (following the advice in > the posting guide http://www.R-project.org/posting-guide.html). The > simpler the example, the more likely someone on this list will reply > quickly with a useful suggestion. > > I know this doesn't solve your problem, but I hope it helps. > Spencer > > J S wrote: > > Dear R community, > > > > I have a nonlinear model describing average daily soil temperature. What test should I use to compare differences in soil temperature of the two studied vegetation types depending upon month? > > > > Building linear contrasts for the developed nonlinear model does not help since this model does not include variable “Months” (only “Days”). > > > > 1) Just a Student’s test is not probably an option because I would violate an assumption of independency, since the daily soil temperature observations have high autocorrelation. Or maybe I could average the observations for each month and then use this test since I have
Re: [R] Test for multiple comparisons: Nonlinear model, autocorrelation?
Thanks for your help and suggestions. Thats exactly what I did, i.e. a sin () and cos () code using daily observations of soil temperature, and putting a variable vegetation types as a covariate. Therefore, I can build contrasts to compare parameters of the model such as an intercept, amplitude and phase between different vegetation types. If I understand correctly, you mean to do the similar model but using average monthly data of soil temperature instead of daily soil temperature? Still, I think that the model will allow us comparison of the parameters of the model such as an intercept, amplitude and phase between the vegetation types, but not the monthly soil temperature between different vegetation types Thanks for your help and I am sorry if I did not understand it correctly or did not describe the experiment clearly. Julia> Date: Sun, 6 Jul 2008 08:38:51 -0700> From: [EMAIL PROTECTED]> To: [EMAIL PROTECTED]> CC: r-help@r-project.org> Subject: Re: [R] Test for multiple comparisons: Nonlinear model, autocorrelation?> > If I had only a very limited time to do this, I might include > 'month' as another effect, probably coded as 'sin' and 'cos' on an > annual cycle rather than as 12 individual Indicators. This would allow > you to explore not only main effects but interactions with plots. > > Before I did that, however, I'd want to generate more plots of > data, residuals, and coefficients. For example, > qqnorm(resid(fm1Soy.nlme), datax=TRUE) displayed an S shape that > indicated inhomogeniety of variance. This suggests that there is > something else to be modeled in these data. I would next try plotting > residuals by 'month'. I'd also plot the averages and standard > deviations by 'month'. This might tell me if I only need to add a fixed > annual cycle, and how much of a Fourier series approximation to add. If > the standard deviations show a pattern, it suggests I need to model > heteroscedasticity. For that see '?varClasses' and the corresponding > information in a book by Pinheiro and Bates (2000), mentioned on that > help page. You can do 'anova' for any of these effects. [To test > changes in fixed effects, you will need to use method='ML', as discussed > in a book by Pinheiro and Bates (2000).]> > Hope this helps. > Spencer> > J S wrote:> >> > Thanks. Here is a similar example from a book by Pinheiro and Bates > > (2000, chapter 6):> >> > > >> > library(nlme)> > data(Soybean)> >> > fm1Soy.lis <- nlsList( weight ~ SSlogis(Time, Asym, xmid, scal),> > data = Soybean )> > fm1Soy.nlme <- nlme( fm1Soy.lis )> >> > > >> > *If we would like to make comparisons among the years we could just > > simply involve years as a covariate, and later we could use L argument > > to ANOVA to could compute contrasts. *> >> > > >> > soyFix <- fixef( fm1Soy.nlme )> > fm2Soy.nlme <- update( fm1Soy.nlme,> > fixed = Asym + xmid + scal ~ Year,> > start = c(soyFix[1], 0, 0, soyFix[2], 0, 0, soyFix[3], 0, 0) )> >> > * *> >> > *My question is: How can I compare variety of soybeans in a separate > > month, i.e. if there was a difference in weight of soybeans F and P in > > first month, in twelve month?*> >> > > >> > The dataset Soybean:> >> > Plot Variety Year Time weight> >> > 1 1988F1 F 1988 14 0.106000> >> > 2 1988F1 F 1988 21 0.261000> >> > 3 1988F1 F 1988 28 0.666000> >> > 4 1988F1 F 1988 35 2.11> >> > 5 1988F1 F 1988 42 3.56> >> > .> >> > 407 1990P8 P 1990 30 1.478330> >> > 408 1990P8 P 1990 37 2.601667> >> > 409 1990P8 P 1990 43 6.343330> >> > 410 1990P8 P 1990 51 6.131670> >> > 411 1990P8 P 1990 64 16.411700> >> > 412 1990P8 P 1990 79 16.946700> >> > > >> > 1) Involving months and variety as a covariates will probably > > create too many parameters for the model?> >> > 2) Is it possible to use some test for comparisons, lets say t > > test? Perhaps not in case the data are dependent (i.e. previous > > measurement is dependent on the next measurement, i.e. there is > > temporal correlation (as in my study of Soil temperature)? What is an > > alternative suggestion?> >> > > >> > Thanks,> >> > Julia> >> >> >> > > Date: Fri, 4 Jul 2008 17:36:29 -0700> > > From: [EMAIL PROTECTED]> > > To: [EMAIL PROTECTED]> > > CC: r-help@r-project.org> >
Re: [R] test two correlation coefficients against each other
Martin, See r.test in the psych package. This will probably do what you want to do. Bill At 1:29 AM +0100 3/11/09, Martin Batholdy wrote: hi, is there a function in R that calculates the probability that two correlation coefficients are from the same population? thanks! __ 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. -- William Revelle http://personality-project.org/revelle.html Professor http://personality-project.org/personality.html Department of Psychology http://www.wcas.northwestern.edu/psych/ Northwestern University http://www.northwestern.edu/ Use R for psychology http://personality-project.org/r __ 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] Test for equality of complicatedly related average correlations
Hi Ralph, I had the same problem you do a few months ago, and realized that the question I had (does time show a different effect for X than Y) was not best modeled as differences between correlations across individuals, but as whether time interacts with condition. I answered this question with library(nlme) lme(obs ~ cond*time, random=~cond*time|subj) ...where obs is the responses on the X or Y variable, cond is a factor of either X or Y, and subj is your subject variable. This fits a heirarchical linear model to the data. The relationship between X and time is sig. diff. from the relationship between Y and time if the cond:time fixed effect is true. This approach makes better use of your data, because when you correlate the observations, you're effectively "losing" variability (because correlations are doubly standardized) as well as degrees of freedom (you have 9 df within each individual, but each correlation is only one number). --Adam On Sat, 6 Sep 2008, Ralph79 wrote: Dear R-Users, I am currently looking for a way to test the equality of two correlations that are related in a very special way. Let me describe the situation with an example. - There are 100 respondents, and there are 2 points in time, t=1 and t=2. - For each of the respondents and at each of the time points, I have information on 10 X-variables and on 10 Y-variables. - Based on this information, I calculate two correlations for each respondent: cor(X[t=1],X[t=2]) and cor(Y[t=1],Y[t=2]), with X and Y being the vectors of the corresponding 10 variables. - Now I get the average correlations over the whole sample using Fishers Z-transformation, i.e. I have mean(cor(X[t=1],X[t=2])) and mean(cor(X[t=1],X[t=2])) and want to know if the mean correlations are significantly different! I haven't found any test that deals with exactly my situation. Therefore, I "simply" apply a paired t-test based on the individual z-correlations. From my point of view this should be ok, because of the z's normality. However, I am unsure if there is a better way to test the hypothesis that I am interested in? I'd be grateful for any comment or hint. Thank you very much, Ralph - Ralph Wirth University Erlangen-Nuremberg, Chair of Statistics GfK Group, Department of Methods and Product Development -- View this message in context: http://www.nabble.com/Test-for-equality-of-complicatedly-related-average-correlations-tp19346312p19346312.html Sent from the R help mailing list archive at Nabble.com. __ 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] Test for equality of complicatedly related average correlations
Thank you very much, Adam. I have to get a bit more familiar with the model you propose in order to understand if it applies to my problem as well. My question is not really "does time show a different effect" but "which one of two measures is more reliable": My respondents have completed exactly the same questionnaire twice (t=1 and t=2). The questionnaire consisted of two ways of measuring attribute importance, and the "better" method of measuring these importances is the one that gives the same importances for each respondent in t=1 and t=2. In other words: I want to examine test-retest reliability of the two measures. Naturally, if X(t=1,t=2)-correlation is higher for a specific respondent than the Y(t=1,t=2)-corralation, than for this respondent the method that yields the X-importances is more reliable. All I want to do is to see if this holds for the whole sample as well... Anyway, thank you again, I will think of your approach. Ralph Adam D. I. Kramer-3 wrote: > > Hi Ralph, > > I had the same problem you do a few months ago, and realized that > the question I had (does time show a different effect for X than Y) was > not > best modeled as differences between correlations across individuals, but > as > whether time interacts with condition. > > I answered this question with >> library(nlme) >> lme(obs ~ cond*time, random=~cond*time|subj) > > ...where obs is the responses on the X or Y variable, cond is a factor of > either X or Y, and subj is your subject variable. This fits a heirarchical > linear model to the data. The relationship between X and time is sig. > diff. > from the relationship between Y and time if the cond:time fixed effect is > true. > > This approach makes better use of your data, because when you correlate > the > observations, you're effectively "losing" variability (because > correlations > are doubly standardized) as well as degrees of freedom (you have 9 df > within > each individual, but each correlation is only one number). > > --Adam > > On Sat, 6 Sep 2008, Ralph79 wrote: > >> >> Dear R-Users, >> >> I am currently looking for a way to test the equality of two correlations >> that are related in a very special way. Let me describe the situation >> with >> an example. >> >> - There are 100 respondents, and there are 2 points in time, t=1 and t=2. >> >> - For each of the respondents and at each of the time points, I have >> information on 10 X-variables and on 10 Y-variables. >> >> - Based on this information, I calculate two correlations for each >> respondent: cor(X[t=1],X[t=2]) and cor(Y[t=1],Y[t=2]), with X and Y being >> the vectors of the corresponding 10 variables. >> >> - Now I get the average correlations over the whole sample using Fishers >> Z-transformation, i.e. I have mean(cor(X[t=1],X[t=2])) and >> mean(cor(X[t=1],X[t=2])) and want to know if the mean correlations are >> significantly different! >> >> >> I haven't found any test that deals with exactly my situation. Therefore, >> I >> "simply" apply a paired t-test based on the individual z-correlations. >> From >> my point of view this should be ok, because of the z's normality. >> However, I >> am unsure if there is a better way to test the hypothesis that I am >> interested in? >> >> I'd be grateful for any comment or hint. >> >> Thank you very much, >> >> Ralph >> >> - >> Ralph Wirth >> University Erlangen-Nuremberg, Chair of Statistics >> GfK Group, Department of Methods and Product Development >> >> -- >> View this message in context: >> http://www.nabble.com/Test-for-equality-of-complicatedly-related-average-correlations-tp19346312p19346312.html >> Sent from the R help mailing list archive at Nabble.com. >> >> __ >> 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. > > - Ralph Wirth University Erlangen-Nuremberg, Chair of Statistics GfK Group, Department of Methods and Product Development -- View this message in context: http://www.nabble.com/Test-for-equality-of-complicatedly-related-average-correlations-tp19346312p19355825.html Sent from the R help mailing list archive at Nabble.com. __ 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] Test for equality of complicatedly related average correlations
Hi Ralph, My approach provides the same answer by asking a different question. Effectively, my approach tests whether the difference between timepoints is larger for X than for Y (and also gives you the main effects of whether X has a higher mean than Y and whether scores increase or decrease over time, which may or may not be of interest but as control variables serve the same purpose as using correlations rather than difference scores). One objection to this mode of comparing test-retest reliabilities is that one test may be more variable over time (at the item level) than the other, but that the overall means don't differ...but the correlational approch you asked about also suffers from this problem. --Adam On Sun, 7 Sep 2008, Ralph79 wrote: I have to get a bit more familiar with the model you propose in order to understand if it applies to my problem as well. My question is not really "does time show a different effect" but "which one of two measures is more reliable": My respondents have completed exactly the same questionnaire twice (t=1 and t=2). The questionnaire consisted of two ways of measuring attribute importance, and the "better" method of measuring these importances is the one that gives the same importances for each respondent in t=1 and t=2. In other words: I want to examine test-retest reliability of the two measures. Naturally, if X(t=1,t=2)-correlation is higher for a specific respondent than the Y(t=1,t=2)-corralation, than for this respondent the method that yields the X-importances is more reliable. All I want to do is to see if this holds for the whole sample as well... Anyway, thank you again, I will think of your approach. Ralph Adam D. I. Kramer-3 wrote: Hi Ralph, I had the same problem you do a few months ago, and realized that the question I had (does time show a different effect for X than Y) was not best modeled as differences between correlations across individuals, but as whether time interacts with condition. I answered this question with library(nlme) lme(obs ~ cond*time, random=~cond*time|subj) ...where obs is the responses on the X or Y variable, cond is a factor of either X or Y, and subj is your subject variable. This fits a heirarchical linear model to the data. The relationship between X and time is sig. diff. from the relationship between Y and time if the cond:time fixed effect is true. This approach makes better use of your data, because when you correlate the observations, you're effectively "losing" variability (because correlations are doubly standardized) as well as degrees of freedom (you have 9 df within each individual, but each correlation is only one number). --Adam On Sat, 6 Sep 2008, Ralph79 wrote: Dear R-Users, I am currently looking for a way to test the equality of two correlations that are related in a very special way. Let me describe the situation with an example. - There are 100 respondents, and there are 2 points in time, t=1 and t=2. - For each of the respondents and at each of the time points, I have information on 10 X-variables and on 10 Y-variables. - Based on this information, I calculate two correlations for each respondent: cor(X[t=1],X[t=2]) and cor(Y[t=1],Y[t=2]), with X and Y being the vectors of the corresponding 10 variables. - Now I get the average correlations over the whole sample using Fishers Z-transformation, i.e. I have mean(cor(X[t=1],X[t=2])) and mean(cor(X[t=1],X[t=2])) and want to know if the mean correlations are significantly different! I haven't found any test that deals with exactly my situation. Therefore, I "simply" apply a paired t-test based on the individual z-correlations. From my point of view this should be ok, because of the z's normality. However, I am unsure if there is a better way to test the hypothesis that I am interested in? I'd be grateful for any comment or hint. Thank you very much, Ralph - Ralph Wirth University Erlangen-Nuremberg, Chair of Statistics GfK Group, Department of Methods and Product Development -- View this message in context: http://www.nabble.com/Test-for-equality-of-complicatedly-related-average-correlations-tp19346312p19346312.html Sent from the R help mailing list archive at Nabble.com. __ 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. - Ralph Wirth University Erlangen-Nuremberg, Chair of Statistics GfK Group, Department of Methods and Product Development -- View this message in context: http://www.nabble.com/Test-for-equalit
Re: [R] test for the variance of a normal population
Dear Alexandra, Perhaps you can use a different approach but I think it works: # Chi-suared CI var.ci=function(x,alpha=0.05){ n=length(x)-sum(is.na(x)) s2=var(x,na.rm=T) li=s2*(n-1)/qchisq(1-alpha/2,n-1) ls=s2*(n-1)/qchisq(alpha/2,n-1) c(li,ls) } # Example set.seed(123) y=rnorm(1000,25,2) var.ci(y) # 3.610426 4.302965 # Bootstrap CI var.bs=function(x,FUN=var,alpha=0.05,NSIM=1000){ temp=matrix(rep(x,NSIM),ncol=NSIM) temp2=apply(temp,2,sample,replace=TRUE) vars=apply(temp2,2,var) quantile(vars,probs=c(alpha/2,1-alpha/2)) } var.bs(y) # 3.618220 4.274773 I hope this helps, -- JIV On Mon, Apr 7, 2008 at 10:13 AM, Alexandra Ramos <[EMAIL PROTECTED]> wrote: > Hi, > > > > Does anyone know an instruction to perform a test (or to construct a > confidence interval) for the variance of a normal population (distribution). > > The test statistic is (n-1)*S´^2/sigma^2 and has chi square (n-1) > distribution. > > > > Thank you, > > Alexandra > > > > > > >[[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. > > [[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.
Re: [R] test for whether dataset comes from a known MVN
Campbell, Desmond wrote: > > Dear all, > > > > I have a multivariate dataset containing 100,000 or more points. > > I want find the p-value for the dataset of points coming from a > particular multivariate normal distribution > > With > > mean vector u > > Covariance matrix s2 > > So > > H0: points ~ MVN( u, s2) > > H1: points not ~ MVN( u, s2) > > How do I find the p-value in R? > > > Googling for "Shapiro-Wilk multivariate" brings up mshapiro.test() in the mvnormtest package. However, I would strongly suspect that if your data are from the real world that you will reject the null hypothesis of multivariate normality when you have 100,000 points -- the power to detect tiny (unimportant?) deviations from MVN will be very high. cheers Ben Bolker -- View this message in context: http://www.nabble.com/test-for-whether-dataset-comes-from-a-known-MVN-tf4607009.html#a13155278 Sent from the R help mailing list archive at Nabble.com. __ 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] test for whether dataset comes from a known MVN
Desmond Campbell wrote: > > Dear Ben Bolker, > > Thanks for replying and offering advice, unfortunately it doesn't solve my > problem. > > 1) The mshapiro.test() in the mvnormtest package appears only applicable > for datasets containing 3-5000 samples, whereas my dataset contains > 100,000 > samples. > > 2) As you said in your email if my data is from the real world then any > test is likely to reject the null hypothesis, because of the power of such > a > large dataset. > > However my data is not from the real world. I am conducting validation > studies, and if the program I am testing is working correctly then the > dataset > will be perfectly normally distributed. > > Thanks anyway. > > I would be tempted in this case to contact the package author and find out what limits the size of the input data set. It does look like the method requires a matrix inversion, in which case you might be in big trouble (if it were sparse you could see if you could substitute in SparseM functions, but I kind of doubt it would be ...). Do you know if anyone has come up with a method that will do this test for this size data set? i.e., is this a problem of developing a statistical method or a problem of implementation in R? (Are the methods discussed in http://support.sas.com/ctx/samples/index.jsp?sid=480 or http://interstat.statjournals.net/YEAR/2003/articles/0301001.pdf such as Mardia's multivariate skew or kurtosis appropriate and less numerically intensive? I don't know how to calculate MV skew, and R site search brings up a lot about the MV skew-normal distribution but not a lot about MV skew itself. I found an SPSS macro http://www.columbia.edu/~ld208/Mardia.sps but that's as far as I got.) Do you have to test the whole data set at once? Could you hack it by testing subsets of the data and (e.g.) using Fisher's combined p values? cheers Ben Bolker -- View this message in context: http://www.nabble.com/test-for-whether-dataset-comes-from-a-known-MVN-tf4609195.html#a13177063 Sent from the R help mailing list archive at Nabble.com. __ 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] test for existance of a method for given class
On Wed, 14 Nov 2007, William Valdar wrote: > Dear All, > > I want to test whether a method exists for given object. For example, > whether a function "deviance" is defined for an object of the "lm" class. For an S3 generic 'f' and with an S3 object or an S3 class 'x', try hasS3method <- function(f, x) { if(is.object(x)) x <- oldClass(x) m <- methods(f) cl <- sub(paste("^", f, ".", sep=""), "", m) any(c("default", x) %in% cl) } (You can break this, e.g. by f="resid" or using implicit classes: it needs inside knowledge to know if the latter would be invoked. Also, the set of available methods is in principle scope-specific.) For S4 generics and classes, look at selectMethod(optional=TRUE): this is documented to return NULL if and only if there is no applicable method. > My imperfect understanding leads me to think something like > > hasMethod("deviance", object) > hasMethod("deviance", "lm") > existsMethod("deviance", signature(class="lm")) > > or similar might work (I don't fully understand how to manipulate > signatures), but all the variations on this I have tried return FALSE. > (Except, interestingly, when I first load library lme4, after which all > return TRUE even for non-existant classes and functions). > > I realize there are several ways in which R implements function > polymorphism and that this is all documented somewhere but a hint would > save me considerable time. I would also prefer not to resort to the hack > solution of try()ing the function with the object and then catching the > error to determine whether it was defined. > > Thanks, > > Will > > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > Dr William Valdar ++44 (0)1865 287 589 > Wellcome Trust Centre [EMAIL PROTECTED] > for Human Genetics, Oxford www.well.ox.ac.uk/~valdar -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] test for existance of a method for given class
Thanks Brian, that helps a lot. For others interested, a few variants for testing existance of methods are below: # modified sub/grep of BDR's example hasS3method.1 <- function(f, x) { if(is.object(x)) x <- oldClass(x) m <- methods(f) pattern <- paste("^", f, ".", sep="") cl <- sub(pattern, "", grep(pattern, m, value=TRUE)) any(c("default", x) %in% cl) } # almost equivalently... hasS3method.2 <- function(f, x, include.default=TRUE) { if(is.object(x)) x <- oldClass(x) !is.null(getS3method(f, x, optional=TRUE)) } hasS4method <- function(f, x) { if (is.object(x)) x <- class(x) for (cl in x) { m <- selectMethod(f, signature(object=cl), optional=TRUE) if (!is.null(m)) return (TRUE) } FALSE } Will On Wed, 14 Nov 2007, Prof Brian Ripley wrote: > On Wed, 14 Nov 2007, William Valdar wrote: > >> Dear All, >> >> I want to test whether a method exists for given object. For example, >> whether a function "deviance" is defined for an object of the "lm" class. > > For an S3 generic 'f' and with an S3 object or an S3 class 'x', try > > hasS3method <- function(f, x) > { >if(is.object(x)) x <- oldClass(x) >m <- methods(f) >cl <- sub(paste("^", f, ".", sep=""), "", m) >any(c("default", x) %in% cl) > } > > (You can break this, e.g. by f="resid" or using implicit classes: it needs > inside knowledge to know if the latter would be invoked. Also, the set of > available methods is in principle scope-specific.) > > For S4 generics and classes, look at selectMethod(optional=TRUE): this is > documented to return NULL if and only if there is no applicable method. > > >> My imperfect understanding leads me to think something like >> >> hasMethod("deviance", object) >> hasMethod("deviance", "lm") >> existsMethod("deviance", signature(class="lm")) >> >> or similar might work (I don't fully understand how to manipulate >> signatures), but all the variations on this I have tried return FALSE. >> (Except, interestingly, when I first load library lme4, after which all >> return TRUE even for non-existant classes and functions). >> >> I realize there are several ways in which R implements function >> polymorphism and that this is all documented somewhere but a hint would >> save me considerable time. I would also prefer not to resort to the hack >> solution of try()ing the function with the object and then catching the >> error to determine whether it was defined. >> >> Thanks, >> >> Will >> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Dr William Valdar ++44 (0)1865 287 589 Wellcome Trust Centre [EMAIL PROTECTED] for Human Genetics, Oxford www.well.ox.ac.uk/~valdar __ 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] Test for stochastic dominance, non-inferiority test for distributions
Look for Russell Davidson's work, e.g. this: http://www.citeulike.org/user/ctacmo/article/3681756, easily googlable for more. On Mon, Aug 31, 2009 at 1:04 PM, Matthias Gondan wrote: > Dear R-Users, > > Is anyone aware of a significance test which allows > demonstrating that one distribution dominates another? > > Let F(t) and G(t) be two distribution functions, the > alternative hypothesis would be something like: > > F(t) >= G(t), for all t > > null hypothesis: F(t) < G(t), for some t. > > > Best wishes, > > Matthias > > > PS. This one would be ok, as well: > > F(t) > G(t), for all t > > null hypothesis: F(t) <= G(t), for some t. > > -- > GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! > > __ > 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. > -- Stas Kolenikov, also found at http://stas.kolenikov.name Small print: I use this email account for mailing lists only. __ 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] test if all predictors in a glm object are factors
on 09/03/2008 04:56 PM Michael Friendly wrote: > I'm trying to develop some graphic methods for glm objects, but they > only apply for models > where all predictors are discrete factors. How can I test for this in a > function, given the > glm model object? > > That is, I want something that will serve as an equivalent of > is.discrete.glm() in the following > context: > > myplot.glm <- > function(model, ...) { >if (!inherits(model,"glm")) stop("requires a glm object") >if (!is.discrete.glm(model)) stop("only factors are allowed") > ... > } > > A small example, for count data, a poisson glm: > > GSS <- data.frame( > expand.grid(sex=c("female", "male"), party=c("dem", "indep", "rep")), > count=c(279,165,73,47,225,191)) > > mod.glm <- glm(count ~ sex + party, family = poisson, data = GSS) > > So, the model terms are sex and party, both factors. Peeking inside > mod.glm, I > can find > >> mod.glm$xlevels > $sex > [1] "female" "male" > $party > [1] "dem" "indep" "rep" > and, in str(mod.glm$model) I see > >> str(mod.glm$model) > 'data.frame': 6 obs. of 3 variables: > $ count: num 279 165 73 47 225 191 > $ sex : Factor w/ 2 levels "female","male": 1 2 1 2 1 2 > $ party: Factor w/ 3 levels "dem","indep",..: 1 1 2 2 3 3 > - attr(*, "terms")=Classes 'terms', 'formula' length 3 count ~ sex + party > > > so this is a keeper. Can someone help me improve on the following > is.discrete.glm() function. > It works for mod.glm, but isn't very general ;-) > > is.discrete.glm <- function(model) { >TRUE > } > Michael, How about something like this: is.discrete.glm <- function(model) { all(attr(terms(model), "dataClasses")[-1] == "factor") } Essentially, take the output of terms(model), check the 'dataClasses' attribute, except for the first element, which is the DV. > is.discrete.glm(mod.glm) [1] TRUE HTH, Marc Schwartz __ 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] test if all predictors in a glm object are factors
On Wed, 3 Sep 2008, Marc Schwartz wrote: on 09/03/2008 04:56 PM Michael Friendly wrote: I'm trying to develop some graphic methods for glm objects, but they only apply for models where all predictors are discrete factors. How can I test for this in a Is an ordered factor a 'discrete factor'? I suspect it is, so this needs to be is.discrete.glm <- function(model) all(attr(terms(model), "dataClasses")[-1] %in% c("factor", "ordered")) (removing redundant braces). function, given the glm model object? That is, I want something that will serve as an equivalent of is.discrete.glm() in the following context: myplot.glm <- function(model, ...) { if (!inherits(model,"glm")) stop("requires a glm object") if (!is.discrete.glm(model)) stop("only factors are allowed") ... } A small example, for count data, a poisson glm: GSS <- data.frame( expand.grid(sex=c("female", "male"), party=c("dem", "indep", "rep")), count=c(279,165,73,47,225,191)) mod.glm <- glm(count ~ sex + party, family = poisson, data = GSS) So, the model terms are sex and party, both factors. Peeking inside mod.glm, I can find mod.glm$xlevels $sex [1] "female" "male" $party [1] "dem" "indep" "rep" and, in str(mod.glm$model) I see str(mod.glm$model) 'data.frame': 6 obs. of 3 variables: $ count: num 279 165 73 47 225 191 $ sex : Factor w/ 2 levels "female","male": 1 2 1 2 1 2 $ party: Factor w/ 3 levels "dem","indep",..: 1 1 2 2 3 3 - attr(*, "terms")=Classes 'terms', 'formula' length 3 count ~ sex + party so this is a keeper. Can someone help me improve on the following is.discrete.glm() function. It works for mod.glm, but isn't very general ;-) is.discrete.glm <- function(model) { TRUE } Michael, How about something like this: is.discrete.glm <- function(model) { all(attr(terms(model), "dataClasses")[-1] == "factor") } Essentially, take the output of terms(model), check the 'dataClasses' attribute, except for the first element, which is the DV. is.discrete.glm(mod.glm) [1] TRUE HTH, Marc Schwartz __ 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. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] Test for X=1 fails, test for >0 works, data in text file
On 07-Jul-09 19:06:59, Mark Knecht wrote: > Hi, >I am apparently not understanding some nuance about either the use > of subset or more likely my ability to test for a numerical match > using '='. Which is it? Thanks in advance. It looks as though you have tripped over the distinction between "=" and "==". The first is (in effect) an assignment operator (like "<-"). The second is a comparison operator: "X==Y" is TRUE if X equals Y. So, for example, to select rows from MyResults according to your criteria below, you could do something like: MyResultsNeg <- MyResults[(MyResults$PosType==(-1)),] MyResultsPos <- MyResults[(MyResults$PosType==1 ),] [Note: the parentheses "(...)" are in fact logically superfluous, but I like to use them (a) to make it absolutely clear, visually, how things are being evaluated; (b) (not relevant in this particular context) to avoid falling into traps like "N <- 10 ; X <- 1:N-1" which results in X == (0:9) = (1:10) - 1. The correct syntax for the latter would be X <- 1:(N-1).] Hoping this helps, Ted. >I've read a data file, reshaped it and then created MyResults by > keeping only lines where the value column is greater than 0. So far so > good. The data in MyResults looks good to me by eye. > >The problem comes in when I try to further subset MyResults into > two files, one with PosType=1 and the other with PosType=-1. Looking > at the dimension of the results there's no change. It didn't work > which is verified by eye. However if I test for PosType=1 by actually > testing for PosType>0 then it does work. > >Is this the general case in R that if I've read data that was > written into a csv file as 1 - it is 1 if I look into the file with a > text editor - that I cannot test for that? Or is some case where I > need to use maybe as.numeric or something else first to ensure R sees > the number the way I'm thinking about the number? > > Cheers, > Mark > >> dim(X) > [1] 25 425 >> >> ReShapeX <- melt(X, id = c("Trade", "PosType", "EnDate", "EnTime", >> "ExDate", "ExTime", "PL_Pos", "Costs", "Save2")) >> >> dim(ReShapeX) > [1] 1040011 >> >> MyResults <- subset(ReShapeX, value > 0) >> >> dim(MyResults) > [1] 1105 11 >> >> MyResults.GroupA <- subset(MyResults, PosType = 1) >> >> dim(MyResults.GroupA) > [1] 1105 11 >> >> MyResults.GroupB <- subset(MyResults, PosType = -1) >> >> dim(MyResults.GroupB) > [1] 1105 11 >> >> MyResults.GroupA <- subset(MyResults, PosType > 0) >> >> dim(MyResults.GroupA) > [1] 432 11 >> >> MyResults.GroupB <- subset(MyResults, PosType < 0) >> >> dim(MyResults.GroupB) > [1] 673 11 >> > > __ > 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. E-Mail: (Ted Harding) Fax-to-email: +44 (0)870 094 0861 Date: 07-Jul-09 Time: 20:28:44 -- XFMail -- __ 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] Test for X=1 fails, test for >0 works, data in text file is 1
Try this: MyResults.GroupA <- subset(MyResults, PosType == 1) On Tue, Jul 7, 2009 at 4:06 PM, Mark Knecht wrote: > Hi, > I am apparently not understanding some nuance about either the use > of subset or more likely my ability to test for a numerical match > using '='. Which is it? Thanks in advance. > > I've read a data file, reshaped it and then created MyResults by > keeping only lines where the value column is greater than 0. So far so > good. The data in MyResults looks good to me by eye. > > The problem comes in when I try to further subset MyResults into > two files, one with PosType=1 and the other with PosType=-1. Looking > at the dimension of the results there's no change. It didn't work > which is verified by eye. However if I test for PosType=1 by actually > testing for PosType>0 then it does work. > > Is this the general case in R that if I've read data that was > written into a csv file as 1 - it is 1 if I look into the file with a > text editor - that I cannot test for that? Or is some case where I > need to use maybe as.numeric or something else first to ensure R sees > the number the way I'm thinking about the number? > > Cheers, > Mark > > > dim(X) > [1] 25 425 > > > > ReShapeX <- melt(X, id = c("Trade", "PosType", "EnDate", "EnTime", > "ExDate", "ExTime", "PL_Pos", "Costs", "Save2")) > > > > dim(ReShapeX) > [1] 1040011 > > > > MyResults <- subset(ReShapeX, value > 0) > > > > dim(MyResults) > [1] 1105 11 > > > > MyResults.GroupA <- subset(MyResults, PosType = 1) > > > > dim(MyResults.GroupA) > [1] 1105 11 > > > > MyResults.GroupB <- subset(MyResults, PosType = -1) > > > > dim(MyResults.GroupB) > [1] 1105 11 > > > > MyResults.GroupA <- subset(MyResults, PosType > 0) > > > > dim(MyResults.GroupA) > [1] 432 11 > > > > MyResults.GroupB <- subset(MyResults, PosType < 0) > > > > dim(MyResults.GroupB) > [1] 673 11 > > > > __ > 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[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.
Re: [R] Test for X=1 fails, test for >0 works, data in text file is 1
Hi Mark, X = 1 assings the number 1 to X whereas X == 1 test if X is equal to 1. I suspect you want to do this :-) Here is an example: # R code X = 1 X # [1] 1 X == 1 # [1] TRUE HTH, Jorge On Tue, Jul 7, 2009 at 3:06 PM, Mark Knecht wrote: > Hi, > I am apparently not understanding some nuance about either the use > of subset or more likely my ability to test for a numerical match > using '='. Which is it? Thanks in advance. > > I've read a data file, reshaped it and then created MyResults by > keeping only lines where the value column is greater than 0. So far so > good. The data in MyResults looks good to me by eye. > > The problem comes in when I try to further subset MyResults into > two files, one with PosType=1 and the other with PosType=-1. Looking > at the dimension of the results there's no change. It didn't work > which is verified by eye. However if I test for PosType=1 by actually > testing for PosType>0 then it does work. > > Is this the general case in R that if I've read data that was > written into a csv file as 1 - it is 1 if I look into the file with a > text editor - that I cannot test for that? Or is some case where I > need to use maybe as.numeric or something else first to ensure R sees > the number the way I'm thinking about the number? > > Cheers, > Mark > > > dim(X) > [1] 25 425 > > > > ReShapeX <- melt(X, id = c("Trade", "PosType", "EnDate", "EnTime", > "ExDate", "ExTime", "PL_Pos", "Costs", "Save2")) > > > > dim(ReShapeX) > [1] 1040011 > > > > MyResults <- subset(ReShapeX, value > 0) > > > > dim(MyResults) > [1] 1105 11 > > > > MyResults.GroupA <- subset(MyResults, PosType = 1) > > > > dim(MyResults.GroupA) > [1] 1105 11 > > > > MyResults.GroupB <- subset(MyResults, PosType = -1) > > > > dim(MyResults.GroupB) > [1] 1105 11 > > > > MyResults.GroupA <- subset(MyResults, PosType > 0) > > > > dim(MyResults.GroupA) > [1] 432 11 > > > > MyResults.GroupB <- subset(MyResults, PosType < 0) > > > > dim(MyResults.GroupB) > [1] 673 11 > > > > __ > 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. > [[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.
Re: [R] Test for X=1 fails, test for >0 works, data in text file is 1
On 7/7/2009 3:06 PM, Mark Knecht wrote: Hi, I am apparently not understanding some nuance about either the use of subset or more likely my ability to test for a numerical match using '='. Which is it? Thanks in advance. I've read a data file, reshaped it and then created MyResults by keeping only lines where the value column is greater than 0. So far so good. The data in MyResults looks good to me by eye. The problem comes in when I try to further subset MyResults into two files, one with PosType=1 and the other with PosType=-1. Looking PosType = 1 is an assignment. The test is PosType == 1. Duncan Murdoch at the dimension of the results there's no change. It didn't work which is verified by eye. However if I test for PosType=1 by actually testing for PosType>0 then it does work. Is this the general case in R that if I've read data that was written into a csv file as 1 - it is 1 if I look into the file with a text editor - that I cannot test for that? Or is some case where I need to use maybe as.numeric or something else first to ensure R sees the number the way I'm thinking about the number? Cheers, Mark dim(X) [1] 25 425 ReShapeX <- melt(X, id = c("Trade", "PosType", "EnDate", "EnTime", "ExDate", "ExTime", "PL_Pos", "Costs", "Save2")) dim(ReShapeX) [1] 1040011 MyResults <- subset(ReShapeX, value > 0) dim(MyResults) [1] 1105 11 MyResults.GroupA <- subset(MyResults, PosType = 1) dim(MyResults.GroupA) [1] 1105 11 MyResults.GroupB <- subset(MyResults, PosType = -1) dim(MyResults.GroupB) [1] 1105 11 MyResults.GroupA <- subset(MyResults, PosType > 0) dim(MyResults.GroupA) [1] 432 11 MyResults.GroupB <- subset(MyResults, PosType < 0) dim(MyResults.GroupB) [1] 673 11 __ 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] Test for X=1 fails, test for >0 works, data in text file is 1
On Tue, Jul 7, 2009 at 12:17 PM, Henrique Dallazuanna wrote: > Try this: > > MyResults.GroupA <- subset(MyResults, PosType == 1) > > Darn those small screen fonts. I never noticed that! Every example I'm looking at jsut looks like a single '=' until you pointed it out! Thanks to everyone who responded. Cheers, Mark __ 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] Test for X=1 fails, test for >0 works, data in text file is 1
subset(), like many R methods, has an argument list that ends with '...', meaning that it will not tell you that an argument you gave it by name= is not in the official list of arument names. If the ... were not there then you would have gotten an error message. E.g., the following makes a version of subset.data.frame without the ... argument: > sb<-subset.data.frame > formals(sb) <- formals(sb)[1:4] > data(cars) > sb(cars, speed==19) speed dist 3619 36 3719 46 3819 68 > sb(cars, speed=19) Error in sb(cars, speed = 19) : unused argument(s) (speed = 19) subset(cars, speed=19) silently ignores the argument you named "speed" and returns the entire cars dataset. I think that it is unfortunate that the method system requires these ... arguments, as it leads users to waste time tracking down typing errors that would otherwise be flagged. Bill Dunlap TIBCO Software Inc - Spotfire Division wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Mark Knecht > Sent: Tuesday, July 07, 2009 12:39 PM > To: Henrique Dallazuanna > Cc: r-help > Subject: Re: [R] Test for X=1 fails, test for >0 works,data > in text file is 1 > > On Tue, Jul 7, 2009 at 12:17 PM, Henrique > Dallazuanna wrote: > > Try this: > > > > MyResults.GroupA <- subset(MyResults, PosType == 1) > > > > > > > Darn those small screen fonts. I never noticed that! Every example I'm > looking at jsut looks like a single '=' until you pointed it out! > > Thanks to everyone who responded. > > Cheers, > Mark > > __ > 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.