Re: [R] The W statistic in wilcox.exact
On Thu, 5 Oct 2006, Christos Hatzis wrote: Jue, On a second look, it appears that wilcox.test does report the offset-adjusted statistic U, as also mentioned in the help page. wilcox.test returns W=6 (instead of 12 as your example showed, unless wilcox_test is a different function). wilcox.test( 1:5 ~ c(1,1,0,0,0) )$statistic # or wilcox.test( 1:5 ~ factor(c(1,1,0,0,0)) )$statistic W 6 So there does not appear to be a difference between the two methods. Did I miss something? wilcox.{exact,test} compute the sum of the ranks 3, 4 and 5 minus a constant STATISTIC - sum(r[seq(along = x)]) - n.x * (n.x + 1)/2 whereas the linear statistic in wilcox_test (package coin) is equivalent to sum(r[seq(along = x)]) (only sum of the ranks). Best, Torsten -Christos -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Christos Hatzis Sent: Thursday, October 05, 2006 4:41 PM To: [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Subject: Re: [R] The W statistic in wilcox.exact Probably because of the offset: U = W - n*(n+1)/2 In your example, W=12 (=3+4+5) as reported by wilcox.test. The offset is 6 (=3*4/2) and therefore U=6. I am not certain as I haven't installed the exactRankTests package, but it seems that wilcox.exact reports U instead of W. -Christos Hatzis -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, October 05, 2006 1:35 PM To: r-help@stat.math.ethz.ch Subject: [R] The W statistic in wilcox.exact Does anyone know why wilcox.exact gives W-statistic 6 instead of 12 as indicated below. 12 is the rank sum of group 0 of x, which is the linear statistic computed by wilcox_test. y-c(1,2,3,4,5) x-c(1,1,0,0,0) (a) wilcox.exact wilcox.exact(y~x) Exact Wilcoxon rank sum test data: y by x W = 6, p-value = 0.2 alternative hypothesis: true mu is not equal to 0 (b) wilcox_test tt-wilcox_test(y~factor(x),distribution=exact) statistic(tt,linear) 0 12 Jue Wang, Biostatistician Contracted Position for Preclinical Research Biostatistics PrO Unlimited (908) 231-3022 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] hist plot
This is taken from the help for the hist function: Typical plots with vertical bars are not histograms. Consider barplot or plot(*, type = h) for such bar plots. For example: x - rchisq(100, df = 4) op-hist(x, freq = FALSE, ylim = c(0, 0.2)) plot(op$mids,op$counts,type=h) On 06/10/06, Baoqiang Cao [EMAIL PROTECTED] wrote: Hi there, I really couldn't find out how to plot histogram with point/line instead of rectangle for each bin? Any help please? Thanks! Best, -Cao __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] convert day of week from number to character and include in lm
Ferdinand Alimadhi [EMAIL PROTECTED] writes: lm(dep ~ as.factor(WKDY) but if you want WKDYs as character you can make the appropriate changes in your dataset days-c(mon,tue,wed,thu,fri,sat,sun) for(i in 1:7) + D$WKDY[D$WKDY==i]-days[[i]] suppossing that D is your dataframe Come on... factor(WKDY, labels=days) If you insist on a character result, take as.character(), or just days[WKDY] HTH Spencer Jones wrote: All, I am trying to include a day of week variable (1-7) in in a regression model. I would like to have the day of week treated as a categorical variable rather than a number the code looks like lm( dep ~ WKDY) I know this is a basic question, but help would be appreciated thanks spencer [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ferdinand Alimadhi Programmer / Analyst Harvard University The Institute for Quantitative Social Science (617) 496-0187 [EMAIL PROTECTED] www.iq.harvard.edu __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Relative constraint using constrOptim?
I am trying to optimize a likelihood function using constrOptim. I know from prior research that, e.g. x1x2. Is there a way to include that constraint into the optimization routine, i.e. the ci constraint? The examples I found only use absolute numeric values for the constraint and not relative values. My attempts to include it into ci failed: e.g. ci=c(1, x[1]). Am I using the right function or is there another one that could solve my problem? Any help would be much appreciated! Best regards Felix __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] back to back barplot
Dear all, someone knows if there is an already implemented function for drawing a back to back barplot (something similar to histbackback of the Hmisc package but for categorical data)? Thanks in advance, domenico vistocco Chiacchiera con i tuoi amici in tempo reale! http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] any package can visualize original affymetrix data?
See the Bioconductor project, http://www.bioconductor.org Uwe Ligges Baoqiang Cao wrote: Dear All, I'm thinking of visualizing the original binary data from affymetrix. Would you recommend any package? Not necessarily limited to R packages. Thanks! Best, -Cao __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] factor levels with umlauts
Hi all I have to generate some test data for import in an sql database. The database is meant for web-based data entry in a study taking place in a german speaking region, so factor levels of the variables include umlauts. The variables in the dataframe t.muster are generated e.g. like this: t.muster$screening - rep(ausgefüllt,50) and exported to a .csv file by: write.table(t.muster,MakeMuster041006/MusterDaten.csv, col.names=FALSE,row.names=FALSE,na=,sep=;) After export the factor level including an umlaut of t.muster$screening look like this in the sql-database as well as in an excel spreadsheet: ausgefüllt Looks like a conflict between encodings, but my locals are set correct in my discretion and I tried something like: t.muster - lapply(t.muster, iconv, ISO8859-1, ISO8859-15) but it did not work. my locals are: Sys.getlocale() [1] LC_COLLATE=German_Switzerland.1252;LC_CTYPE=German_Switzerland.1252;LC_MONETARY=German_Switzerland.1252; LC_NUMERIC=C;LC_TIME=German_Switzerland.1252 and I am running R on: R.version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) I'd be glad if someone could help me out. Thanks in advance. Christian __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Multivariate AR - prediction
Hello Alexander, try package CRAN package 'vars'. Best, Bernhard Hi, does anybody know how to predict a multivariate AR within R? If I just estimate a multi AR-object and plug it into predict I get an error from the aperm - just works for univariates. thx alex __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. * Confidentiality Note: The information contained in this mess...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sparklines in lattice
Dear R-help, Has anyone implemented sparklines in the strips of a lattice plot? What I have in mind is, say, highlighting that part of a time series that one is examining in more detail in a set of lattice plots. Regads,. Mark Difford. PS: (Andreas Loffler has implemented a simple but functional version for TeX/LaTeX: http://www.tug.org/tex-archive/help/Catalogue/entries/sparklines.html) Mark Difford Ph.D. candidate, Botany Department, Nelson Mandela Metropolitan University, Port Elizabeth, SA. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] calling R from within Java, using jri
Hi, (I addressed the JRI issues I had in my previous email below http://article.gmane.org/gmane.comp.lang.r.general/70322 by working with the precompiled version of JRI that is part of the rJava package.) So I can now run the JRI examples as expected but am having difficulty getting the Rengine to start with the '--vanilla' startup option set. When I run JRI's rtest example with the '--vanilla' argument set, it seems to have no effect but on the command line (inside rtest) I can see that the command line option was issued as expected: commandArgs() rBusy(1) [1] Rengine --vanilla rBusy(0) In addition, adding the line System.out.println(Print arguments + args[0]); just before passing the 'args' to the Rengine Rengine re=new Rengine(args, false, new TextConsole()); produces the expected output 'Print arguments --vanilla'. So what is the correct way to get Rengine to accept the '--vanilla' argument? Regards, John. John Gavin [EMAIL PROTECTED], Commodities, FIRC, UBS Investment Bank, 2nd floor, 100 Liverpool St., London EC2M 2RH, UK. Phone +44 (0) 207 567 4289 -Original Message- From: Gavin, John Sent: 28 September 2006 12:42 To: 'R-help@stat.math.ethz.ch' Subject: calling R from within Java, using jri Hi, I want to call R from within Java, using jri as per http://www.rosuda.org/software/jri/ So I am following the instructions in the README file for JRI 0.2-4. I have run 'sh configure.win' and 'make' and they seemed to be successful. (See below for the output from make, for example.) But when I try 'run.bat rtest' (with and without R command line arguments) the output that I get is 'c:\temp\r\jriC:/PROGRA~1/Java/JDK15~1.0_0/bin/java -cp .;examples;src/JRI.jar rtest $* Creating Rengine (with arguments)' That suggests that it gets to line 60 in rtest.java then stops on line 61, without producing an error. Line 61 is Rengine re=new Rengine(args, false, null); so it seems that I am not able to construct an Rengine. Can someone suggest what I might try next to track down the problem, please? I am running Java JDK 1.5.0 and R 2.3.1 on Windows NT. Regards, John. This communication is issued by UBS AG and/or affiliates to institutional investors; it is not for private persons. This is a product of a sales or trading desk and not the Research Dept. Opinions expressed may differ from those of other divisions of UBS, including Research. UBS may trade as principal in instruments identified herein and may accumulate/have accumulated a long or short position in instruments or derivatives thereof. UBS has policies designed to negate conflicts of interest. This e-mail is not an official confirmation of terms and unless stated, is not a recommendation, offer or solicitation to buy or sell. Any prices or quotations contained herein are indicative only. Communications may be monitored. © 2006 UBS. All rights reserved. Intended for recipient only and not for further distribution without the consent of UBS. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Block comments in R?
And of course for NEdit, all one needs to do is select: Preferences | Default Settings | Customize menus | Macro Menu Then select the New option at the top of the menu list, Give it a name (I call this r_comment), Enter the following code: replace_in_selection(^,#,regex) click on Apply and then OK You will have an item named r_comment on your macro menu Simply select the area you wish to comment out and run the macro. To remove comments, you can program another macro (r_nocomment) replace_in_selection(#,) You can give both of these a keystroke invocation if you wish. Happy commenting! Jim __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Block comments in R?
Richard A. O'Keefe wrote: Commenting code out and providing documentation comments are easily done with a good editor, although R documentation comments really belong in files where help() can find them. R documentation comments belong in .Rd files at the moment, but how joyous would it be if they could be included in the .R files? Okay, this is all part of my incessant whining to make R more like Python, but I've found managing separate .Rd and .R files a pain. If .R files could have embedded documentation you'd have one source for code, documentation, tests etc. I did play about with this in the Splus days, attaching documentation strings to functions with attributes, but it was just kludgy without a proper mechanism. Is there an R 3.0 roadmap? Barry __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Block comments in R?
Note that if you only have block comments in a language, its much harder to do this: http://www.xkcd.com/c156.html Barry __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] back to back barplot
Domenico Vistocco wrote: Dear all, someone knows if there is an already implemented function for drawing a back to back barplot (something similar to histbackback of the Hmisc package but for categorical data)? Hi Domenico, Have a look at pyramid.plot in the plotrix package if you want something like a population pyramid. Jim __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] hist plot
Baoqiang Cao wrote: Hi there, I really couldn't find out how to plot histogram with point/line instead of rectangle for each bin? Any help please? Thanks! This is a guess, but... y-hist(rnorm(100,3),plot=FALSE)$counts x-barplot(y,width=0.01,space=20) points(x,y) Jim __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] processing strings in R
Dear R cracks, I need to process data in R which consist of strings like AAABAVVABNN ABVVNNAA What I would like to know is whether there are commands that deliver -the length of a string -one specified character of a string (e.g. the 3rd letter) -that allow to concatenate characters to a string again Can anyone help me? Thanks a lot! Florian Menzel - Stay in the know. Pulse on the new Yahoo.com. Check it out. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Fitting a cumulative gaussian
Dear R-Experts, I was wondering how to fit a cumulative gaussian to a set of empirical data using R. On the R website as well as in the mail archives, I found a lot of help on how to fit a normal density function to empirical data, but unfortunately no advice on how to obtain reasonable estimates of m and sd for a gaussian ogive function. Specifically, I have data from a psychometric function relating the frequency a subject's binary response (stimulus present / absent) to the strength of a physical stimulus. Such data is often modeled using a cumulative gaussian function. I have tried to implement such a fitting algorithm in R, but unfortunately, I was not successful. Maybe anyone on the list already coded a script for such purposes or could help me otherwise??? Thanks in advance, Matthias __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] processing strings in R
Florian Menzel wrote: Dear R cracks, We prefer to be called 'R souls'. I need to process data in R which consist of strings like AAABAVVABNN ABVVNNAA What I would like to know is whether there are commands that deliver -the length of a string -one specified character of a string (e.g. the 3rd letter) -that allow to concatenate characters to a string again s1=AAABAVVABNN s2='ABVVNNAA' nchar(s1) [1] 11 substr(s1,6,6) [1] V strsplit(s1,'') [[1]] [1] A A A B A V V A B N N - returns a list. chars = strsplit(s1,'')[[1]] chars [1] A A A B A V V A B N N - back together again: paste(chars,collapse='') [1] AAABAVVABNN __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Block comments in R?
And of course in emacs you can select the region to comment then hit Ctrl-x r t and type #: all the lines in that region will have a # at the beginnig To uncomment Ctrl-x r d Stefano On Fri, Oct 06, 2006 at 07:05:52PM -0400, Jim Lemon wrote: JimAnd of course for NEdit, all one needs to do is select: Jim JimPreferences | Default Settings | Customize menus | Macro Menu Jim JimThen select the New option at the top of the menu list, Jim JimGive it a name (I call this r_comment), Jim JimEnter the following code: Jim Jimreplace_in_selection(^,#,regex) Jim Jimclick on Apply and then OK Jim JimYou will have an item named r_comment on your macro menu Jim JimSimply select the area you wish to comment out and run the macro. Jim JimTo remove comments, you can program another macro (r_nocomment) Jim Jimreplace_in_selection(#,) Jim JimYou can give both of these a keystroke invocation if you wish. Jim JimHappy commenting! Jim JimJim Jim Jim__ JimR-help@stat.math.ethz.ch mailing list Jimhttps://stat.ethz.ch/mailman/listinfo/r-help JimPLEASE do read the posting guide http://www.R-project.org/posting-guide.html Jimand provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Summation in R
I was off for few days and as nobody seems to answer I will try again. It is probably not trivial with matrix (possibly with combination of outer and some subsequent selection) but if you can transfer it to data frame (or list) you could use mapply tj - 1:5 vj - matrix(1:25, 5,5) mapply(*, data.frame(vj), tj) anyway it is always advisable to provide some example what you want to achieve. Usually when I try to elaborate an example I find the answer myself. HTH Petr On 3 Oct 2006 at 11:50, Dina Said wrote: Date sent: Tue, 03 Oct 2006 11:50:39 +0200 From: Dina Said [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:Re: [R] Summation in R Thanks Pikal for your reply I want element wise summation. If t is a vector of 5, v is a matrix of 5*5 then I want the answer to be a matrix of 5*5 by multiplying each element in t (t_j) by each vector in v (v_j). Dina Petr Pikal wrote: Hi you shall probably to be more specific tj-rnorm(5) vj-matrix(25,5,5) sum(tj*vj) [1] 149.2977 gives you an answer but maybe not the answer you want. HTH Petr On 3 Oct 2006 at 8:58, Dina Said wrote: Date sent: Tue, 03 Oct 2006 08:58:15 +0200 From: Dina Said [1][EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject:[R] Summation in R Hello! Maybe this is a trivial question as I'm still a new baby in R but I wish that u will help me. I want to calculate the following U= sum (t_j*v_j) where t_j is a vector and v_j is the matrix Thanks Dina __ [EMAIL PROTECTED] mailing list [4]https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide [5]http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] References 1. mailto:[EMAIL PROTECTED] 2. mailto:r-help@stat.math.ethz.ch 3. mailto:R-help@stat.math.ethz.ch 4. https://stat.ethz.ch/mailman/listinfo/r-help 5. http://www.R-project.org/posting-guide.html 6. mailto:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Block comments in R?
Commenting code out and providing documentation comments are easily done with a good editor, although R documentation comments really belong in files where help() can find them. R documentation comments belong in .Rd files at the moment, but how joyous would it be if they could be included in the .R files? This is how I do al my package documentation, using a home-made comment parser based on javadoc. It doesn't cover all situations, but it works well enough for me, and has dramatically increased the quanity and quality of documentation that I write. Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Block comments in R?
Stefano == Stefano Calza [EMAIL PROTECTED] on Fri, 6 Oct 2006 12:55:38 +0200 writes: Stefano And of course in emacs you can select the region to comment then hit Stefano Ctrl-x r t and type #: all the lines in that region will have a # at the Stefano beginnig Stefano To uncomment Ctrl-x r d well, if we really talk emacs --- we shouldn't here -- you definitely should learn to use M-; It does use ## in ESS (as you should for full line comments) Martin Stefano Stefano __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Relative constraint using constrOptim?
Reparameterize replacing x1 with x2+delta constraining delta to be positive or else replace x1 with x2 + delta^2 and no constraint. On 10/6/06, Felix Eggers [EMAIL PROTECTED] wrote: I am trying to optimize a likelihood function using constrOptim. I know from prior research that, e.g. x1x2. Is there a way to include that constraint into the optimization routine, i.e. the ci constraint? The examples I found only use absolute numeric values for the constraint and not relative values. My attempts to include it into ci failed: e.g. ci=c(1, x[1]). Am I using the right function or is there another one that could solve my problem? Any help would be much appreciated! Best regards Felix __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Block comments in R?
Cool, didn't know that! Thanks, Stefano On Fri, Oct 06, 2006 at 01:46:03PM +0200, Martin Maechler wrote: MartinStefano To uncomment Ctrl-x r d Martin Martinwell, if we really talk emacs --- we shouldn't here -- Martinyou definitely should learn to use M-; Martin MartinIt does use ## in ESS (as you should for full line comments) Martin MartinMartin -- Stefano Calza, PhD Researcher - Biostatistician *Sezione di Statistica Medica e Biometria Dipartimento di Scienze Biomediche e Biotecnologie Università degli Studi di Brescia - Italy Viale Europa, 11 25123 Brescia email: [EMAIL PROTECTED] Phone: +390303717653 Fax: +390303717488 *Dept. Medical Epidemiology and Biostatistics (MEB) Karolinska Institutet, SE-17177 Stockholm Sweden phone:+46-8-524 82279 Civilization is the limitless multiplication of unnecessary necessities. -- Mark Twai __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] glm and plot.effects
Dear R-helpers, I don't see a difference between the following two plots of effect objects, which I understand should be different. What am I missing? require(doBy) require(effects) data(budworm) m1 - glm(ndead/20 ~ sex + log(dose), data=budworm, weight=ntotal, family=binomial) m1.eff - all.effects(m1) plot(m1.eff, rescale.axis = FALSE, selection = 2, main = 'rescale = F') plot(m1.eff, rescale.axis = TRUE, selection = 2, main = 'rescale = T') * R version 2.4.0 (2006-10-03) powerpc-apple-darwin8.7.0 locale: C attached base packages: [1] grid tools splines methods utils [6] stats graphics grDevices datasets base other attached packages: effects doBy Hmisc chron weaver codetools 1.0-9 0.83.1-12.3-81.0.00.0-3 digest proptest survival lme4 MatrixJGR 0.2.20.1-1 2.29 0.9975-0 0.9975-1 1.4-11 iplots JavaGD rJava MASSlattice 1.0-40.3-5 0.4-10 7.2-29 0.14-9 _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lmer BIC changes between output and anova
The two models that you compare differ in their fixed effects. As far as lme had been concerned, the anova gave a warning because one should not compare two models differing in their fixed effects if they had been estimated with REML (Pinheiro Bates, 2000). I guess the issue is still the same using lmer (but anyone please correct me, if I am wrong) but perhaps the warning message is currently not implemented. Regards, Lorenz - Lorenz Gygax Centre for proper housing of ruminants and pigs Swiss Federal Veterinary Office Agroscope Reckenholz-Tänikon Research Station ART -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Darren M. Ward Sent: Thursday, October 05, 2006 5:18 PM To: r-help@stat.math.ethz.ch Subject: [R] lmer BIC changes between output and anova list, i am using lmer to fit multilevel models and trying to use anova to compare the models. however, whenever i run the anova, the AIC, BIC and loglik are different from the original model output- as below. can someone help me out with why this is happening? (i'm hoping the output assocaited with the anova is right!). thank you, darren unconditional-lmer(log50 ~ 1 + (1 | Stream:Site) + (1|Stream), data) summary(unconditional) Linear mixed-effects model fit by REML Formula: log50 ~ 1 + (1 | Stream:Site) + (1 | Stream) Data: data AICBIC logLik MLdeviance REMLdeviance -138.8 -132.8 72.42 -150.4 -144.8 nosection-lmer(log50 ~ 1 + meanlogATS + residuallogATS + (1 | Stream:Site) + (1|Stream), data) summary(nosection) Linear mixed-effects model fit by REML Formula: log50 ~ 1 + meanlogATS + residuallogATS + (1 | Stream:Site) + (1 | Stream) Data: data AICBIC logLik MLdeviance REMLdeviance -140.8 -130.7 75.4 -168.9 -150.8 anova(unconditional, nosection) Data: data Models: unconditional: log50 ~ 1 + (1 | Stream:Site) + (1 | Stream) nosection: log50 ~ 1 + meanlogATS + residuallogATS + (1 | Stream:Site) + unconditional: (1 | Stream) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) unconditional 3 -144.370 -138.294 75.185 nosection 5 -158.861 -148.734 84.430 18.491 2 9.657e-05 *** __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] glm and plot.effects
Dear Michael, Look more closely at the two plots: With rescale.axis=TRUE (the default), the vertical axis is on the scale of the linear predictor (i.e., the logit scale), but the tick marks are labelled in the scale of the response (i.e., the probability scale); this preserves the linear structure of the model. With rescale.axis=FALSE, the vertical axis is on the scale of the response (directly on the probability scale). If you want the vertical axis labelled on the scale of the linear predictor, specify type=link (the default is response). I hope this helps, John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Kubovy Sent: Friday, October 06, 2006 7:19 AM To: R list Subject: [R] glm and plot.effects Dear R-helpers, I don't see a difference between the following two plots of effect objects, which I understand should be different. What am I missing? require(doBy) require(effects) data(budworm) m1 - glm(ndead/20 ~ sex + log(dose), data=budworm, weight=ntotal, family=binomial) m1.eff - all.effects(m1) plot(m1.eff, rescale.axis = FALSE, selection = 2, main = 'rescale = F') plot(m1.eff, rescale.axis = TRUE, selection = 2, main = 'rescale = T') * R version 2.4.0 (2006-10-03) powerpc-apple-darwin8.7.0 locale: C attached base packages: [1] grid tools splines methods utils [6] stats graphics grDevices datasets base other attached packages: effects doBy Hmisc chron weaver codetools 1.0-9 0.83.1-12.3-81.0.00.0-3 digest proptest survival lme4 MatrixJGR 0.2.20.1-1 2.29 0.9975-0 0.9975-1 1.4-11 iplots JavaGD rJava MASSlattice 1.0-40.3-5 0.4-10 7.2-29 0.14-9 _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re : research
Hi, What about computational aspect for the job you intend to realise ? What will be the use of R ? R can do a lot in statistic but you can't ask help for a topic so far far of R. Be more precise. Justin BEM Elève Ingénieur Statisticien Economiste BP 294 Yaoundé. Tél (00237)9597295. - Message d'origine De : aziz tomi [EMAIL PROTECTED] À : r-help@stat.math.ethz.ch Envoyé le : Jeudi, 5 Octobre 2006, 15h57mn 02s Objet : [R] research dear sir iam algerian student iam 30 years old i finished my postgraduate in applied economic and statistics .i prepare my doctorat about effect of kyoto protocol on our economic. i need the document and the articals and the adress of doctor in this domain in your university i shall be looking forward and hoping that give my request forward consideration rachid toumache adress: 11 rue doudou mothtar ben aknoun algeria institut national de la planification et de la statistique inps - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ___ interface révolutionnaire. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with script
Thank you, Gabor, for all your suggestions. Best, John On 10/5/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: On 10/4/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Also see package caTools. On 10/4/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: See: http://tolstoy.newcastle.edu.au/R/help/04/10/5161.html On 10/4/06, JOHN VOIKLIS [EMAIL PROTECTED] wrote: Hello, I wrote the function, below, in the hope of _quickly_ generating a sliding-window time series of the mean, sd, median, and mad values from a matrix of data. The script below is anything but quick; it has been working away on a 2500 x 2500 matrix with a sliding window of 100 x 100 for five days, with no end in sight. Obviously, I am not the best of programmers. Can anyone offer suggestions as to how I might optimize this script. Thank you, John common.ground-function(inMatrix,window){ cleanMatrix-as.matrix(inMatrix) diag(cleanMatrix)-NA outMatrix-matrix(0,dim(inMatrix)[1]-window,4) colnames(outMatrix)-c(mean,SD, median,mad) for(i in 1:dim(outMatrix)[1]){ for(j in window:dim(cleanMatrix)[2]){ outMatrix[i,1]-mean(cleanMatrix[c(i:j),c(i:j)],na.rm=TRUE) outMatrix[i,2]-sd(c(cleanMatrix[c(i:j),c(i:j)]),na.rm=TRUE) outMatrix[i,3]-median(cleanMatrix[c(i:j),c(i:j)],na.rm=TRUE) outMatrix[i,4]-mad(cleanMatrix[c(i:j),c(i:j)],na.rm=TRUE) } } return(outMatrix) } Also you could look at rollmax, rollmean and rollmedian in the zoo package. rollapply in zoo with FUN = sd could be used for the sd. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sweave2html only for Linux users ?
Laurent Rhelp laurentRhelp at free.fr writes: Dear R-List, I would like to convert my rnw files written with Sweave from LaTeX to html. I discovered on the list the following link : http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/SweaveConvert Is this document only for linux users or I can use it with windose XP ? Maybe cygwin can be of help here. Gregor __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Block comments in R?
And of course vim, emacs, nedit, tinn-r... Should R be editor specific? Or should it be editor neutral? In my view blocks comments are a desirable, editor-neutral approach. Note that most of the more recent languages have some form of block comment capability. http://en.wikipedia.org/wiki/Comment#Summary jab -- John Bollinger, CFA, CMT www.BollingerBands.com If you advance far enough, you arrive at the beginning. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkg] New packages pmg, gWidgets, gWidgetsRGtk2
I'd like to announce three new packages on CRAN: pmg, gWidgets, and gWidgetsRGtk2. --John Verzani 1 PMG *=*=*= The pmg package for R provides a relatively simple graphical user interface for R in a manner similar to the more mature RCmdr package. Basically this means a menu-driven interface to dialogs that collect arguments for R functions. This GUI was written with an eye towards simplifying the learning curve of R for introductory statistics students. The pmg package uses the GTK toolkit via the RGtk2 (1) package by Michael Lawrence. Some features are - The GUI works under Windows, Mac OS X, Linux/X11 - The GUI takes advantage of GTK's drag-and-drop capabilities. - Several dialogs for analyses performed in an introductory statistics course can be used simply by dragging variables around. - With the cairoDevice package, the GUI provides a notebook interface to a graphics device that allows UNIX users to easily manage multiple graphics devices. 2 gWidgets *=*=*=*=*=* The RGtk2 package is interfaced with the new gWidgets package, which may be of independent interest to those who would like to add GUI elements to their work. The gWidgets package provides a toolkit-independent API for interactive GUIs based on the iWidgets API of Simon Urbanek, with additional suggestions given by Philippe Grosjean and Michael Lawrence. The gWidgetsRGtk2 package provides the link between gWidgets and RGtk2, allowing the GTK toolkit to be used through gWidgets. It is possible for others to write a link between gWidgets and some other GUI toolkit. The gWidgets API is nowhere near as rich as the RGtk2 interface to the toolkit, but is much easier to learn. It is well-suited for simple applications or for rapid prototyping of more complicated applications. An accompanying vignette shows many examples of its use. For a simple, but not trivial, illustration, this code, following chooseCRANmirror(), shows how to use gWidgets to make a dialog for selecting a CRAN mirror. win = gwindow(Select a CRAN mirror) size(win) - c(600,400) tbl = gtable(utils:::getCRANmirrors(), chosencol=4, filter.column=2, container=win, filter.column=2, handler = function(h,...) { URL = svalue(tbl) repos - getOption(repos) repos[CRAN] - gsub(/$, , URL[1]) options(repos = repos) dispose(win) }) Two widgets are created: a base window to be a container for the widget that displays a table, which has a few extra arguments shown to indicate its flexibility. The widget to display a table allows a user to double click on a row and expect some action to happen. In this case, the handler for this action sets the value of repos. The svalue() method is used to retrieve the selected value from a widget and the dispose() method is used to remove a window. 3 Installation *=*=*=*=*=*=*=* Installing pmg requires two steps: installing the GTK libraries and installing the R packages. 3.1 Installing the GTK libraries = RGtk2 requires relatively modern versions of the GTK libraries (2.8.0 or higher). Installing the libraries under Windows is easy. Download the runtime installer from sourceforge (2). With linux you may need to upgrade base GTK libraries. The GTK libraries are available under Mac OS X using X11. (I haven't confirmed that is possible for RGtk2 to use the native port of GTK.) More details at RGtk2's home (3). 3.2 Installing the R packages == The following R packages are needed: RGtk2, cairoDevice, gWidgets, gWidgetsRGtk2, and pmg. All can be downloaded from CRAN. The gWidgetsRGtk2 depends on gWidgets and RGtk2 and suggests cairoDevice so you may be able to get away with install.packages(c(gWidgetsRGtk2,pmg), dependencies=c(Depends, Suggests)) 4 Starting *=*=*=*=*=* The GUI is started when the pmg package is loaded. If the GUI is closed, it may be restarted by calling pmg(). An accompanying vignette (vignette(pmg)) describes the GUI. 5 Comments *=*=*=*=*=* Send comments or suggestions to [EMAIL PROTECTED] --- (1) http://www.ggobi.org/rgtk2 (2) http://gladewin32.sourceforge.net/modules/news/ (3) http://www.ggobi.org/rgtk2 --- This document was translated from LaTeX by HeVeA (http://pauillac.inria.fr/~maranget/hevea/index.html). __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fitting a cumulative gaussian
Gamer, Matthias gamer at uni-mainz.de writes: Specifically, I have data from a psychometric function relating the frequency a subject's binary response (stimulus present / absent) to the strength of a physical stimulus. Such data is often modeled using a cumulative gaussian function. Well, more often by a logistic function, and there are quite a few tools powerful for doings this around, for example glm, or lmer/lme4, glmmPQL/MASS, glmmML/glmmML . The latter three are the tools of choice when you have within subject repeats, as it's standard in psychophysics. See http://finzi.psych.upenn.edu/R/Rhelp02a/archive/33737.html for a comparison. If you really want a cumlative gaussian, you can misuse drfit/drfit, which is primarily for dose/response curves and ld50 determination. I think there is a fitdistr/MASS example around (somewhere in the budworms chapter), but I don't have the book at hand currently. Dieter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] which command
AgusSusanto gusanto at gmail.com writes: I obtained error messages when I run these commands in UNIX, but I obtained correct result when I run these command in WINDOWS. Can somebody point out the problem and give the solution. Thanks. dt-read.table(file=Fall.dat) dim(dt) [1] 19415 Windows file names are not case sensitive, UNIX is. Check you effective filename. Dieter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Estimate in Wilcox_test vs wilcox.exact
Does any one know why wilcox.exact sometimes doesn't agree with wilcox_test on the estimate of the difference of medians in two levels ? Thank you Jue Wang, Biostatistician Contracted Position for Preclinical Research Biostatistics PrO Unlimited (908) 231-3022 Example 1: (wilcox_test gives correct median difference) y1-rep(0,10) y2-c(32.507,61.901,134.938,49.95,29.954,99.835,49.27) median(y1)-median(y2) -49.95 y-c(y1,y2) x-c(rep(0,10),rep(1,7)) Test-wilcox_test(y~factor(x),distribution=exact,conf.int=TRUE) confint(Test)$estimate difference in location -49.95 exact-wilcox.exact(y~x,conf.int=TRUE) exact$estimate difference in location -55.9255 Example 2: (wilcox.exact gives correct median difference) y1-c(0,0,0,0,0,3.065,3.075,3.075,3.118,3.118) y2-c(0,0,0,0,0,0,0,14.958,51.002,63.984) median(y1)-median(y2) 1.5325 y-c(y1,y2) x-c(rep(0,10),rep(1,10)) Test-wilcox_test(y~factor(x),distribution=exact,conf.int=TRUE) confint(Test)$estimate difference in location 0 exact-wilcox.exact(y~x,conf.int=TRUE) exact$estimate difference in location 1.5325 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Fitting a cumulative gaussian
If the data asymptote at 0 and 1, then you can use glm with the binomial family with either the logistic or probit links. If the data are from an n-alternative forced choice procedure or if the data do not asymptote at 0 and 1 for some reason or other, then you need to try other procedures. Two possibilities are to use the PsychoFun package available here http://www.kyb.tuebingen.mpg.de/~kuss and described in Kuss, M., F. Jäkel and F.A. Wichmann: Bayesian inference for psychometric functions. Journal of Vision 5(5), 478-492 (2005) or tools from some of Jim Lindsey's packages, described here Yssaad-Fesselier R, Knoblauch K. Modeling psychometric functions in R. Behav Res Methods. 2006 Feb;38(1):28-41. HTH ken Gamer, Matthias gamer at uni-mainz.de writes: Specifically, I have data from a psychometric function relating the frequency a subject's binary response (stimulus present / absent) to the strength of a physical stimulus. Such data is often modeled using a cumulative gaussian function. Well, more often by a logistic function, and there are quite a few tools powerful for doings this around, for example glm, or lmer/lme4, glmmPQL/MASS, glmmML/glmmML . The latter three are the tools of choice when you have within subject repeats, as it's standard in psychophysics. See http://finzi.psych.upenn.edu/R/Rhelp02a/archive/33737.html for a comparison. If you really want a cumlative gaussian, you can misuse drfit/drfit, which is primarily for dose/response curves and ld50 determination. I think there is a fitdistr/MASS example around (somewhere in the budworms chapter), but I don't have the book at hand currently. Dieter [[alternative text/enriched version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [R-pkg] New packages pmg, gWidgets, gWidgetsRGtk2
Hi, I need installation instructions. library(pmg) seems not to be enough. Thanks. library(pmg) Loading pmg() Loading required package: gWidgets Loading required package: gWidgetsRGtk2 Loading required package: RGtk2 Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library 'C:/PROGRA~1/R/R-24~1.0/library/RGtk2/libs/RGtk2.dll': LoadLibrary failure: The specified procedure could not be found. Error: package 'RGtk2' could not be loaded Error: .onAttach failed in 'attachNamespace' Loading required package: pmggWidgetsRGtk PMG needs gWidgetsError in assign(x, value, envir = ns, inherits = FALSE) : could not find function gwindow In addition: Warning message: there is no package called 'pmggWidgetsRGtk' in: library(package, lib.loc = lib.loc, character.only = TRUE, logical = TRUE, Error: .onLoad failed in 'loadNamespace' for 'pmg' Error: package/namespace load failed for 'pmg' On 10/6/06, j verzani [EMAIL PROTECTED] wrote: I'd like to announce three new packages on CRAN: pmg, gWidgets, and gWidgetsRGtk2. --John Verzani 1 PMG *=*=*= The pmg package for R provides a relatively simple graphical user interface for R in a manner similar to the more mature RCmdr package. Basically this means a menu-driven interface to dialogs that collect arguments for R functions. This GUI was written with an eye towards simplifying the learning curve of R for introductory statistics students. The pmg package uses the GTK toolkit via the RGtk2 (1) package by Michael Lawrence. Some features are - The GUI works under Windows, Mac OS X, Linux/X11 - The GUI takes advantage of GTK's drag-and-drop capabilities. - Several dialogs for analyses performed in an introductory statistics course can be used simply by dragging variables around. - With the cairoDevice package, the GUI provides a notebook interface to a graphics device that allows UNIX users to easily manage multiple graphics devices. 2 gWidgets *=*=*=*=*=* The RGtk2 package is interfaced with the new gWidgets package, which may be of independent interest to those who would like to add GUI elements to their work. The gWidgets package provides a toolkit-independent API for interactive GUIs based on the iWidgets API of Simon Urbanek, with additional suggestions given by Philippe Grosjean and Michael Lawrence. The gWidgetsRGtk2 package provides the link between gWidgets and RGtk2, allowing the GTK toolkit to be used through gWidgets. It is possible for others to write a link between gWidgets and some other GUI toolkit. The gWidgets API is nowhere near as rich as the RGtk2 interface to the toolkit, but is much easier to learn. It is well-suited for simple applications or for rapid prototyping of more complicated applications. An accompanying vignette shows many examples of its use. For a simple, but not trivial, illustration, this code, following chooseCRANmirror(), shows how to use gWidgets to make a dialog for selecting a CRAN mirror. win = gwindow(Select a CRAN mirror) size(win) - c(600,400) tbl = gtable(utils:::getCRANmirrors(), chosencol=4, filter.column=2, container=win, filter.column=2, handler = function(h,...) { URL = svalue(tbl) repos - getOption(repos) repos[CRAN] - gsub(/$, , URL[1]) options(repos = repos) dispose(win) }) Two widgets are created: a base window to be a container for the widget that displays a table, which has a few extra arguments shown to indicate its flexibility. The widget to display a table allows a user to double click on a row and expect some action to happen. In this case, the handler for this action sets the value of repos. The svalue() method is used to retrieve the selected value from a widget and the dispose() method is used to remove a window. 3 Installation *=*=*=*=*=*=*=* Installing pmg requires two steps: installing the GTK libraries and installing the R packages. 3.1 Installing the GTK libraries = RGtk2 requires relatively modern versions of the GTK libraries (2.8.0 or higher). Installing the libraries under Windows is easy. Download the runtime installer from sourceforge (2). With linux you may need to upgrade base GTK libraries. The GTK libraries are available under Mac OS X using X11. (I haven't confirmed that is possible for RGtk2 to use the native port of GTK.) More details at RGtk2's home (3). 3.2 Installing the R packages == The following R packages are needed: RGtk2, cairoDevice, gWidgets, gWidgetsRGtk2, and pmg. All can be downloaded from CRAN. The gWidgetsRGtk2 depends on gWidgets and RGtk2 and suggests cairoDevice so you may be able to get away with install.packages(c(gWidgetsRGtk2,pmg), dependencies=c(Depends, Suggests)) 4 Starting *=*=*=*=*=* The GUI is started when the pmg package is loaded. If the GUI is
Re: [R] treatment effect at specific time point within mixedeffects model
-Original Message- From: Chuck Cleland [mailto:[EMAIL PROTECTED] Sent: Friday, October 06, 2006 5:32 AM To: Afshartous, David Subject: Re: [R] treatment effect at specific time point within mixedeffects model Afshartous, David wrote: The data structure is a repeated measures crossover design, i.e., N patients measured at 6 time points, each on drug and placebo; thus no clustering of individuals within groups if I understand you correctly. David: That is not the same as the structure of data.grp, where there is no crossover. I believe this makes drug a within-subjects effect in the mixed model. In the simple t-test, drug is essentially a between-subjects effect since only one time is considered. If I understand correctly, the simple t-test is an independent sample t-test since at a particular time each subject serves in only one drug condition. DA sorry, the pseudo data of data.grp should have had crosover. RE the t-test, a paired t-test would account for the dependence. I just ran the mixed model w/ the new contrast coding so that the coefficient for Drug now tests the signifiance of Drug at Hour 3. The p-value is comparable to that obtained from the paired t-test at hour 3. However, for a different dataset the relevant mixed model p-value is .003 while that for the paired t-test is .04. Given this data structure, does anyone have any suggestions as to what to look for that could explain why in one case p-values are consistent and in the other case they are not? This would be especially helpful since the medical people want to solely focus on hour 3 and perform the paired t-test. Sorry to belabor the question but I've been getting various answers to this question and would like to resolve it. Are the coefficients for this comparison the same with each approach? Here is one way of doing the simple t-test which gives the coefficient for that approach: lm(z ~ drug, data = data.grp, subset = (time == Time-3)) DA but this wouldn't be a paired t-test, correct? If the coefficients for this simple t-test approach and the contrast in the mixed-model are the same, then the difference in significance results from differences in the standard errors. The mixed-model approach takes into account many more observations of z, so I would consider its estimate of the standard error to be better than the estimate that only considers one time point. DA RE the coefficients: they are the same for both approaches for both my datasets above, as expected. For the latter case where the mixed model obtained much greater significance than the paired t-test, I guess your explantion how it uses more data to estimate the standards error is on target. Finally, would it be okay to say that the paired t-test is a valid conservative method for this question at a single time point if that time point is the main endpoint of the study? There is an article in the British Journal of Medicne (Analysis of Serisal Measurments in Medical Research, v300, p.230, Mathews et al) that critiques testing several separate time points, but I don't think their arguments invalidate doing a single paired t-test. hope this helps, Chuck -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lmer output
When I do lmer models I only get Estimate, Standard Error and t value in the output for the fixed effects. Is there a way I get degrees of freedom and p values as well? I'm a very new to R, so sorry if this a stupid question. Thank you - Mike Mike Ford Centre for Speech and Language Department of Experimental Psychology Downing Street Cambridge CB2 3EB Tel: +44 (0) 1223 766559 Fax: +44 (0) 1223 766452 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lmer output
On Fri, 2006-10-06 at 17:05 +0100, Mike Ford wrote: When I do lmer models I only get Estimate, Standard Error and t value in the output for the fixed effects. Is there a way I get degrees of freedom and p values as well? I'm a very new to R, so sorry if this a stupid question. Thank you - Mike See R FAQ 7.35 Why are p-values not displayed when using lmer()? http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-are-p_002dvalues-not-displayed-when-using-lmer_0028_0029_003f HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sparklines in lattice
On 10/6/06, Mark Difford [EMAIL PROTECTED] wrote: Dear R-help, Has anyone implemented sparklines in the strips of a lattice plot? What I have in mind is, say, highlighting that part of a time series that one is examining in more detail in a set of lattice plots. It's not particularly hard (at least for me :-)). Here's a possible implementation, which could of course be improved in many ways. PDF output (as well as the code, in case this gets wrapped) available at http://www.stat.wisc.edu/~deepayan/R/spark/ -Deepayan cutAndStack - function(x, number = 6, overlap = 0.1, type = 'l', xlab = Time, ylab = deparse(substitute(x)), ...) { stopifnot(is.ts(x)) if (is.mts(x)) stop(mts not supported, use 'x[, 1]' etc) stopifnot(require(grid)) stopifnot(require(lattice)) tdf - data.frame(.response = as.numeric(x), .time = time(x), .Time = equal.count(as.numeric(time(x)), number = number, overlap = overlap)) strip.ts - function(which.given, which.panel, shingle.intervals, bg = trellis.par.get(strip.background)$col[1], ...) { pushViewport(viewport(xscale = range(tdf$.time), yscale = range(tdf$.response))) panel.fill(col = bg) current.interval - shingle.intervals[which.panel[which.given], ] highlight - cut(tdf$.time, breaks = c(min(shingle.intervals) - 1, current.interval, max(shingle.intervals) + 1)) with(tdf, panel.xyplot(.time, .response, groups = highlight, subscripts = seq(length = nrow(tdf)), type = l, col = c(grey, red, grey), lwd = c(1, 2, 1))) upViewport() } xyplot(.response ~ .time | .Time, data = tdf, type = type, xlab = xlab, ylab = ylab, strip = strip.ts, default.scales = list(x = list(relation = free), y = list(relation = free, rot = 0)), ...) } p - cutAndStack(EuStockMarkets[, 1], aspect = xy, scales = list(x = list(draw = FALSE))) p update(p[3], par.strip.text = list(lines = 3), scales = list(x = list(draw = TRUE, at = 1991:1999))) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Stopping ctrl-\ from qutting R
Hi, In the Linux (FC3) version of R, ctrl-\ quits R. This wouldn't be so bad, but on my keyboard, it's right next to ctrl-p and I tend to hit it by accident. Is there any way to turn that off? Best, Martin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] new version of mclust available
A new version of mclust is now available as a contributed package on CRAN. The associated manual is located at http://www.stat.washington.edu/www/research/reports/2006/tr504.pdf The main feature in terms of new functionality is the option to include a Bayesian prior in the mixture model for regularization. The older version is still available mclust02 for those who need backward compatibility. Chris Fraley Department of Statistics University of Washington ___ R-packages mailing list R-packages@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stopping ctrl-\ from qutting R
Martin C. Martin wrote: In the Linux (FC3) version of R, ctrl-\ quits R. This wouldn't be so bad, but on my keyboard, it's right next to ctrl-p and I tend to hit it by accident. And what is the use of ctrl-p? Alberto Monteiro __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stopping ctrl-\ from qutting R
previous command. Very helpful when you want to repeat something you recently did, perhaps after modifying it a bit. - Martin Alberto Monteiro wrote: Martin C. Martin wrote: In the Linux (FC3) version of R, ctrl-\ quits R. This wouldn't be so bad, but on my keyboard, it's right next to ctrl-p and I tend to hit it by accident. And what is the use of ctrl-p? Alberto Monteiro __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stopping ctrl-\ from qutting R
Alberto Monteiro [EMAIL PROTECTED] writes: Martin C. Martin wrote: In the Linux (FC3) version of R, ctrl-\ quits R. This wouldn't be so bad, but on my keyboard, it's right next to ctrl-p and I tend to hit it by accident. And what is the use of ctrl-p? Same as up-arrow, but some people are more comfortable touch-typing control characters. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stopping ctrl-\ from qutting R
On Fri, 2006-10-06 at 14:46 -0400, Martin C. Martin wrote: Hi, In the Linux (FC3) version of R, ctrl-\ quits R. This wouldn't be so bad, but on my keyboard, it's right next to ctrl-p and I tend to hit it by accident. Is there any way to turn that off? Open your favorite terminal emulator (ie. gnome-terminal, xterm, konsole) and type: stty quit undef then type: R The first command will disable the QUIT signal within the tty session, which by default is set to CTRL-\. This will not change other console sessions. Of course this behavior may introduce other problems. :-) BTW, you might want to consider updating your FC distro, as FC3 is now EOL and only supported by the Fedora Legacy folks. That support will end on December 31. At this point of course, you might just want to wait until FC 6 is out sometime in the next week or so. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Sum of Bernoullis with varying probabilities
Hi Folks, Given a series of n independent Bernoulli trials with outcomes Yi (i=1...n) and Prob[Yi = 1] = Pi, I want P = Prob[sum(Yi) = r] (r = 0,1,...,n) I can certainly find a way to do it: Let p be the vector c(P1,P2,...,Pn). The cases r=0 and r=n are trivial (and also are exceptions for the following routine). For a given value of r in (1:(n-1)), library(combinat) Set - (1:n) Subsets - combn(Set,r) P - 0 for(i in (1:dim(Subsets)[2])){ ix - numeric(n) ix[Subsets[,i]] - 1 P - P + prod((p^ix) * ((1-p)^(1-ix))) } OK, some abbreviation of the above can be achieved with the 'apply' function (and I've spelt out the details for clarity). But I feel the basis of the approach (i.e. 'combn') is crude (also tending to cause problems if n is large); and I'm wondering if there is a nicer way. And also wondering if someone has implemented it! Statutory Declaration: I have been on to R Site Search. Best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 06-Oct-06 Time: 20:29:02 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stopping ctrl-\ from qutting R
Thanks! I put it in my .bashrc, now it will never bother me again. Marc Schwartz (via MN) wrote: BTW, you might want to consider updating your FC distro, as FC3 is now EOL Unfortunately, this is my work machine and they're still using FC3. Although I've heard various grumblings about it, so maybe that will change some day... Best, Martin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] mcmcsamp-CI instead of P-values - references?
Henrik Parn henrik.parn at bio.ntnu.no writes: Dear all, Given the discussions and issues of d.f., p-values and mcmcsamp-CIs in mixed models, I wonder if anyone could recommend one or two papers (or other citable sources for that sake) that summarizes the arguments for/against P-values/mcCIs. I have followed the discussions on R-help and have learnt a lot (in my naive non-statistician way). With all respect to all great contributions, I may need published articles (if there are any), that could be suitable to use in the Methods-section of a manuscript, to motivate a no-p-values-but-some-nice-mcmcsampCIs-instead-approach! Book (Bayesian Data Analysis) by Gelman et al. is very good source of this and much more. You might also find his papers and blog interesting http://www.stat.columbia.edu/~gelman/ http://www.stat.columbia.edu/~gelman/blog/ Gregor __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] is it possible to fill with a color or transparency gradient?
Hi all, Is there a way to fill a rectangle or polygon with a color and/or transparency gradient? This would be extremely useful for me in terms of adding some additional information to some plots I'm making, especially if I could define the gradient on my own by putting functions into rgb something like rgb( r=f(x,y), g=f(x,y), b=f(x,y), alpha=f(x,y) ). Not so important whether the coordinates are in terms of the plot axes or normalized to the polygon itself somehow. Ideally it would work not only for a fill color but also for shading lines. I haven't been using R very long, so it's possible that I'm just missing something, but I haven't found anything like this in the help files. I've tried to poke around in graphics, grid, and ggplot, without any luck so far. I really like some of the functionality in ggplot, and it does some nice things with continuous gradients for the color of scatter plot points, for example, but it each individual point (or grob) is always one solid color as far as I can tell. Thanks, Eric __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Nonlinear mixed effects model
In nonlinear mixed effects models, SAS doesn't allow for free manipulation of the covariance matrix (you can only specify a type, and our type doesn't exist). Can R accomplish this? For example: Parameters: B1= Beta 1i B2= Beta 2i G1= Gamma i y = B1 -(B1 - B2) exp { - G1 time} + e the covariance matrix for (B1 [( covB1? covB1B2 covB1G1 B2~ covB2B1covB2? covB2G1 G1) covG1B1 covG1B2 covG1? )] **If we want to specify covG1B1 and make everything else 0's, for example, what would the code look like? Thanks for your time. -- View this message in context: http://www.nabble.com/Nonlinear-mixed-effects-model-tf2397889.html#a6686679 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] is it possible to fill with a color or transparency gradient?
On Fri, 2006-10-06 at 16:15 -0400, Eric Harley wrote: Hi all, Is there a way to fill a rectangle or polygon with a color and/or transparency gradient? This would be extremely useful for me in terms of adding some additional information to some plots I'm making, especially if I could define the gradient on my own by putting functions into rgb something like rgb( r=f(x,y), g=f(x,y), b=f(x,y), alpha=f(x,y) ). Not so important whether the coordinates are in terms of the plot axes or normalized to the polygon itself somehow. Ideally it would work not only for a fill color but also for shading lines. I haven't been using R very long, so it's possible that I'm just missing something, but I haven't found anything like this in the help files. I've tried to poke around in graphics, grid, and ggplot, without any luck so far. I really like some of the functionality in ggplot, and it does some nice things with continuous gradients for the color of scatter plot points, for example, but it each individual point (or grob) is always one solid color as far as I can tell. Thanks, Eric Take a look at the gradient.rect() function in Jim Lemon's 'plotrix' CRAN package. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to check object size in workspace
hi, I tried to keep my workspace as small as possible when i tried to save.image(). Sometimes, I am not sure whether obj in workspace will be needed in future or not. However, I want to delete some big ones when I use save.image(). BTW, I know I could use save, but I would like to know : how to check objects' size (the size when I try to save it in disk) in workspace, anyway. thanks, -- Weiwei Shi, Ph.D Research Scientist GeneGO, Inc. Did you always know? No, I did not. But I believed... ---Matrix III __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Once again: aov vs. lme/lmer
First of all, I apologize for asking a question that has appeared recurrently in this mailing list. However, I have googled for it, have looked at the mailing list archives, and also looked at Pinheiro Bates book (although not very thoroughly, I must confess), to no avail. Here is the question: I am trying to obtain with lme or lmer the same exact numerical results (p-values) that I obtain with aov. Consider the following data: d - data.frame (a = factor (rep (c (1, 2), c(10, 10))), b = factor (rep (rep (c (1, 2), c(5, 5)),2)), s = factor (rep (1 : 5, 4)), v = rnorm (20)) Let us say that this comes from a repeated measures experiments where all five subjects (factor s) were tested in all combinations of the two fixed factors a and b. With aov, for a model were s, s:a, s:b and s:a:b are random, and a*b are fixed terms, I would use: aov (v ~ a*b + Error (s / (a*b)), data = d) Is there a way to get the same results using lme or lmer? How should I write my random argument in lme or the (...|...) terms in lmer? Please notice that I am not interested in philosophical discussions about whether I am trying to do wrong things. I would only like to know whether a given R function could be used in place of another R function. Thanks in advance for your help, -- Rafael Laboissiere __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Row comparisons to a new matrix?
Hi, Can somebody tell me, which is the fastest way to make comparisons between all rows in a matrix (here A) and put the results to the new symmetric matrix? I have here used cosine distance as an example, but the comparison function can be any other, euclidean dist etc. A=rbind(c(2,3),c(4,5),c(-1,2),c(5,6)) M=matrix(nrow=length(A[,1]),ncol=length(A[,1])) for(i in 1:length(A[,1])) { for(j in 1:length(A[,1])) { M[i,j]=cosine(A[i,],A[j,]) } } Atte Tenkanen University of Turku, Finland __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sum of Bernoullis with varying probabilities
On 10/6/06, Ted Harding [EMAIL PROTECTED] wrote: Hi Folks, Given a series of n independent Bernoulli trials with outcomes Yi (i=1...n) and Prob[Yi = 1] = Pi, I want P = Prob[sum(Yi) = r] (r = 0,1,...,n) I can certainly find a way to do it: Let p be the vector c(P1,P2,...,Pn). The cases r=0 and r=n are trivial (and also are exceptions for the following routine). For a given value of r in (1:(n-1)), library(combinat) Set - (1:n) Subsets - combn(Set,r) P - 0 for(i in (1:dim(Subsets)[2])){ ix - numeric(n) ix[Subsets[,i]] - 1 P - P + prod((p^ix) * ((1-p)^(1-ix))) } Don't you want to multiply this with factorial(r) * factorial(n-r)? I assume combn() gives all combinations and not all permutations, in which case you are only counting prod((p^ix) * ((1-p)^(1-ix))) once instead of all the different ways in which ix could be permuted without changing it. OK, some abbreviation of the above can be achieved with the 'apply' function (and I've spelt out the details for clarity). But I feel the basis of the approach (i.e. 'combn') is crude (also tending to cause problems if n is large); and I'm wondering if there is a nicer way. I don't see how. Someone has to evaluate the n-choose-r distinct terms to be added, and your code seems to be doing that as directly as possible. Just for fun, here's a cute but very inefficient implementation using recursion (even n=8 is very slow): u - function(n, r, p) { if (r == 0) return(prod(1-p)) if (r == n) return(prod(p)) ans - 0 for (i in 1:n) { ans - ans + p[i] * u(n-1, r-1, p[-i]) + (1 - p[i]) * u(n-1, r, p[-i]) } ans / n } -Deepayan And also wondering if someone has implemented it! Statutory Declaration: I have been on to R Site Search. Best wishes to all, Ted. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Row comparisons to a new matrix?
?dist Bert Gunter Nonclinical Statistics 7-7374 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Atte Tenkanen Sent: Friday, October 06, 2006 1:54 PM To: r-help@stat.math.ethz.ch Subject: [R] Row comparisons to a new matrix? Hi, Can somebody tell me, which is the fastest way to make comparisons between all rows in a matrix (here A) and put the results to the new symmetric matrix? I have here used cosine distance as an example, but the comparison function can be any other, euclidean dist etc. A=rbind(c(2,3),c(4,5),c(-1,2),c(5,6)) M=matrix(nrow=length(A[,1]),ncol=length(A[,1])) for(i in 1:length(A[,1])) { for(j in 1:length(A[,1])) { M[i,j]=cosine(A[i,],A[j,]) } } Atte Tenkanen University of Turku, Finland __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sum of Bernoullis with varying probabilities
Many thanks for your comments, Deepayan; and I liked your recursive solution! Fun indeed. Just a comment (below) on one of your comments (the rest snipped). On 06-Oct-06 Deepayan Sarkar wrote: On 10/6/06, Ted Harding [EMAIL PROTECTED] wrote: Hi Folks, Given a series of n independent Bernoulli trials with outcomes Yi (i=1...n) and Prob[Yi = 1] = Pi, I want P = Prob[sum(Yi) = r] (r = 0,1,...,n) I can certainly find a way to do it: Let p be the vector c(P1,P2,...,Pn). The cases r=0 and r=n are trivial (and also are exceptions for the following routine). For a given value of r in (1:(n-1)), library(combinat) Set - (1:n) Subsets - combn(Set,r) P - 0 for(i in (1:dim(Subsets)[2])){ ix - numeric(n) ix[Subsets[,i]] - 1 P - P + prod((p^ix) * ((1-p)^(1-ix))) } Don't you want to multiply this with factorial(r) * factorial(n-r)? I assume combn() gives all combinations and not all permutations, in which case you are only counting prod((p^ix) * ((1-p)^(1-ix))) once instead of all the different ways in which ix could be permuted without changing it. You had me worried for a moment -- the interplay between perms and combs is always a head-spinner -- but since I'd verified already that I get sum(P)=1 when I do this over all values of r, I had to conclude that your comment must be incorrect. In fact, if you consider the event r out of the n gave Y=1, this can be decomposed into disjoint sub-events subset {1,2,3,...,r} gave Y=1, the rest 0 subset {1,2,3,...,(r-1),(r=1)} gave Y=1, the rest 0. and so on over all choose(n,r) subsets, and the probability of r out of n is the sum of the probabilities of the sub-events. For any one of these (say the first above), the probability is P(Y1=1 Y2=1 ... Yr=1 Y[r+1]=0 ... Y[n]=0) which is simply the product of their probabilities. No further permutation is involved. I hope I've got this right (we'll soon find out if not)! Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 06-Oct-06 Time: 22:15:44 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Row comparisons to a new matrix?
I have to focus my question a little. I'd like to get rid of those for-loops and use, if possible, some faster method for creating the symmetric result matrix. Atte ?dist Bert Gunter Nonclinical Statistics 7-7374 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Atte Tenkanen Sent: Friday, October 06, 2006 1:54 PM To: r-help@stat.math.ethz.ch Subject: [R] Row comparisons to a new matrix? Hi, Can somebody tell me, which is the fastest way to make comparisons betweenall rows in a matrix (here A) and put the results to the new symmetricmatrix? I have here used cosine distance as an example, but the comparison function can be any other, euclidean dist etc. A=rbind(c(2,3),c(4,5),c(-1,2),c(5,6)) M=matrix(nrow=length(A[,1]),ncol=length(A[,1])) for(i in 1:length(A[,1])) { for(j in 1:length(A[,1])) { M[i,j]=cosine(A[i,],A[j,]) } } Atte Tenkanen University of Turku, Finland __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.htmland provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Row comparisons to a new matrix?
There is a generalized inner product here: http://tolstoy.newcastle.edu.au/R/help/05/04/3709.html On 10/6/06, Atte Tenkanen [EMAIL PROTECTED] wrote: Hi, Can somebody tell me, which is the fastest way to make comparisons between all rows in a matrix (here A) and put the results to the new symmetric matrix? I have here used cosine distance as an example, but the comparison function can be any other, euclidean dist etc. A=rbind(c(2,3),c(4,5),c(-1,2),c(5,6)) M=matrix(nrow=length(A[,1]),ncol=length(A[,1])) for(i in 1:length(A[,1])) { for(j in 1:length(A[,1])) { M[i,j]=cosine(A[i,],A[j,]) } } Atte Tenkanen University of Turku, Finland __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sum of Bernoullis with varying probabilities
On 10/6/06, Ted Harding [EMAIL PROTECTED] wrote: Many thanks for your comments, Deepayan; and I liked your recursive solution! Fun indeed. Just a comment (below) on one of your comments (the rest snipped). On 06-Oct-06 Deepayan Sarkar wrote: On 10/6/06, Ted Harding [EMAIL PROTECTED] wrote: Hi Folks, Given a series of n independent Bernoulli trials with outcomes Yi (i=1...n) and Prob[Yi = 1] = Pi, I want P = Prob[sum(Yi) = r] (r = 0,1,...,n) I can certainly find a way to do it: Let p be the vector c(P1,P2,...,Pn). The cases r=0 and r=n are trivial (and also are exceptions for the following routine). For a given value of r in (1:(n-1)), library(combinat) Set - (1:n) Subsets - combn(Set,r) P - 0 for(i in (1:dim(Subsets)[2])){ ix - numeric(n) ix[Subsets[,i]] - 1 P - P + prod((p^ix) * ((1-p)^(1-ix))) } Don't you want to multiply this with factorial(r) * factorial(n-r)? I assume combn() gives all combinations and not all permutations, in which case you are only counting prod((p^ix) * ((1-p)^(1-ix))) once instead of all the different ways in which ix could be permuted without changing it. You had me worried for a moment -- the interplay between perms and combs is always a head-spinner -- but since I'd verified already that I get sum(P)=1 when I do this over all values of r, I had to conclude that your comment must be incorrect. In fact, if you consider the event r out of the n gave Y=1, this can be decomposed into disjoint sub-events subset {1,2,3,...,r} gave Y=1, the rest 0 subset {1,2,3,...,(r-1),(r=1)} gave Y=1, the rest 0. and so on over all choose(n,r) subsets, and the probability of r out of n is the sum of the probabilities of the sub-events. For any one of these (say the first above), the probability is P(Y1=1 Y2=1 ... Yr=1 Y[r+1]=0 ... Y[n]=0) which is simply the product of their probabilities. No further permutation is involved. You are right. The key point I was missing is that the number of distinct _permutations_ of r 1's and (n-r) 0's is choose(n, r) (the places to put the 1's). Sorry for the red herring. Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] is it possible to fill with a color or transparency gradient?
I haven't been using R very long, so it's possible that I'm just missing something, but I haven't found anything like this in the help files. I've tried to poke around in graphics, grid, and ggplot, without any luck so far. I really like some of the functionality in ggplot, and it does some nice things with continuous gradients for the color of scatter plot points, for example, but it each individual point (or grob) is always one solid color as far as I can tell. ggplot supports alpha blending provided your graphics device does too (Quartz on the mac, or pdf version 1.3 or later). Have a look at the alpha function for easily making transparent colours, as well as scgradient for specifying the colour scale. Oh, I see you want a gradient fill on a polygon - that's a lot harder, and I can only suggest dividing your polygon up into smaller rectangles and filling those individually. That appears to be what gradient.rect does. Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to check object size in workspace
Weiwei Shi helprhelp at gmail.com writes: hi, I tried to keep my workspace as small as possible when i tried to save.image(). Sometimes, I am not sure whether obj in workspace will be needed in future or not. However, I want to delete some big ones when I use save.image(). BTW, I know I could use save, but I would like to know : how to check objects' size (the size when I try to save it in disk) in workspace, anyway. Take a look at ?object.size and also in ?ll in gdata package Gregor __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Block comments in R?
Hi all, Indeed, block comment is more clean and elegant than line by line. If the R interpreter will recognizes it (I'm not sure if already recognizes), we will spend no more than few hours to make the syntax of the main editors compatible, isn't it? Regards, -- Jose Claudio Faria Brasil/Bahia/Ilheus/UESC/DCET Estatística Experimental/Prof. Adjunto mails: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] tel: 73-3634.2779 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] DBI, RMySQL, RSQLite updated
Hello all, Just uploaded to CRAN updates for RSQLite, RMySQL, and DBI. The primary svn repository for these packages is now hosted by the Gentleman Lab in Seattle and our group is working with David James to help with maintenance. Details on the updates are below. RMySQL_0.5-9.tar.gz * Fixed unclosed textConnections RSQLite_0.4-4.tar.gz * Upgraded to SQLite 3.3.7 * Default when building from source is now to compile the included version of SQLite and link to it statically * Fixed unclosed textConnections DBI_0.1-11.tar.gz * Minor updates in package structure (no feature changes). Best Wishes, + seth -- Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center http://bioconductor.org ___ R-packages mailing list R-packages@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] gregexpr in R 2.3.0 != gregexpr in R 2.4.0
Hi all I have a question regarding differences in the way gregpexr works in R 2.3.0 and R 2.4.0. In R 2.3.0, this is what happens: gregexpr( [a-z] [a-z] , a b c d e f , perl=T) [[1]] [1] 1 3 5 7 9 attr(,match.length) [1] 5 5 5 5 5 ... while in R 2.4.0, this is what happens: gregexpr( [a-z] [a-z] , a b c d e f , perl=T) [[1]] [1] 1 7 attr(,match.length) [1] 5 5 Looking at the archives, I came across these sites where the reverse issue has been discussed before: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/75843.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/76815.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/75846.html From there, it seems as if the first result has been considered undesirable (apparently because it differs from Perl's output if not also for other reasons) and R. Gentleman wrote that [t]his has been reverted in R-devel, so you should get the old behavior in it. However, (i) I could not find any announcement of that change in the change log (the news file at https://svn.r-project.org/R/trunk/NEWS or at http://cran.r-project.org/src/base/NEWS) so I am still not sure whether this change of behavior is in fact due to changes by the R Development Core Team or not. So, first question: is this change intended or not? (My system has not changed otherwise.) (ii) Since for some applications of mine the first behavior above was exactly what I needed, I now have the same (second) question as Thomas Girke before: is there a way to get the first of the two results now in R 2.4.0 (on a Windows XP machine)? Thanks a lot, STG __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] gregexpr in R 2.3.0 != gregexpr in R 2.4.0
You can get that by using zero width lookahead assertions. They must match but are not consuming so the next match will not be forced to start past them. See ?regex and http://www.regular-expressions.info/lookaround.html for more. gregexpr( [a-z](?= [a-z] ), a b c d e f , perl = TRUE) On 10/6/06, Stefan Th. Gries [EMAIL PROTECTED] wrote: Hi all I have a question regarding differences in the way gregpexr works in R 2.3.0 and R 2.4.0. In R 2.3.0, this is what happens: gregexpr( [a-z] [a-z] , a b c d e f , perl=T) [[1]] [1] 1 3 5 7 9 attr(,match.length) [1] 5 5 5 5 5 ... while in R 2.4.0, this is what happens: gregexpr( [a-z] [a-z] , a b c d e f , perl=T) [[1]] [1] 1 7 attr(,match.length) [1] 5 5 Looking at the archives, I came across these sites where the reverse issue has been discussed before: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/75843.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/76815.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/75846.html From there, it seems as if the first result has been considered undesirable (apparently because it differs from Perl's output if not also for other reasons) and R. Gentleman wrote that [t]his has been reverted in R-devel, so you should get the old behavior in it. However, (i) I could not find any announcement of that change in the change log (the news file at https://svn.r-project.org/R/trunk/NEWS or at http://cran.r-project.org/src/base/NEWS) so I am still not sure whether this change of behavior is in fact due to changes by the R Development Core Team or not. So, first question: is this change intended or not? (My system has not changed otherwise.) (ii) Since for some applications of mine the first behavior above was exactly what I needed, I now have the same (second) question as Thomas Girke before: is there a way to get the first of the two results now in R 2.4.0 (on a Windows XP machine)? Thanks a lot, STG __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] gregexpr in R 2.3.0 != gregexpr in R 2.4.0
On 10/6/2006 10:00 PM, Stefan Th. Gries wrote: Hi all I have a question regarding differences in the way gregpexr works in R 2.3.0 and R 2.4.0. In R 2.3.0, this is what happens: gregexpr( [a-z] [a-z] , a b c d e f , perl=T) [[1]] [1] 1 3 5 7 9 attr(,match.length) [1] 5 5 5 5 5 ... while in R 2.4.0, this is what happens: gregexpr( [a-z] [a-z] , a b c d e f , perl=T) [[1]] [1] 1 7 attr(,match.length) [1] 5 5 Looking at the archives, I came across these sites where the reverse issue has been discussed before: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/75843.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/76815.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/75846.html From there, it seems as if the first result has been considered undesirable (apparently because it differs from Perl's output if not also for other reasons) and R. Gentleman wrote that [t]his has been reverted in R-devel, so you should get the old behavior in it. However, (i) I could not find any announcement of that change in the change log (the news file at https://svn.r-project.org/R/trunk/NEWS or at http://cran.r-project.org/src/base/NEWS) so I am still not sure whether this change of behavior is in fact due to changes by the R Development Core Team or not. So, first question: is this change intended or not? (My system has not changed otherwise.) If you really want to be sure to see where a change occurred, you should look in the Subversion log (on developer.r-project.org). I think the changes here were likely made in revisions 37228 on February 1 2006 and 38145 on May 20 2006. Both were made to the trunk, but in the case of the first one, that was 2.3.0, and in the second it was 2.4.0. If these changed behaviour there should have been an entry in the NEWS file, but apparently that was overlooked. (ii) Since for some applications of mine the first behavior above was exactly what I needed, I now have the same (second) question as Thomas Girke before: is there a way to get the first of the two results now in R 2.4.0 (on a Windows XP machine)? I don't know. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.