[R] Wilcoxon test for mixed design (between-within subjects)
Hallo, is there any extension of the pairwise Wilcoxon test to a dependent samples layout with replicates (or, in other terms, a one-way layout with blocking and replicates)? The Wilcoxon method with matched pairs works for the case of dependent samples with one observation per block, while the Mann-Whitney test works for independent samples, thus one single block and replicated observations. Is there a method which mixes this two cases considering a depedent sample design in which each block has more than one observation? I know it exists a Friedman test for this case but in the Friedman test ranks are constructed considering all subjects jointly, while in Wilcoxon only the pair of subject currently considered are ranked, thus resulting in a more powerful test. If no such method exists in R, I am anyway intersted in possible references. Thank you for the consideration, Regards, Marco __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] statistical test improvement of readability (was average disjunction)
Dear all ReadeRs I was finding a quick method to improve test readability adding or constructing (with your help) one or more function that allow what follow. Please consider Trt-c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5) Block-c(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4) AD2DAT-c(1.44,2.32,1.68,1.28,0.12,0.08,0.24,0.52,0.12,0.08,0.16,0.28,0.16,0.08,0.12,0.12,0.16,0.08,0.32,0.76) Tab-cbind(Trt,Block,AD2DAT);Tab AD2DAT.aov.lm-aov(lm(AD2DAT~as.factor(Block)+as.factor(Trt),method=qr)) TukeyHSD(AD2DAT.aov.lm,as.factor(Trt),ordered=TRUE,conf.level=.95) TukeyHSD(AD2DAT.aov.lm,as.factor(Trt),ordered=TRUE,conf.level=.99) TabMEANS-aggregate(Tab,list(Trt),FUN=mean);TabMEANS Group.1 Trt Block AD2DAT 1 12.5 1.68 22 2.5 0.24 3 3 2.5 0.16 4 4 2.5 0.12 5 5 2.5 0.33 So I'm thinking that was more readable something like one function that permit me to juxtapose tiny letters when we are talking about .95 confidence level and capital letters when we are talking about .99 confidence level so results will be approx this Group.1 Trt Block AD2DAT .95 .99 1 12.5 1.68 a A 22 2.5 0.24 b B 3 3 2.5 0.16b B 4 4 2.5 0.12b B 5 5 2.5 0.33b B Does anyone have suggestion??? Thanks in advance!! - Landini dr. Massimiliano Tel. mob. (+39) 347 140 11 94 Tel./Fax. (+39) 051 762 196 e-mail: numero (dot) primo (at) tele2 (dot) it - Legge di Hanggi: Più stupida è la tua ricerca, più verrà letta e approvata. Corollario alla Legge di Hanggi: Più importante è la tua ricerca, meno verrà capita. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Plotting with Statistics::R, Perl/R
Peter Dalgaard wrote: d) Use bitmap(). It requires a working Ghostscript install, but is otherwise much more convenient. Newer versions of Ghostscript have some quite decent antialiasing built into some of the png devices. Currently you need a small hack to pass the extra options to Ghostscript -- we should probably add a gsOptions argument in due course. This works for me on FC3 (Ghostscript 7.07): mybitmap(file=foo.png, type=png16m, gsOptions= -dTextAlphaBits=4 -dGraphicsAlphaBits=4 ) where mybitmap() is a modified bitmap() that just sticks the options into the command line. There are definitely better ways... [The antialiasing is not quite perfect. In particular, the axes stand out from the box around plots, presumably because an additive model is used (so that if you draw a line on top of itself, the result becomes darker). Also, text gets a little muddy at the default 9pt @ 72dpi, so you probably want to increase the pointsize or the resolution.] Apart from the significant quality issues which you mention, the other problem with using bitmap() in a Web server environment is the speed issue - it takes much longer to produce the output. Whether it takes too long depends on the users of your Web application, and how many simultaneous users there are. However, most users are more worried by the poor quality of the fonts in output produced by bitmap(). Tim C __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] printing PCA scores
Hey folks, I have an environmental dataset on which I conducted a PCA (prcomp) and I need the scores of this PCA for each site (=each row) to conduct further analyses. Can you please help me with that? Thanks a lot Jérôme Lemaître __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] survreg: fitting different location parameters
Hi R-Help! My question: I have lifetime/failure data of machines with different stress levels and i think an weibull/extreme value distribution would fit this data. So I did: model1 - survreg(Surv(lfailure)~stress,data=steel,dist=extreme) (where lfailure=log(failure)) Now I would like to do a likelihood ratio test to test the hypothesis H0: location parameters of the extreme value distribution are equal for each stress level. So in order to perform the likelihood ratio test I need the likelood of the model under HA: location parameters are not equal (i.e. each stress level has its slope and intercept). How can I do this? Thanks for any help! Hadassa __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] scan command
I am using the scan command to read a file I called data1. The program returns Error in file(file,r) : unable to open connection In addition: Warning message: cannot open file 'data1' I already checked to see if the starting directory in R was correct and it is. Also, the file opens ok from its directory so it isn't corrupted. Does someone have an idea? [[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
[R] comparing glmmPQL models
Dear R users, Is there a way to compare glmmPQL models differing in their fixed-effects structure (similar to the ANOVA approach in lme) ? Thank you very much for your help! Chris. This mail was sent through http://webmail.uni-jena.de __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] survreg: fitting different location parameters
Hi R-Help! My question: I have lifetime/failure data of machines with different stress levels and i think an weibull/extreme value distribution would fit this data. So I did: model1 - survreg(Surv(lfailure)~stress,data=steel,dist=extreme) (where lfailure=log(failure)) Now I would like to do a likelihood ratio test to test the hypothesis H0: location parameters of the extreme value distribution are equal for each stress level. So in order to perform the likelihood ratio test I need the likelood of the model under HA: location parameters are not equal (i.e. each stress level has its slope and intercept). How can I do this? Thanks for any help! Hadassa __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Hardware Suggestions
We've been running servers with AMD Opterons (both duals and 4-ways) using SuSE SLES 8 and Fedora Core 2 and 3 (64 bit). All work well and R can access up to ~15GB of RAM on our 4-way machine (which has 16GB installed). One of the Red Hat Enterprise Linux versions comes with a buggy compiler but I can't remember which version (there is some discussion on the R-devel mailing list archives). Watch out for that. I think using gcc 3.4.x solves that problem. R pretty much compiles out of the box on AMD Opteron/Fedora Core 3 (64-bit) Linux. We've been very happy with our R experience so far. -roger Jon Dressel wrote: We are currently running R under Windows 2000 on a server box running with 2 1.2 GHZ Intel Pentium III Processors. We would like to run this on a new computer running Linux and receive a significant speed increase over our current implementation. Could anyone provide some suggestions for a fast 64 BIT Intel based processor computer with a recommendation for memory and speed/type/number of processors. Also which version of R would install out-of-the-box easily on this computer and what version of Linux should be used? Thanks in advance for any help. Jon Dressel, MCSE MCSA MCP A+?xml:namespace prefix = o ns = urn:schemas-microsoft-com:office:office / Applications Supervisor SurroMed, Inc. 1430 O'Brien Drive Menlo Park, CA 94025 Phone: 650.470.2322 Fax: 650.470.2400 email: [EMAIL PROTECTED] [[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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] error preparing a package for lazy loading with R CMD
Dear Lister, I work with R 2.0.1 and Windows XP, and meet a strange trouble trying to make a R package with a make-package.bat file John Fox has kindly provided (see detailed script below). I am working with it since some months with excellent results (I do'nt use compiled C code so far). Just adding a new function in the R directory today, when running make-package and thus excuting the command ..\..\bin\R CMD build --force --binary --auto-zip %1, I got the following message after the compile stage, preparing the package for lazy loading : preparing package pgirmess for lazy loading Error in names-.default(`*tmp*`, value =c(R, Platform, Date, : names attribute[4] must be the same length as the vector [1] Execution halted make: ***[lazyload] Error 1 *** Installation of pgirmess failed *** (pgirmess is the package name) ... and the zip file is not generated. I have checked and rechecked everything during this (long) afternoon... and get nothing except that if I drag out any of the *.r file of the R folder, everything comes to be OK (except the function that has been dragged out is missing...). It looks like if having added one extra function in the R folder on the top of the earlier 32 (+ 2 data frames) makes problem. I have then consulted John Fox offlist and he seems quite perplexed I'm not sure why you're experiencing this problem. On his advise I have included LazyLoad: no in the package description file. In this case everything goes smoothly then (except LazyLoad will not be activated), the zip file is generated and the package can be installed from R. Has anybody an idea about why a problem occurs when preparing the package for lazy loading? Any remedy? Kind regards, Patrick Make-Package script: cd c:\R\rw2001\src\library del %1\INDEX del %1\data\00Index del %1\chm\*.* /Q ..\..\bin\R CMD build --force --binary --auto-zip %1 ..\..\bin\R CMD build --force %1 ..\..\bin\R CMD check %1 cd %1.Rcheck dvipdfm %1-manual notepad 00check.log cd .. cd .. From: John Fox [EMAIL PROTECTED] To: 'Patrick Giraudoux H' [EMAIL PROTECTED] Subject: RE: [R] writing a simple package in R 2.0 under Windows XP Date: Sun, 23 Jan 2005 11:41:25 -0500 X-Mailer: Microsoft Office Outlook, Build 11.0.6353 X-MIME-Autoconverted: from quoted-printable to 8bit by utinam.univ-fcomte.fr id j0NGfJoD011345 Dear Patrick, I'm not sure why you're experiencing this problem. Two suggestions: (1) Since the problem appears to be with preparing the package for lazy loading, try adding the directive LazyLoad: no (without the quotes) to the package's DESCRIPTION file. (2) Rather than using my batch file, run the commands one at a time to see exactly where the problem is produced; then you could send a message to r-help. I hope this helps, John __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] survreg: fitting different location parameters
Hi R-Help! My question: I have lifetime/failure data of machines with different stress levels and i think an weibull/extreme value distribution would fit this data. So I did: model1 - survreg(Surv(lfailure)~stress,data=steel,dist=extreme) (where lfailure=log(failure)) Now I would like to do a likelihood ratio test to test the hypothesis H0: location parameters of the extreme value distribution are equal for each stress level. So in order to perform the likelihood ratio test I need the likelood of the model under HA: location parameters are not equal (i.e. each stress level has its slope and intercept). How can I do this? Thanks for any help! Hadassa __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] read data from a file and vector expansion
hello, if i need to read data from a file one line and one how can do? I am using lines - (input.txt) so that now the variable lines holds all the data in my file and i am using for loop to loop each lines[i] to get each line. for exmaple, right now my lines[i] = 1 2 3 44 54 23 24 I am wonder how can i get each integer from ines[i], and how can i put each ingeter into a vector so that my vector i can hold all the data i want. I was thinking using a table to hold my data, but right now i think it is impossible because my data file is not in good table format, also my data file is too long which is about 60,000 pages. the second question is that: i want to declare some vectors to hold the data that I read from the file, so when i read one data from the file then i add one to the vectors. Example, if right now I have a vector called v - (10 3 8 5 9), then i have a data 23 from the file, how i can add 23 to the vector without changing or deleting the previous data in my vector. Thank you so much for all your help. C-ming Jan 23, 2005 - [[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
[R] How to use identify
I can't get identify to work, using R 2.0.1 under windows xp pro, service pack 2. Here's what I enter, and the result: plot((our.frame2$c1),(our.frame2$c9)) # Produces desired plot identify(our.frame2$c1) # Plot comes to forefront, so I select a point warning: no point with 0.25 inches numeric(0) Is my call to identify correct? The help page for indentify (from ?identify) doesn't give any examples, so I don't know what the x should be. I right click right on top of one of the points, then left click and select stop. Thanks for any help. Dave Parkhurst __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] package dependency error on loading lme4
Hi all, I recently (today) updated the Matrix package and installed the latticeExtra package, but then when I tried to load the lme4 package, I got the following error message:- library(lme4) Loading required package: Matrix Loading required package: latticeExtra Error in importIntoEnv(impenv, impnames, ns, impvars) : object(s) '.__C__lmeRep' are not exported by 'namespace:Matrix' Error in library(lme4) : package/namespace load failed for 'lme4' ??? I'm running R 2.0.1 under WinXP as follows R.Version() $platform [1] i386-pc-mingw32 $arch [1] i386 $os [1] mingw32 $system [1] i386, mingw32 $status [1] $major [1] 2 $minor [1] 0.1 $year [1] 2004 $month [1] 11 $day [1] 15 $language [1] R Cheers, Duncan * Dr. Duncan Mackay School of Biological Sciences Flinders University GPO Box 2100 Adelaide S.A.5001 AUSTRALIA Ph (08) 8201 2627FAX (08) 8201 3015 http://www.scieng.flinders.edu.au/biology/people/mackay_d/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
Re: [R] printing PCA scores
On Sat, 2005-01-22 at 17:31 -0500, Jérôme Lemaître wrote: Hey folks, I have an environmental dataset on which I conducted a PCA (prcomp) and I need the scores of this PCA for each site (=each row) to conduct further analyses. Can you please help me with that? Did you try help(prcomp) ? It says that prcomp (may) return an item called 'x': x: if 'retx' is true the value of the rotated data (the centred (and scaled if requested) data multiplied by the 'rotation' matrix) is returned. [non-matching parentheses in the original help file] So this is what you asked for. cheers, jari oksanen -- Jari Oksanen [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
Re: [R] scan command
Hi Olivia On 22 Jan 2005 at 20:55, Olivia Fant wrote: I am using the scan command to read a file I called data1. The program returns Error in file(file,r) : unable to open connection In addition: Warning message: cannot open file 'data1' I am not exactly sure but either your file is locked by some program or your data1 has an extension which your OS (probably Windows) hides and which you need to use or data1 is in different directory Do you see it through choose.files() ? Cheers Petr I already checked to see if the starting directory in R was correct and it is. Also, the file opens ok from its directory so it isn't corrupted. Does someone have an idea? [[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 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
[R] mcnemar.test odds ratios, CI, etc.
Does anyone know of another version of the Mcnemar test that provides: 1. Odds Ratios 2. 95% Confidence intervals of the Odds Ratios 3. Sample probability 4. 95% Confidence intervals of the sample probability Obviously the Odds Ratios and Sample probabilities are easy to calculate from the contingency table, but I would appreciate any help on how to calculate the confidence intervals. Below is a simple example of the test, and the corresponding output with the function mcnemar.test. xtabs(~PLC50.T1+PLC50.T2,data=LANCET.DAT) PLC50.T2 PLC50.T1 0 1 0 464 22 1 6 1 mcnemar.test(xtabs(~PLC50.T1+PLC50.T2,data=LANCET.DAT)) McNemar's Chi-squared test with continuity correction data: xtabs(~PLC50.T1 + PLC50.T2, data = LANCET.DAT) McNemar's chi-squared = 8.0357, df = 1, p-value = 0.004586 Paul [[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
Re: [R] read data from a file and vector expansion
__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to use identify
__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to use identify
Does this work for you? x - runif(30) y - runif(30) z - 1:30 plot(x,y) identify(x,y,z) That is you need to tell it everything it is looking for. Sometimes x is boy x and y because they use xy.coords Tom David Parkhurst wrote: I can't get identify to work, using R 2.0.1 under windows xp pro, service pack 2. Here's what I enter, and the result: plot((our.frame2$c1),(our.frame2$c9)) # Produces desired plot identify(our.frame2$c1) # Plot comes to forefront, so I select a point warning: no point with 0.25 inches numeric(0) Is my call to identify correct? The help page for indentify (from ?identify) doesn't give any examples, so I don't know what the x should be. I right click right on top of one of the points, then left click and select stop. Thanks for any help. Dave Parkhurst __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to use identify
David Parkhurst wrote: I can't get identify to work, using R 2.0.1 under windows xp pro, service pack 2. Here's what I enter, and the result: plot((our.frame2$c1),(our.frame2$c9)) # Produces desired plot identify(our.frame2$c1) # Plot comes to forefront, so I select a point warning: no point with 0.25 inches numeric(0) Is my call to identify correct? The help page for indentify (from ?identify) doesn't give any examples, so I don't know what the x should be. I right click right on top of one of the points, then left click and select stop. Thanks for any help. Dave Parkhurst You forgot to pass in your y coordinates in your call to identify(). You can only leave off the y argument in certain circumstances (see ?identify) Here's an example: xdat - rnorm(10) ydat - rnorm(10) plot(xdat, ydat) identify(xdat, ydat) So you need: plot(our.frame2$c1, our.frame2$c9) # you don't need the extra brackets identify(our.frame2$c1, our.frame2$c9) G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [T] +44 (0)20 7679 5522 ENSIS Research Fellow [F] +44 (0)20 7679 7565 ENSIS Ltd. ECRC [E] gavin.simpsonATNOSPAMucl.ac.uk UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/ 26 Bedford Way[W] http://www.ucl.ac.uk/~ucfagls/ London. WC1H 0AP. %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] package dependency error on loading lme4
[EMAIL PROTECTED] wrote: Hi all, I recently (today) updated the Matrix package and installed the latticeExtra package, but then when I tried to load the lme4 package, I got the following error message:- library(lme4) Loading required package: Matrix Loading required package: latticeExtra Error in importIntoEnv(impenv, impnames, ns, impvars) : object(s) '.__C__lmeRep' are not exported by 'namespace:Matrix' Error in library(lme4) : package/namespace load failed for 'lme4' Confirmed. There are new versions of Matrix and lme4 in the sources area of CRAN. They will probably appear in the Windows repository within 24 hours. Please check again with the new versions tomorrow. Uwe Ligges ??? I'm running R 2.0.1 under WinXP as follows R.Version() $platform [1] i386-pc-mingw32 $arch [1] i386 $os [1] mingw32 $system [1] i386, mingw32 $status [1] $major [1] 2 $minor [1] 0.1 $year [1] 2004 $month [1] 11 $day [1] 15 $language [1] R Cheers, Duncan * Dr. Duncan Mackay School of Biological Sciences Flinders University GPO Box 2100 Adelaide S.A.5001 AUSTRALIA Ph (08) 8201 2627FAX (08) 8201 3015 http://www.scieng.flinders.edu.au/biology/people/mackay_d/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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Wilcoxon test for mixed design (between-within subjects)
Hallo Marco Marco Chiarandini writes: Hallo, is there any extension of the pairwise Wilcoxon test to a dependent samples layout with replicates (or, in other terms, a one-way layout with blocking and replicates)? There is always the possibility to summarize the replicates and then calculate a common pairwise Wilcoxon test. The Wilcoxon method with matched pairs works for the case of dependent samples with one observation per block, while the Mann-Whitney test works for independent samples, thus one single block and replicated observations. Is there a method which mixes this two cases considering a depedent sample design in which each block has more than one observation? I know it exists a Friedman test for this case but in the Friedman test ranks are constructed considering all subjects jointly, while in Wilcoxon only the pair of subject currently considered are ranked, thus resulting in a more powerful test. The Friedman test calculates the ranks inside of the blocks, for each block separately and is not considering all subjects jointly. In R implemented is the case with unreplicated blocked data, so this doesn't help you. If no such method exists in R, I am anyway intersted in possible references. Look at: Myles Hollander Douglas A. Wolfe (1999), _Nonparametric statistical methods_. New York: John Wiley Sons. There you find the generalization of the replicated case, but you have to implement it. Regards, Christoph Buser -- Christoph Buser [EMAIL PROTECTED] Seminar fuer Statistik, LEO C11 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-5414 fax: 632-1228 http://stat.ethz.ch/~buser/ -- Thank you for the consideration, Regards, Marco __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] functions not found after installing DBI/RDBI packages
hi - thanks for the response, I've changed to using the ODBC driver and MySQL as i didn't want to be tied to using linux, and it seems there is no easily installable version of the postgres driver for windows. cheers, colin -Original Message- From: Sean Davis [mailto:[EMAIL PROTECTED] Sent: Fri 21/01/2005 11:45 To: Combe, Colin Cc: r-help@stat.math.ethz.ch Subject: Re: [R] functions not found after installing DBI/RDBI packages Colin, Rdbi provides generic methods for working with databases. It requires a driver for a specific database, as well. Therefore, you will need to download and install RdbiPgSQL, also. Sean On Jan 21, 2005, at 4:58 AM, Combe, Colin wrote: Hi, I would like to be able to use R with a connection to a PostgreSQL database. I am using R 2.0.1 on windows XP. I have tried installing both the DBI and rDBI packages (which is better?) but in either case I run into the same problem - when i try to use either the dbDriver or dbConnect functions i'm told the function couldn't be found. Seems like the packages aren't installing properly. I installed DBI from a zip file and rDBI from bioconductor. Any clues as to where i'm going wrong? thanks, colin [[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 [[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
Re: [R] Wilcoxon test for mixed design (between-within subjects)
Hallo Christoph, There is always the possibility to summarize the replicates and then calculate a common pairwise Wilcoxon test. mmmh, in this case I prefer the Friedman test, I would like not to loose any data. The Friedman test calculates the ranks inside of the blocks, for each block separately and is not considering all subjects jointly. true, but it considers all the treatments together, while Wilcoxon works per pairs of treatments within the blocks. In R implemented is the case with unreplicated blocked data, so this doesn't help you. If no such method exists in R, I am anyway intersted in possible references. Look at: Myles Hollander Douglas A. Wolfe (1999), _Nonparametric statistical methods_. New York: John Wiley Sons. There you find the generalization of the replicated case, but you have to implement it. I already implemented the Friedman test for the replicated case although taken from Conover 1999 _Practical non parametric statistics_. I hope it is the same. My interest in a Wilcoxon procedure is due to the fact that according to Hsu 1996 _Multiple comparisons_ the Friedman test is not recommended for multiple comparisons becasue it has been shown that it is not a confident method (the actual alpha value is greater). Regards, Marco --- Marco Chiarandini, Fachgebiet Intellektik, Fachbereich Informatik, Technische Universität Darmstadt, Hochschulstraße 10, D-64289 Darmstadt - Germany, Office: S2/02 Raum E312 Tel: +49.(0)6151.166802 Fax: +49.(0)6151.165326 email: [EMAIL PROTECTED] web page: http://www.intellektik.informatik.tu-darmstadt.de/~machud __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to use identify
On Sun, 23 Jan 2005 18:35:00 -0500, David Parkhurst [EMAIL PROTECTED] wrote : I can't get identify to work, using R 2.0.1 under windows xp pro, service pack 2. Here's what I enter, and the result: plot((our.frame2$c1),(our.frame2$c9)) # Produces desired plot identify(our.frame2$c1) # Plot comes to forefront, so I select a point warning: no point with 0.25 inches numeric(0) Is my call to identify correct? The help page for indentify (from ?identify) doesn't give any examples, so I don't know what the x should be. I right click right on top of one of the points, then left click and select stop. You want to give both x and y coordinates to identify(), matching the points you plotted, e.g.. change your example to plot((our.frame2$c1),(our.frame2$c9)) # Produces desired plot identify(our.frame2$c1, our.frame2$c9) # Give the same coords 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
Re: [R] mcnemar.test odds ratios, CI, etc.
Bliese, Paul D LTC USAMH [EMAIL PROTECTED] writes: Does anyone know of another version of the Mcnemar test that provides: 1. Odds Ratios 2. 95% Confidence intervals of the Odds Ratios 3. Sample probability 4. 95% Confidence intervals of the sample probability Obviously the Odds Ratios and Sample probabilities are easy to calculate from the contingency table, but I would appreciate any help on how to calculate the confidence intervals. Below is a simple example of the test, and the corresponding output with the function mcnemar.test. xtabs(~PLC50.T1+PLC50.T2,data=LANCET.DAT) PLC50.T2 PLC50.T1 0 1 0 464 22 1 6 1 mcnemar.test(xtabs(~PLC50.T1+PLC50.T2,data=LANCET.DAT)) McNemar's Chi-squared test with continuity correction data: xtabs(~PLC50.T1 + PLC50.T2, data = LANCET.DAT) McNemar's chi-squared = 8.0357, df = 1, p-value = 0.004586 What is the sample probability in this context? The odds ratio is a simple functional of the off-diagonal elements, and the conditional distribution of those given their sum is just a binomial, so you can use prop.test or binom.test to get estimate and confidence intervals for the probability parameter and convert that to odds. E.g. prop.test(6,28) 1-sample proportions test with continuity correction data: 6 out of 28, null probability 0.5 X-squared = 8.0357, df = 1, p-value = 0.004586 alternative hypothesis: true p is not equal to 0.5 95 percent confidence interval: 0.09027927 0.41462210 sample estimates: p 0.2142857 ci.p - prop.test(22,28)$conf ci.odds - ci.p/(1-ci.p) ci.odds [1] 1.411835 10.076740 attr(,conf.level) [1] 0.95 ci.p - binom.test(22,28)$conf ci.odds - ci.p/(1-ci.p) ci.odds [1] 1.441817 11.053913 attr(,conf.level) [1] 0.95 -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- 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
Re: [R] survreg: fitting different location parameters
On Sun, Jan 23, 2005 at 03:10:18PM -0500, [EMAIL PROTECTED] wrote: Hi R-Help! My question: I have lifetime/failure data of machines with different stress levels and i think an weibull/extreme value distribution would fit this data. So I did: model1 - survreg(Surv(lfailure)~stress,data=steel,dist=extreme) (where lfailure=log(failure)) Now I would like to do a likelihood ratio test to test the hypothesis H0: location parameters of the extreme value distribution are equal for each stress level. So in order to perform the likelihood ratio test I need the likelood of the model under HA: location parameters are not equal (i.e. each stress level has its slope and intercept). How can I do this? Stratify on stress level. -- Göran Broströmtel: +46 90 786 5223 Department of Statistics fax: +46 90 786 6614 Umeå University http://www.stat.umu.se/egna/gb/ SE-90187 Umeå, Sweden e-mail: [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
[R] limma ref
Hi, I have a question about limma. I have data from spotted arrays. I have class A and Class B on the same slide. In Limma if I put class A as the reference (ref), are the list of genes I get in the output for class A or class B? #design - modelMatrix(targets, ref=classA) design Josephine Brennan [[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
Re: [R] printing PCA scores
On Mon, 24 Jan 2005, Jari Oksanen wrote: On Sat, 2005-01-22 at 17:31 -0500, Jérôme Lemaître wrote: Hey folks, I have an environmental dataset on which I conducted a PCA (prcomp) and I need the scores of this PCA for each site (=each row) to conduct further analyses. Can you please help me with that? Did you try help(prcomp) ? It says that prcomp (may) return an item called 'x': x: if 'retx' is true the value of the rotated data (the centred (and scaled if requested) data multiplied by the 'rotation' matrix) is returned. [non-matching parentheses in the original help file] What `non-matching parentheses'? Try counting them: two ( and two )! -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] CIS inquiries
Does anyone have an automated way to make Current Index to Statistics inquiries from R, or from the Unix command line? I thought it might be convenient to have something like this for occasions in which I'm in a foreign domain and would like to make inquires on my office machine without firing up a full fledged browser. Lynx is ok for this purpose, but it might be nice to have something more specifically designed for CIS. url:www.econ.uiuc.edu/~rogerRoger Koenker email [EMAIL PROTECTED] Department of Economics vox:217-333-4558University of Illinois fax:217-244-6678Champaign, IL 61820 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] lme and varFunc()
Dear R users, I am currently analyzing a dataset using lme(). The model I use has the following structure: model-lme(response~Covariate+TreatmentA+TreatmentB,random=~1|Block/Plot,method=ML) When I plot the residuals against the fitted values, I see a clear positive trend (meaning that the variance increases with the mean). I tried to solve this issue using weights=varPower(), but it doesn´t change the residual plot at all. How would you implement such a positive trend in the variance? I´ve tried glmmPQL (which works great with poisson errors), but using glmmPQL I can´t do model simplification. Many thanks for your help! Regards Chris. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] several boxplots or bwplots into one graphic
Hi I have 10 variables and 2 groups. I know how to plot a bwplot for ONE var. e.g. var.a var.b var.c .. GROUP 0.2 0.5 0.2 .. 0 0.3 0.2 0.2 .. 0 .. 0.1 0.8 0.7 .. 1 0.5 0.5 0.1 .. 1 .. bwplot(var.a ~ GROUP, data = my.data) How can I plot 10 bwplots (or boxplots) automatically into one graphic? is there any function from lattice which can do this? thanks for a short hint christoph __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] error preparing a package for lazy loading with R CMD
Not sure if this will help, but have you tried loading the package after install with no lazyload? I've found that if there are syntax errors in the R source, that can give the problem you described. Just a guess. Andy From: Patrick Giraudoux H Dear Lister, I work with R 2.0.1 and Windows XP, and meet a strange trouble trying to make a R package with a make-package.bat file John Fox has kindly provided (see detailed script below). I am working with it since some months with excellent results (I do'nt use compiled C code so far). Just adding a new function in the R directory today, when running make-package and thus excuting the command ..\..\bin\R CMD build --force --binary --auto-zip %1, I got the following message after the compile stage, preparing the package for lazy loading : preparing package pgirmess for lazy loading Error in names-.default(`*tmp*`, value =c(R, Platform, Date, : names attribute[4] must be the same length as the vector [1] Execution halted make: ***[lazyload] Error 1 *** Installation of pgirmess failed *** (pgirmess is the package name) ... and the zip file is not generated. I have checked and rechecked everything during this (long) afternoon... and get nothing except that if I drag out any of the *.r file of the R folder, everything comes to be OK (except the function that has been dragged out is missing...). It looks like if having added one extra function in the R folder on the top of the earlier 32 (+ 2 data frames) makes problem. I have then consulted John Fox offlist and he seems quite perplexed I'm not sure why you're experiencing this problem. On his advise I have included LazyLoad: no in the package description file. In this case everything goes smoothly then (except LazyLoad will not be activated), the zip file is generated and the package can be installed from R. Has anybody an idea about why a problem occurs when preparing the package for lazy loading? Any remedy? Kind regards, Patrick Make-Package script: cd c:\R\rw2001\src\library del %1\INDEX del %1\data\00Index del %1\chm\*.* /Q ..\..\bin\R CMD build --force --binary --auto-zip %1 ..\..\bin\R CMD build --force %1 ..\..\bin\R CMD check %1 cd %1.Rcheck dvipdfm %1-manual notepad 00check.log cd .. cd .. From: John Fox [EMAIL PROTECTED] To: 'Patrick Giraudoux H' [EMAIL PROTECTED] Subject: RE: [R] writing a simple package in R 2.0 under Windows XP Date: Sun, 23 Jan 2005 11:41:25 -0500 X-Mailer: Microsoft Office Outlook, Build 11.0.6353 X-MIME-Autoconverted: from quoted-printable to 8bit by utinam.univ-fcomte.fr id j0NGfJoD011345 Dear Patrick, I'm not sure why you're experiencing this problem. Two suggestions: (1) Since the problem appears to be with preparing the package for lazy loading, try adding the directive LazyLoad: no (without the quotes) to the package's DESCRIPTION file. (2) Rather than using my batch file, run the commands one at a time to see exactly where the problem is produced; then you could send a message to r-help. I hope this helps, John __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] functions not found after installing DBI/RDBI packages
RE: [R] functions not found after installing DBI/RDBI packagesColin, There is an ODBC driver for postgres and there is a binary installer for postgres, just in case you want to use postgres. I think both are available at http://www.postgresql.org. If all you are doing is storing and retrieving data, then mysql will more than suffice. However, it you want to use foreign keys, any stored procedures, etc., you will need postgres. I started out using mysql but have moved to postgres for everything that I can (all my own work), but that is a topic for another list on another day. Sean - Original Message - From: Combe, Colin To: Sean Davis Cc: r-help@stat.math.ethz.ch Sent: Monday, January 24, 2005 6:13 AM Subject: RE: [R] functions not found after installing DBI/RDBI packages hi - thanks for the response, I've changed to using the ODBC driver and MySQL as i didn't want to be tied to using linux, and it seems there is no easily installable version of the postgres driver for windows. cheers, colin -Original Message- From: Sean Davis [mailto:[EMAIL PROTECTED] Sent: Fri 21/01/2005 11:45 To: Combe, Colin Cc: r-help@stat.math.ethz.ch Subject: Re: [R] functions not found after installing DBI/RDBI packages Colin, Rdbi provides generic methods for working with databases. It requires a driver for a specific database, as well. Therefore, you will need to download and install RdbiPgSQL, also. Sean On Jan 21, 2005, at 4:58 AM, Combe, Colin wrote: Hi, I would like to be able to use R with a connection to a PostgreSQL database. I am using R 2.0.1 on windows XP. I have tried installing both the DBI and rDBI packages (which is better?) but in either case I run into the same problem - when i try to use either the dbDriver or dbConnect functions i'm told the function couldn't be found. Seems like the packages aren't installing properly. I installed DBI from a zip file and rDBI from bioconductor. Any clues as to where i'm going wrong? thanks, colin [[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 [[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
Re: [R] an R script editor for Mac
TomH == Thomas Schönhoff [EMAIL PROTECTED] on Fri, 21 Jan 2005 23:21:30 +0100 writes: TomH Hello, TomH Am Freitag, den 21.01.2005, 06:39 -0500 schrieb Sean Davis: Consider using ESS and xemacs or emacs. You get syntax highlighting, auto-indent, command auto-complete, transcripts for your session, integrated help, and the tools of one of the most powerful text editors on the planet. The learning curve is a bit steep, but if you use R much, it is worth it. TomH Yes, definitely. I'd like to add that there is an exellent ref-card TomH regarding the Emacs/ESS duo that may smoothing the learning curve a bit! TomH Don't remember the right place to fetch from From the ESS page, http://ESS.r-project.org/ last line in the list. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] several boxplots or bwplots into one graphic
Your variables (var.*) seem to be on the same scale. How about reshaping the data into a univariate layout and then using bwplot as follows: mydata - data.frame(ID = 1:20, A = runif(20), B = runif(20), C = runif(20), GROUP = rep(c(0,1), c(10,10))) mydata.uni - reshape(mydata, varying = list(c(A, B, C)), v.names = Y, timevar = VAR, times = c(A, B, C), direction = long) library(lattice) bwplot(Y ~ as.factor(GROUP) | VAR, data = mydata.uni, layout=c(3,1,1), xlab=Group) hope this helps, Chuck Cleland Christoph Lehmann wrote: Hi I have 10 variables and 2 groups. I know how to plot a bwplot for ONE var. e.g. var.a var.b var.c .. GROUP 0.2 0.5 0.2 .. 0 0.3 0.2 0.2 .. 0 .. 0.1 0.8 0.7 .. 1 0.5 0.5 0.1 .. 1 .. bwplot(var.a ~ GROUP, data = my.data) How can I plot 10 bwplots (or boxplots) automatically into one graphic? is there any function from lattice which can do this? thanks for a short hint christoph __ 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 -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (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
[R] parameter couldn't be set in high-level plot() function
Dear R users, I am using function bandplot from the gplots package. To my understanding (viewing the source of bandplot) it calls function plot (add = FALSE) with the same parameters (except for a few removed). I would like to give extra parameters 'xlab' and 'ylab' to function bandplot, but, as can be seen below, that raises warnings (and the labels do not show up at the end). It does work to call title(... xlab=blah, ylab=foo) after bandplot (), but then I have two labels on top of each other, which is even more ugly. Can anyone explain me why this goes wrong? Thanks in advance, Jonne. x11() ; bandplot(x=xdata, y=zdata) [works fine] x11() ; bandplot(x=xdata, y=zdata, xlab=blah, ylab=foo) There were 22 warnings (use warnings() to see them) warnings() Warning messages: 1: parameter xlab couldn't be set in high-level plot() function 2: parameter ylab couldn't be set in high-level plot() function 3: parameter xlab couldn't be set in high-level plot() function 4: parameter ylab couldn't be set in high-level plot() function 5: parameter xlab couldn't be set in high-level plot() function 6: parameter ylab couldn't be set in high-level plot() function 7: parameter xlab couldn't be set in high-level plot() function 8: parameter ylab couldn't be set in high-level plot() function 9: parameter xlab couldn't be set in high-level plot() function 10: parameter ylab couldn't be set in high-level plot() function 11: parameter xlab couldn't be set in high-level plot() function 12: parameter ylab couldn't be set in high-level plot() function 13: parameter xlab couldn't be set in high-level plot() function 14: parameter ylab couldn't be set in high-level plot() function 15: parameter xlab couldn't be set in high-level plot() function 16: parameter ylab couldn't be set in high-level plot() function 17: parameter xlab couldn't be set in high-level plot() function 18: parameter ylab couldn't be set in high-level plot() function 19: parameter xlab couldn't be set in high-level plot() function 20: parameter ylab couldn't be set in high-level plot() function 21: parameter xlab couldn't be set in high-level plot() function 22: parameter ylab couldn't be set in high-level plot() function There were 22 warnings (use warnings() to see them) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to use identify --- Summary
I asked why my call to identify wasnt working. Thanks to Petr Pikal, Tom Mulholland, Gavin Simpson, and Duncan Murdoch for explaining that I had misinterpreted the ?identify help page, and that I needed to feed both the x and y vectors in the plot to identify(). Its working fine for me now. Dave Parkhurst __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] proj() function for lm objects
Dear all, I'm trying to find a clear explanation of what the 'proj(lm)' function produces after having fit a linear model using 'lm'. I find the help page on the proj() function highly unclear (surely part to my limited knowledge of statistics). Can anybody provide a pointer to a clearer explanation, preferable containing some examples of the calculations involved ? More particularly, I am interested in the relation between the coefficients produced by the 'coef()' function on an 'lm' object, and the corresponding projections. regards, Piet -- Piet van Remortel Intelligent Systems Lab University of Antwerp Belgium http://www.islab.ua.ac.be __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] using eval() with pre-built expression inside function
I'm trying to evaluate a pre-built expression using eval(), e.g. dataset - data.frame(y = runif(30, 50,100), x = gl(5, 6)) # one like this mf - expression(model.frame(y~x)) eval(mf, dataset, parent.frame()) # rather than this eval(expression(model.frame(y~x)), dataset, parent.frame()) In the example above there is no problem, the problem comes when I try to do a similar thing within a function, e.g. f1 - function(formula, data) { mt - terms(formula) mf - as.expression(as.call(c(as.name(model.frame), formula = mt))) eval(mf, data, parent.frame()) } f1(formula = y ~ x, data = dataset) Error in eval(expr, envir, enclos) : Object y not found I can get round this by building a call to eval using paste, e.g. f2 - function(formula, data) { mt - terms(formula) mf - as.expression(as.call(c(as.name(model.frame), formula = mt))) direct - parse(text = paste(eval(expression(, mf, ), data, parent.frame( print(direct) eval(direct) } f2(formula = y ~ x, data = dataset) expression(eval(expression(model.frame(formula = y ~ x)), data, parent.frame())) y x 1 92.23087 1 2 63.43658 1 3 55.24448 1 4 72.75650 1 5 67.58781 1 ... but this seems rather convoluted. Can anyone explain why f1 doesn't work (when f2 does) and/or suggest a neater way of dealing with this? Thanks Heather Mrs H Turner Research Assistant Dept. of Statistics University of Warwick __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] an R script editor for Mac
Jacques VESLOT wrote: Could someone please make me know if there is a nice script editor available under Mac, similar to Crimson, that offers R syntax highlighting (and pairs of parentheses underlining) ? Did you look into BareBone's TextWrangler, 'BBEdit Lite' replacement? It's now available as free (as in beer) download for 10.3.5+. http://www.barebones.com/products/textwrangler/download.shtml I created a quick version of the Codeless Language Module for R but it's lacking at the moment. -- SIGSIG -- signature too long (core dumped) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] using eval() with pre-built expression inside function
If you look at the beginning of lm(), you'll see that match.call() is used and name of the function (in this case f1) is replaced with model.frame. Does something like this work? f1 - function(formula, data) { mf - match.call(expand.dots = FALSE) mf[[1]] - as.name(model.frame) eval(mf, parent.frame()) } -roger Heather Turner wrote: I'm trying to evaluate a pre-built expression using eval(), e.g. dataset - data.frame(y = runif(30, 50,100), x = gl(5, 6)) # one like this mf - expression(model.frame(y~x)) eval(mf, dataset, parent.frame()) # rather than this eval(expression(model.frame(y~x)), dataset, parent.frame()) In the example above there is no problem, the problem comes when I try to do a similar thing within a function, e.g. f1 - function(formula, data) { mt - terms(formula) mf - as.expression(as.call(c(as.name(model.frame), formula = mt))) eval(mf, data, parent.frame()) } f1(formula = y ~ x, data = dataset) Error in eval(expr, envir, enclos) : Object y not found I can get round this by building a call to eval using paste, e.g. f2 - function(formula, data) { mt - terms(formula) mf - as.expression(as.call(c(as.name(model.frame), formula = mt))) direct - parse(text = paste(eval(expression(, mf, ), data, parent.frame( print(direct) eval(direct) } f2(formula = y ~ x, data = dataset) expression(eval(expression(model.frame(formula = y ~ x)), data, parent.frame())) y x 1 92.23087 1 2 63.43658 1 3 55.24448 1 4 72.75650 1 5 67.58781 1 ... but this seems rather convoluted. Can anyone explain why f1 doesn't work (when f2 does) and/or suggest a neater way of dealing with this? Thanks Heather Mrs H Turner Research Assistant Dept. of Statistics University of Warwick __ 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 -- Roger D. Peng http://www.biostat.jhsph.edu/~rpeng/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] proj() function for lm objects
Dear Piet, You'll find more of an explanation in Sec. 5.3.3 of Chambers and Hastie, eds., Statistical Models in S. Briefly, proj() computes the orthogonal projections of the response (y) sequentially onto the subspaces spanned by columns of the model matrix (X) corresponding to terms in the model. Consequently, in a model in which the first term is the constant, the first such projection is just the mean of the response. Suppose the second term has just one degree of freedom; then the second projection is of y minus its mean onto the second column of X minus its mean. Each such projection is essentially residualized (both y and X) for the preceding ones, and therefore the coefficients are for each term in a sequential set of regressions, not the coefficients of the model as whole (or of any particular such regression). The last projection is onto the orthogonal complement of X and thus gives residuals for the model as a whole. The sum of these projections is y. 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 Piet van Remortel Sent: Monday, January 24, 2005 10:16 AM To: r-help@stat.math.ethz.ch Subject: [R] proj() function for lm objects Dear all, I'm trying to find a clear explanation of what the 'proj(lm)' function produces after having fit a linear model using 'lm'. I find the help page on the proj() function highly unclear (surely part to my limited knowledge of statistics). Can anybody provide a pointer to a clearer explanation, preferable containing some examples of the calculations involved ? More particularly, I am interested in the relation between the coefficients produced by the 'coef()' function on an 'lm' object, and the corresponding projections. regards, Piet -- Piet van Remortel Intelligent Systems Lab University of Antwerp Belgium http://www.islab.ua.ac.be __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] converting R objects to C types in .Call
Dear People, I'm trying to write an R wrapper for a C++ library, using .Call. I've never used .Call before. I'm currently having some difficulties converting a R character string to a C one. Here is a little test program. #include R.h #include Rinternals.h #include stdio.h SEXP testfn(SEXP chstr) { char * charptr = CHAR(chstr); printf(%s, charptr); } This compiles without problems, but when I try to run this as .Call(testfn, foo) I get a segmentation fault. I am sure I am making an obvious mistake, but can someone help me to sort it out? Thanks in advance. Please cc me, I'm not subscribed. Faheem. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] converting R objects to C types in .Call
Faheem Mitha wrote: SEXP testfn(SEXP chstr) { char * charptr = CHAR(chstr); printf(%s, charptr); } I am sure I am making an obvious mistake, but can someone help me to sort it out? Thanks in advance. Please cc me, I'm not subscribed. Firstly, R is expecting an SEXP as a return value! And secondly, your SEXP chstr is still a vector - so you need to get an element from it. If there's only one element, then that'll be the zeroth element. Here's my code: #include R.h #include Rinternals.h #include stdio.h SEXP testfn(SEXP chstr) { char * charptr = CHAR(VECTOR_ELT(chstr,0)); printf(%s, charptr); return(chstr); } - I'm just returning the same object back in the return() statement, and using VECTOR_ELT(chstr,0) to get to the 0'th element. SO in R: foo = .Call(testfn,fnord) should print 'fnord' and return foo as fnord. foo = .Call(testfn,c(bar,baz)) will print 'bar' and return foo as c(bar,baz) Baz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] converting R objects to C types in .Call
On Mon, 24 Jan 2005, Faheem Mitha wrote: I'm trying to write an R wrapper for a C++ library, using .Call. I've never used .Call before. I'm currently having some difficulties converting a R character string to a C one. Here is a little test program. #include R.h #include Rinternals.h #include stdio.h SEXP testfn(SEXP chstr) { char * charptr = CHAR(chstr); CHAR(STRING_ELT(chstr, 0)); First you select the first element of the character vector, then select its contents as a C-level character array. printf(%s, charptr); } This compiles without problems, but when I try to run this as .Call(testfn, foo) I get a segmentation fault. I am sure I am making an obvious mistake, but can someone help me to sort it out? Thanks in advance. Please cc me, I'm not subscribed. Please read `Writing R Extensions' for more examples. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] which.pmin?
That's what ifelse is for: ifelse(fpr(b, k.floor) fpr(b, k.ceiling), k.floor, k.ceiling) Reid Huntsinger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Seung Jun Sent: Friday, January 21, 2005 5:27 PM To: R-help@stat.math.ethz.ch Subject: [R] which.pmin? I have two vectors (k.floor and k.ceiling) of integers of the same length, and a function (fpr). b - 10:40 k.floor - floor(log(2) * b) k.ceiling - ceiling(log(2) * b) fpr.floor - fpr(b, k.floor) fpr.ceiling - fpr(b, k.ceiling) If R had a element-wise ternary function, I'd like to do something like this: (fpr.floor fpr.ceiling) ? k.floor : k.ceiling That is, I'd like to go through the two vectors in parallel, picking the one that returns the lower value of fpr. Failing to find such a function, I wrote the following two lines: ind - sapply(data.frame(rbind(fpr.floor,fpr.ceiling)), which.min) opt.k - cbind(k.floor,k.ceiling)[1:length(ind)+length(ind)*(ind-1)] opt.k is the vector I want, but I guess I abuse some functions here. I'd like to ask the experts, What is the proper R-way to do this? The API should be like which.pmin(FUN, X, Y, ...) that returns a vector of the same length as X (and Y), provided that X, Y, ... have the same length. Please fill the function body. Seung __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] converting R objects to C types in .Call
Hi Barry, Thanks for your reply. On Mon, 24 Jan 2005, Barry Rowlingson wrote: Firstly, R is expecting an SEXP as a return value! Ouch... I haven't found anything that says this explicitly, but it looks like .Call expects a SEXP to be returned to R. At any rate, trying to use void instead gives a segfault. And secondly, your SEXP chstr is still a vector - so you need to get an element from it. If there's only one element, then that'll be the zeroth element. Here's my code: #include R.h #include Rinternals.h #include stdio.h SEXP testfn(SEXP chstr) { char * charptr = CHAR(VECTOR_ELT(chstr,0)); printf(%s, charptr); return(chstr); } - I'm just returning the same object back in the return() statement, and using VECTOR_ELT(chstr,0) to get to the 0'th element. SO in R: foo = .Call(testfn,fnord) should print 'fnord' and return foo as fnord. foo = .Call(testfn,c(bar,baz)) will print 'bar' and return foo as c(bar,baz) Thanks for your help. That works fine. Faheem. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lme and varFunc()
Dear Christoph, what command are you using to plot the residuals? If you use the default residuals it will not reflect the variance model. If you use the argument type=p then you get the Pearson residuals, which will reflect the weights model. Try something like this: plot(model, resid(., type = p) ~ fitted(.), abline = 0) I hope that this helps, Andrew On Mon, Jan 24, 2005 at 02:28:44PM +0100, Christoph Scherber wrote: Dear R users, I am currently analyzing a dataset using lme(). The model I use has the following structure: model-lme(response~Covariate+TreatmentA+TreatmentB,random=~1|Block/Plot,method=ML) When I plot the residuals against the fitted values, I see a clear positive trend (meaning that the variance increases with the mean). I tried to solve this issue using weights=varPower(), but it doesn?t change the residual plot at all. How would you implement such a positive trend in the variance? I?ve tried glmmPQL (which works great with poisson errors), but using glmmPQL I can?t do model simplification. Many thanks for your help! Regards Chris. __ 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 -- Andrew Robinson Ph: 208 885 7115 Department of Forest Resources Fa: 208 885 6226 University of Idaho E : [EMAIL PROTECTED] PO Box 441133W : http://www.uidaho.edu/~andrewr Moscow ID 83843 Or: http://www.biometrics.uidaho.edu No statement above necessarily represents my employer's opinion. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Follow-up on nls convergence failure with SSfol
A couple of weeks ago there was a question regarding apparent convergence in nls when using the SSfol selfStart model for fitting a first-order pharmacokinetic model. I can't manage to find the original message either in my archive or in the list archives but the data were time conc dose 0.50 5.401 0.75 11.101 1.00 8.401 1.25 13.801 1.50 15.501 1.75 18.001 2.00 17.001 2.50 13.901 3.00 11.201 3.50 9.901 4.00 4.701 5.00 5.001 6.00 1.901 7.00 1.901 9.00 1.101 12.00 0.951 14.00 0.461 and the attempted fit looked like nls(conc ~ SSfol(dose, time, lKe, lKa, lCl), testdat, trace = 1) nls(conc ~ SSfol(dose, time, lKe, lKa, lCl), testdat, trace = 1) 99.15824 : -1.2061792 0.1296156 -4.3020997 86.07567 : -0.7053265 -0.3873204 -4.1278009 85.19743 : -0.5548499 -0.5333776 -4.1173627 Error in nls(conc ~ SSfol(dose, time, lKe, lKa, lCl), testdat, trace = 1) : step factor 0.000488281 reduced below `minFactor' of 0.000976562 If one allows much smaller step factors you can get more iterations but nls still doesn't converge. It took me a long time to find out why. The lack of convergence is related to the form of the SSfol model. When the first two parameters (lKe and lKa) are equal the model degenerates to a different analytic form. If you were to express the corresponding system of ordinary differential equations in the matrix form (as described in Appendix 5 of Bates and Watts (1988)), it would be a Schur triangular block and the special techniques for nondiagonalizable matrices, described in section A5.2 of that appendix, must be used. The clue here is that the first two parameter values are getting very close to each other and this shows up as a singularity. The fitted model is determined by two parameters, not three. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] hist() and database
Hello, I'm a new R user and I'm having a little trouble getting started. I'm hoping someone can help me out. I read numbers (integer) from a SQL database. Some calculations as mean()are possible but hist() give an error. Here are the commands: library(RMySQL) Loading required package: DBI con - dbConnect(dbDriver(MySQL), dbname = test) dbListTables(con) [1] individu res - dbSendQuery(con,select taille from individu) data - fetch(res,-1) data taille 1 184 2 175 3 189 4 173 5 169 6 175 7 164 8 190 9 174 10184 11168 12179 13174 14163 15175 16176 17190 18172 19178 20173 mean(data) taille 176.25 hist(data) Error in hist.default(data) : `x' must be numeric What can I do to draw the histogram ? Thanks for your time JC Bartier __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] hist() and database
jcb wrote: Hello, I'm a new R user and I'm having a little trouble getting started. I'm hoping someone can help me out. I read numbers (integer) from a SQL database. Some calculations as mean()are possible but hist() give an error. Here are the commands: library(RMySQL) Loading required package: DBI con - dbConnect(dbDriver(MySQL), dbname = test) dbListTables(con) [1] individu res - dbSendQuery(con,select taille from individu) data - fetch(res,-1) data taille 1 184 2 175 3 189 4 173 5 169 6 175 7 164 8 190 9 174 10184 11168 12179 13174 14163 15175 16176 17190 18172 19178 20173 mean(data) taille 176.25 hist(data) Error in hist.default(data) : `x' must be numeric What can I do to draw the histogram ? data is a data.frame, instead use: hist(data$taille) Uwe Ligges Thanks for your time JC Bartier __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R 2.0.1 and Rggobi install issues on windows XP
Has anyone else ran into problems installing Rggobi with R 2.0.1 on a windows platform? I've followed all the instructions available and I still can not get R to recognize Rggobi as a library (package). I I've already emailed Duncan Temple Lange at ggobi.org and bell labs and both emails have bounced back. Any help would be greatly appreciated. -Drew Balazs __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] an R script editor for Mac
Hi, There is also SubEthaEdit, quite an elegant editor with R/S syntax highlighting as 1 of the many available modes. With AppleScript its easy to sent the edit window, a file, a selection etc. to R for execution. http://www.codingmonkeys.de/subethaedit/ Rob On Jan 24, 2005, at 8:41 AM, Paul Roebuck wrote: Jacques VESLOT wrote: Could someone please make me know if there is a nice script editor available under Mac, similar to Crimson, that offers R syntax highlighting (and pairs of parentheses underlining) ? Did you look into BareBone's TextWrangler, 'BBEdit Lite' replacement? It's now available as free (as in beer) download for 10.3.5+. http://www.barebones.com/products/textwrangler/download.shtml I created a quick version of the Codeless Language Module for R but it's lacking at the moment. -- SIGSIG -- signature too long (core dumped) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Deleted objects keep coming back
Having a very strange and frustrating problem with v2.0.1 under Mac OSX 10.3. I have several closely related workspaces in the same directory that I need to keep separate from one another (there are a few objects common to all workspaces, and then there are other objects that store the results of different analyses on the common objects, which is why I need separate workspaces). When I attempted to delete objects with rm() and then re-save the workspace, after quitting and restarting R, reloading the workspace, the objects were still present in the workspace (even though I'd deleted them). So I deleted the objects again with rm() and also called gc(), and saved the workspace with a new name. I then quit R and reloaded the workspaces, and that seemed to work. The deleted objects stayed deleted. But then an hour later, I came back and reloaded these workspaces, and the old objects which I'd deleted had come back again. This is really annoying and I feel like I'm losing my mind! I'm concerned that R is not accessing the directory properly, and may be reading one workspace file in place of another. This would completely jeopardize my work. Please help! Thanks in advance, Ken __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Deleted objects keep coming back
From: Ken Termiso Having a very strange and frustrating problem with v2.0.1 under Mac OSX 10.3. I have several closely related workspaces in the same directory that I need to keep separate from one another (there are a few objects common to all workspaces, and then there are other objects that store the results of different analyses on the common objects, which is why I need separate workspaces). When I attempted to delete objects with rm() and then re-save the workspace, after quitting and restarting R, reloading the workspace, the objects were still present in the workspace (even though I'd deleted them). So I deleted the objects again with rm() and also called gc(), and saved the workspace with a new name. I then quit R and reloaded the workspaces, and that seemed to work. The deleted objects stayed deleted. But then an hour later, I came back and reloaded these workspaces, and the old objects which I'd deleted had come back again. This is really annoying and I feel like I'm losing my mind! I'm concerned that R is not accessing the directory properly, and may be reading one workspace file in place of another. This would completely jeopardize my work. Please help! Thanks in advance, Ken Are you sure the objects that won't go away are actually in the workspace you think they're in? What are the exact commands you used to check? How did you load the workspaces (the commands, please)? Please show the exact sequence of what you did and what you saw. Andy __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Re:[ R] Wilcoxon test for mixed deisgn
Marco Chirandini writes: is there any extension of the pairwise Wilcoxon test to a dependent samples layout with replicates (or, in other terms, a one-way layout with blocking and replicates)? The Wilcoxon method with matched pairs works for the case of dependent samples with one observation per block, while the Mann-Whitney test works for independent samples, thus one single block and replicated observations. Is there a method which mixes this two cases considering a depedent sample design in which each block has more than one observation? I know it exists a Friedman test for this case but in the Friedman test ranks are constructed considering all subjects jointly, while in Wilcoxon only the pair of subject currently considered are ranked, thus resulting in a more powerful test. It is my understanding that the Friedman test ranks responses within each block, independently from block to block. friedman.test() is an R function. ** Cliff Lunneborg, Professor Emeritus, Statistics Psychology, University of Washington, Seattle [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
[R] Job Opportunity: Senior Statistician CC 083
Greetings, Thanks for your time in reviewing the following role located in the RTP, NC area. Our client is a drug development platform technology company whose patent-pending intellectual property is poised to dramatically impact both drug discovery and development processes by accurately measuring the spectrum of biochemical changes and mapping these changes to metabolic pathways. The ultimate benefit to the drug development process will be to identify safer compounds for development, shorten the time for drugs to get to market and identify diagnostic markers for earlier disease detection. This technology will increase the success rate, decrease the time to market and stop development of products before critical investments are lost. Our client is currently pioneering statistical methods for the analysis of data and need a Ph. D. statistician with expertise in R, data mining (RPR, PLS, etc) and some knowledge of DOE (for quality assurance). The candidate should be able to independently develop novel statistical approaches to a variety of data types and have a minimal of 5 years commercial industry experience. The candidate should have excellent written and oral communication skills, the ability to work in team settings, and be highly motivated. Kind regards, Don Don Alexander Carlyle Conlan Director Biz Dev - Life Sciences Phone: 919.474.0771 ext 105 Fax: 919.474.0682 [EMAIL PROTECTED] http://www.ccesearch.com [[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
[R] lookups and joins
I have some data coming from SQL sources that I wish to relate in various ways. For reasons only known to our IT people, this can't be done in SQL at present. I am looking for an R'ish technique for looking up new columns on a data frame. As a simple, hardwired example I have tried the following: # This gives me two columns, one the lookup value and the second one # the result column, ie my lookup table. stcl = read.csv(stockclass.csv) stockclass = as.vector(stcl$stock_class) # This gives me what appears to be a dictionary or map names(stockclass) = as.vector(stcl$stock_group) getstockclass = function(stock_group) { try(stockclass[[stock_group]], TRUE) } csg$stk_class=factor(sapply(csg$stock_group, getstockclass)) I need the try since if there is a missing value I get an exception. I also tried something along the lines of (from memory): getstockclass = function(stock_group) { stcl[which(stcl$stock_group == stock_group),]$stock_class } These work but I just wanted to check if there was an inbuilt way to do this kind of thing in R? I searched on join without much luck. Really what I would like is a generic function that: - Takes 2 data frames, - Some kind of specification on which column(s) to join - Outputs the joined frames, or perhaps a vector which is an index vector that I can use on the second data frame. I don't really want to reinvent SQL and my data sets are not huge. cheers __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] lookups and joins
All together now: ?merge :-) -Original Message- From: [EMAIL PROTECTED] on behalf of Paul Sorenson Sent: Mon 1/24/2005 10:34 PM To: r-help@stat.math.ethz.ch Cc: Subject:[R] lookups and joins I have some data coming from SQL sources that I wish to relate in various ways. For reasons only known to our IT people, this can't be done in SQL at present. I am looking for an R'ish technique for looking up new columns on a data frame. As a simple, hardwired example I have tried the following: # This gives me two columns, one the lookup value and the second one # the result column, ie my lookup table. stcl = read.csv(stockclass.csv) stockclass = as.vector(stcl$stock_class) # This gives me what appears to be a dictionary or map names(stockclass) = as.vector(stcl$stock_group) getstockclass = function(stock_group) { try(stockclass[[stock_group]], TRUE) } csg$stk_class=factor(sapply(csg$stock_group, getstockclass)) I need the try since if there is a missing value I get an exception. I also tried something along the lines of (from memory): getstockclass = function(stock_group) { stcl[which(stcl$stock_group == stock_group),]$stock_class } These work but I just wanted to check if there was an inbuilt way to do this kind of thing in R? I searched on join without much luck. Really what I would like is a generic function that: - Takes 2 data frames, - Some kind of specification on which column(s) to join - Outputs the joined frames, or perhaps a vector which is an index vector that I can use on the second data frame. I don't really want to reinvent SQL and my data sets are not huge. cheers __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Weighted.mean(x,wt) vs. t(x) %*% wt
What is the difference between the above two operations ? [[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
Re: [R] animation without intermediate files?
Hi Cari G Kaufman wrote: Hello, Does anyone know how to make movies in R by making a sequence of plots? I'd like to animate a long trajectory for exploratory purposes only, without creating a bunch of image files and then using another program to string them together. In Splus I would do this using double.buffer() to eliminate the flickering caused by replotting. For instance, with a 2-D trajectory in vectors x and y I would use the following: motif() double.buffer(back) for (i in 1:length(x)) { plot(x[i], y[i], xlim=range(x), ylim=range(y)) double.buffer(copy) } double.buffer(front) I haven't found an equivalent function to double.buffer in R. I tried playing around with dev.set() and dev.copy() but so far with no success (still flickers). Double buffering is only currently an option on the Windows graphics device (and there it is on by default). So something like ... x - rnorm(100) for (i in 1:100) plot(1:i, x[1:i], xlim=c(0, 100), ylim=c(-4, 4), pch=16, cex=2) is already smooth Paul -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] some questions about font
Hi Bobai Li wrote: Hi, I have been using R to create some mathematical and statistical graphs for a book manuscript, but I got some problems: 1) Some web positngs said that default typeface for math expressions is italic, but in my system (R 2.01 on WinXP), the default is regular font. How can I change the default to ilatic? expression(italic(whatever)) 2) When use ComputerModern font, (i.e., family=c(CM_regular_10.afm,CM_boldx_10.afm,cmti10.afm,cmbxti10.afm,CM_symbol_10.afm) ), some accented symbols are not available. For example, expression(hat(beta)) will produce warning message like font metrics unknown for character 94. That appears to be a bug (that requires changes to the PostScript device driver). A nastyish workaround for hat(beta) is widehat(beta), but I suspect there are other problems that this will not solve. Paul -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] survreg: fitting different location parameters
I am still trying to find a common intercept but a different slopes for each group within my lifetime data. By stratifying the variable stress (the groups) I get different scale parameters which is not my goal. So I did this: survreg(Surv(lfailure)~as.factor(stress),data=steel,dist=extreme) and I did get different slopes but common intercepts and scales. Is this correct? I am a bit unsure as I did it with a different software and got different estimates... Thanks for any help Hadassa Quoting Göran Broström [EMAIL PROTECTED]: On Sun, Jan 23, 2005 at 03:10:18PM -0500, [EMAIL PROTECTED] wrote: Hi R-Help! My question: I have lifetime/failure data of machines with different stress levels and i think an weibull/extreme value distribution would fit this data. So I did: model1 - survreg(Surv(lfailure)~stress,data=steel,dist=extreme) (where lfailure=log(failure)) Now I would like to do a likelihood ratio test to test the hypothesis H0: location parameters of the extreme value distribution are equal for each stress level. So in order to perform the likelihood ratio test I need the likelood of the model under HA: location parameters are not equal (i.e. each stress level has its slope and intercept). How can I do this? Stratify on stress level. -- Göran Broströmtel: +46 90 786 5223 Department of Statistics fax: +46 90 786 6614 Umeå University http://www.stat.umu.se/egna/gb/ SE-90187 Umeå, Sweden e-mail: [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
RE: [R] Weighted.mean(x,wt) vs. t(x) %*% wt
Just look at the code: weighted.mean function (x, w, na.rm = FALSE) { if (missing(w)) w - rep.int(1, length(x)) if (is.integer(w)) w - as.numeric(w) if (na.rm) { w - w[i - !is.na(x)] x - x[i] } sum(x * w)/sum(w) } environment: namespace:stats So the differences are: - missing values handling - weight normalization - the difference between t(x) %*% w and sum(x * w) (I'd say the latter is more efficient) Here's an example: x - rnorm(5e6) w - runif(x) w - w / sum(w) system.time(sum(x * w), gcFirst=T) [1] 0.17 0.03 0.20 NA NA system.time(s1 - sum(x * w), gcFirst=T) [1] 0.19 0.01 0.20 NA NA system.time(s2 - t(x) %*% w, gcFirst=T) [1] 0.30 0.01 0.33 NA NA system.time(s3 - crossprod(x, w), gcFirst=T) [1] 0.04 0.00 0.04 NA NA c(s1, s2, s3) [1] -0.0008922782 -0.0008922782 -0.0008922782 [This is w/o using an optimized BLAS. With an optimized BLAS, the two latter ones might be significantly faster than what's seen here.] Andy From: Ranjan S. Muttiah What is the difference between the above two operations ? [[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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Related with kmeans
Hi, I am new here. I used y-kmeans(x, 2)(x is a vector) to do the cluster analysis. I get y has $cluster, $center etc. I need to pull out the data belong to cluster 1 and cluster 2. How can I do that? Thanks, Ming __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Related with kmeans
From: [EMAIL PROTECTED] Hi, I am new here. I used y-kmeans(x, 2)(x is a vector) to do the cluster analysis. I get y has $cluster, $center etc. I need to pull out the data belong to cluster 1 and cluster 2. How can I do that? Here's an example: cl - round(runif(20)) x - rnorm(20, mean=cl) km - kmeans(x, 2) x[km$cluster == 1] [1] -1.739624361 -0.046792299 -0.309680321 0.001928340 -1.036573237 -1.875550649 [7] -2.276369358 -0.453359967 -1.500753548 -1.864152516 x[km$cluster == 2] [1] 0.6467709 1.9746519 1.9463621 2.9971197 2.8290800 0.8533460 0.6175901 2.2296458 [9] 0.6616395 1.5822679 Andy Thanks, Ming __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Estimating error rate for a classification tree
Hi, I created an rpart object and pruned the tree using 1-SE rule. I used 10-fold cross validation while creating the tree. Then, I extracted the cross-validated predictions for my data points using xpred.rpart and obtained some statistics like precision, recall, overall error rate, etc. However, these values change each time I run xpred.rpart because of the random shuffling going on before cross validation (I think so). What should I do in this case? I am inclined to treat them as random variables with normal distribution. So, when I have, say 100 runs, i can say something about the mean with some confidence interval. However, I also doubt that these subsequent runs may not be independent from each other. I would highly appreciate if someone could make a suggestion. Best regards __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Recursive default argument reference
Recursive default argument reference keeps appearing when I try to run a haplo.score function in R for Windows. I'm new to using this program. Does anyone know what this means? - [[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
[R] agglomerative coefficient in agnes (cluster)
I haven't read the book, but could anyone explain more about this parameter? help(agnes) says that ac measures the amount of clustering structure found. From the definition given in help(agnes.object), however, it seems that as long as the dissimilarity of the merger in the final step of the algorithm is large enough, the ac value will be close to 1. So what does ac really mean? Thank you, Weiguang __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Zipf random number generation
Hi, Is there a Zipf-like distribution RNG in R? Thanks, Weiguang __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] error preparing a package for lazy loading with R CMD
That's the way John Fox advised to turn the problem. Indeed it works but doe snot explain this bug in lazy loading. I don't think that it may come for a syntax error somewhere. All the functions have been checked and the problem does not occur if any of the 35 functions is removed. Something happens when I add another function to the 34 already present. Strange. A 08:45 24/01/2005 -0500, vous avez écrit : Not sure if this will help, but have you tried loading the package after install with no lazyload? I've found that if there are syntax errors in the R source, that can give the problem you described. Just a guess. Andy From: Patrick Giraudoux H Dear Lister, I work with R 2.0.1 and Windows XP, and meet a strange trouble trying to make a R package with a make-package.bat file John Fox has kindly provided (see detailed script below). I am working with it since some months with excellent results (I do'nt use compiled C code so far). Just adding a new function in the R directory today, when running make-package and thus excuting the command ..\..\bin\R CMD build --force --binary --auto-zip %1, I got the following message after the compile stage, preparing the package for lazy loading : preparing package pgirmess for lazy loading Error in names-.default(`*tmp*`, value =c(R, Platform, Date, : names attribute[4] must be the same length as the vector [1] Execution halted make: ***[lazyload] Error 1 *** Installation of pgirmess failed *** (pgirmess is the package name) ... and the zip file is not generated. I have checked and rechecked everything during this (long) afternoon... and get nothing except that if I drag out any of the *.r file of the R folder, everything comes to be OK (except the function that has been dragged out is missing...). It looks like if having added one extra function in the R folder on the top of the earlier 32 (+ 2 data frames) makes problem. I have then consulted John Fox offlist and he seems quite perplexed I'm not sure why you're experiencing this problem. On his advise I have included LazyLoad: no in the package description file. In this case everything goes smoothly then (except LazyLoad will not be activated), the zip file is generated and the package can be installed from R. Has anybody an idea about why a problem occurs when preparing the package for lazy loading? Any remedy? Kind regards, Patrick Make-Package script: cd c:\R\rw2001\src\library del %1\INDEX del %1\data\00Index del %1\chm\*.* /Q ..\..\bin\R CMD build --force --binary --auto-zip %1 ..\..\bin\R CMD build --force %1 ..\..\bin\R CMD check %1 cd %1.Rcheck dvipdfm %1-manual notepad 00check.log cd .. cd .. From: John Fox [EMAIL PROTECTED] To: 'Patrick Giraudoux H' [EMAIL PROTECTED] Subject: RE: [R] writing a simple package in R 2.0 under Windows XP Date: Sun, 23 Jan 2005 11:41:25 -0500 X-Mailer: Microsoft Office Outlook, Build 11.0.6353 X-MIME-Autoconverted: from quoted-printable to 8bit by utinam.univ-fcomte.fr id j0NGfJoD011345 Dear Patrick, I'm not sure why you're experiencing this problem. Two suggestions: (1) Since the problem appears to be with preparing the package for lazy loading, try adding the directive LazyLoad: no (without the quotes) to the package's DESCRIPTION file. (2) Rather than using my batch file, run the commands one at a time to see exactly where the problem is produced; then you could send a message to r-help. I hope this helps, John __ 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 -- Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] several boxplots or bwplots into one graphic
On 24 Jan 2005 at 14:44, Christoph Lehmann wrote: Hi I have 10 variables and 2 groups. I know how to plot a bwplot for ONE var. e.g. var.a var.b var.c .. GROUP 0.2 0.5 0.2 .. 0 0.3 0.2 0.2 .. 0 .. 0.1 0.8 0.7 .. 1 0.5 0.5 0.1 .. 1 .. bwplot(var.a ~ GROUP, data = my.data) How can I plot 10 bwplots (or boxplots) automatically into one graphic? is there any function from lattice which can do this? Hallo It probably depends on how you want to organise your boxplots. You can reformat your table to long format to get second grouping (a,b,...) by reshape (or reShape from Hmisc) and than use interaction and boxplot or bwplot(Group~var|second.grouping) Cheers Petr thanks for a short hint christoph __ 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 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
RE: [R] lme and varFunc()
I am currently analyzing a dataset using lme(). The model I use has the following structure: model-lme(response~Covariate+TreatmentA+TreatmentB, random=~1|Block/Plot,method=ML) When I plot the residuals against the fitted values, I see a clear positive trend (meaning that the variance increases with the mean). I tried to solve this issue using weights=varPower(), but it doesn´t change the residual plot at all. You are aware that you need to use something like weigths= varPower (form= fitted (.)) and the plot residuals using e.g. scatter.smooth (fitted (model), resid (model, type= 'n')) Maybe the latter should also be ok with the default pearson residuals, but I am not sure. Possibly a look into the following would help? @Book{Pin:00a, author = {Pinheiro, Jose C and Bates, Douglas M}, title ={Mixed-Effects Models in {S} and {S}-{P}{L}{U}{S}}, publisher ={Springer}, year = {2000}, address = {New York} } How would you implement such a positive trend in the variance? I´ve tried glmmPQL (which works great with poisson errors), but using glmmPQL I can´t do model simplification. Well, what error distribution do you have / do you expect? Regards, Lorenz - Lorenz Gygax, Dr. sc. nat. Centre for proper housing of ruminants and pigs Swiss Federal Veterinary Office __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] more question
Hello, thank you very much for your help in last email. it is very helpful. right now, i have more questions about my project, 1. solve can i remove the NA from a vectors: for exmample, if my vector is: v - (NA, 1, 2, 3, 4, 5) how can I remove the NA from vector v 2. how I can get input from the user? 3. can I read more than one data files in one program? and how i can write something to a file 4. how i can display/output something on the screen? thank you so much Best wish C-Ming Jan 24, 2005 - [[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