Re: [R] lme4a package loading error
Thank you for pointing ou R-forge. I tried link from R-forge for lme4a, it doesn't work at the time I tried (Returned PAGE NOT FOUND. However, the link for lme4b worked, and I installed lme4b package which can be loaded successfully. lme4b has lmer1() instead of lmer(). However, when trying to run lmer1(), it will tell you this warning message: Warning message: model.Matrix() has been moved from package 'Matrix' to the new package 'MatrixModels' which is now loaded (if installed). Its use from package 'Matrix' is deprecated. Do use it from 'MatrixModels' instead. I think this may be why I got error message when I try to load lme4a, which may have not been updated to look for MatrixModels package instead of Matrix package. The reason I posted to both R and R-mixed-models mailing list is that it seems that this question is more suitable to R-mixed-models, but response there is pretty slow,.. Thanks, John - Original Message From: Gavin Simpson gavin.simp...@ucl.ac.uk To: array chip arrayprof...@yahoo.com Cc: John Sorkin jsor...@grecc.umaryland.edu; r-help@r-project.org; Bert Gunter gunter.ber...@gene.com Sent: Fri, September 10, 2010 10:46:16 AM Subject: Re: lme4a package loading error On Fri, 2010-09-10 at 10:23 -0700, array chip wrote: Thanks for reminding this. So I found lme4a package from Doug's UserR!2010 presentation folder: http://lme4.r-forge.r-project.org/slides/2010-07-20-Gaithersburg/pkg/ What is wrong with the one on the packages tab of the lme4 project page: https://r-forge.r-project.org/R/?group_id=60 ? You might need to make sure you have the latest Matrix as well to run lme4a. Update Matrix via update.packages() or install the latest version from r-forge and see if that helps. Also, try not to cross-post to multiple lists. Stick with one, or move the thread onto the new list. HTH G However, after installation, I got the following error message when trying to load the library: library(Matrix) library(Rcpp) library(minqa) library(lme4a) Error : classes modelMatrix, denseModelMatrix, sparseModelMatrix, ddenseModelMatrix, dsparseModelMatrix, predModule, dPredModule, sPredModule, respModule, glmRespMod, nlsRespMod are not exported by 'namespace:Matrix' Error: package/namespace load failed for 'lme4a' Here is my sessionInfo() sessionInfo() R version 2.11.1 (2010-05-31) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] minqa_1.1.9 Rcpp_0.8.6 Matrix_0.999375-43 lattice_0.18-8 loaded via a namespace (and not attached): [1] grid_2.11.1 nlme_3.1-96 splines_2.11.1 stats4_2.11.1 tools_2.11.1 Any suggestions would be appreciated. John - Original Message From: Gavin Simpson gavin.simp...@ucl.ac.uk To: array chip arrayprof...@yahoo.com Cc: John Sorkin jsor...@grecc.umaryland.edu; r-help@r-project.org; Bert Gunter gunter.ber...@gene.com Sent: Fri, September 10, 2010 10:00:15 AM Subject: Re: [R] lmer fixed effects, SE, t . . . and p On Fri, 2010-09-10 at 09:51 -0700, array chip wrote: But as far as I know, profile() seems to be de-activated in the lme4 package. It is beta software. The lme4a version of the lme4 package might have had profile re-enabled, IIRC. G - Original Message From: Gavin Simpson gavin.simp...@ucl.ac.uk To: John Sorkin jsor...@grecc.umaryland.edu Cc: r-help@r-project.org; Bert Gunter gunter.ber...@gene.com Sent: Fri, September 10, 2010 2:05:37 AM Subject: Re: [R] lmer fixed effects, SE, t . . . and p On Thu, 2010-09-09 at 23:40 -0400, John Sorkin wrote: Bert, I appreciate you comments, and I have read Doug Bates writing about p values in mixed effects regression. It is precisely because I read Doug's material that I asked how are we to interpret the estimates rather than how can we compute a p value. My question is a simple question whose answer is undoubtedly complex, but one that needs an answer. Without p values, or confidence intervals, I am not certain what to make of the results of my analysis. Does my analysis suggest, or does it not suggest that there is a relation between time and y? If I can't answer this question after running the analysis, I don't have any more information than I did before I ran the analysis, and a fair question would be why did I run the analysis? I am asking for help not in calculation a p value or a CI, but rather to know what I can and can't say about the results of the analysis. If this basic question can not be answered, I am at a loss to interpret my results. Thank you, John Doug talks quite
Re: [R] ggplot bar geom: control the filling in the colour legend
Sorry my bad, example too simple try that one out. ggplot(diamonds, aes(clarity, fill=color,colour = cut)) + geom_bar(position = dodge) I want change the filling in the colour legend, not the filling of the bars. Regards Le 10/09/2010 20:41, Ista Zahn a écrit : ggplot(diamonds, aes(clarity, colour = cut)) + geom_bar(fill=white) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to comment out entire code parts in Sweave files
Hi, I am wondering if there is any convenient way to comment out an entire region of a Sweave file which comprises R and Latex code. Currently I'm doing it for the R and Latex parts separately or transfer the unwanted part into a different file. But both are not great solutions. (I am doing this when updating old files and debugging) Is there a way to do this with an equivalent of \iffalse \fi or is there some stop command after which Sweave just stops processing? Thanks a lot for any suggestions. Werner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] convert 1, 10, and 100 to 0001, 0010, 0100 etc.
On 09/11/2010 05:00 AM, Peng, C wrote: Thanks David. func() simply prints out the 0010 as a text value. It is still not numeric. I am just curious about it. is.numeric(func4(0100)) 00100[1] FALSE Well, you can look at the kind of things as.octmode friends do. The only thing you can do is to change the print method; internally there can be no difference between the representation of 10 and 010. -- Peter Dalgaard Center for Statistics, Copenhagen Business School Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Traversing a dendrogram object
Hi all, I'm trying to traverse a dendrogram object (cast from an hclust clustering). What's the simplest way to obtain the height per leaf node? I suppose I can print the dendrogram text and parse the height values, etc... But is there a way to query for/access a leaf's branch height? Thanks, Paul -- Paul Rigor http://www.ics.uci.edu/~prigor [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Save R-Part Tree
Would using the ?save function on the rpart object do what you want ? Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Fri, Sep 10, 2010 at 4:25 PM, Paul Kramer gitterro...@gmx.de wrote: Hello, I have some Data, that I analyse using a regression tree (by using rpart). Now I would like to save this tree to a file for later use, and load it (not necessarily in the same workspace). It would be most preferrable, if I could just save some parameters (later probably to a database) and load them again to reform the tree. Is this possible? And if yes, how? Thanks in advance --Paul-- -- GRATIS: Spider-Man 1-3 sowie 300 weitere Videos! -- GRATIS: Spider-Man 1-3 sowie 300 weitere Videos! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Over lay 2 scale in same plot
On 09/10/2010 10:43 PM, mamunbabu2001 wrote: Hi Josh, Thanks for your reply. I gave a reply yesterday but found that it was not posted. I managed to plot the bar pot and overlay points. The problem I am facing now is the spread of Y scale. The values I am plotting in Y scale are very close. so they look pretty flat. (lowest value 7.5 and highest value 8.5 , so if the ranges in y scale is 6-8, 8-10 , the values looks pretty flat.) How can I make the spread of Y scale i.e 6.2 - 6.4 - 6.6 - .. 8.8 - 10 so that values does not look flat. I have added an image below. Hi Mamun, You can get two different scales e.g. 0-10 on the left and 7-9 on the right, but you will want to color code the two axes and plots so that the viewer knows which plot goes with which scale. If you want to try this, look at twoord.plot in the plotrix package. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Argument lib is missing
Dear all, I have installed R using yum install R-2.9. I am able to use R for general functions but when I installed some library say gplots I am getting the below error. install.packages(gplots) Warning in install.packages(gplots) : argument 'lib' is missing: using '/home/fedora/R/i386-redhat-linux-gnu-library/2.11' Warning: unable to access index for repository http://cran.csdb.cn/src/contrib Warning message: In getDependencies(pkgs, dependencies, available, lib) : package gplots is not available any suggestion will be appreciable. Thank you Khush [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] adding zeroes after old zeroes in a vector ??
OK thanks to all, I don't need, more Up to this moment the fastest working code is Jonathan Chang's http://stackoverflow.com/questions/3686982/r-adding-zeroes-after-old-zeroes-in-a-vector/3689360#3689360 rr - rle(tmp) ## Pad so that it always begins with 1 and ends with 1 if (rr$values[1] == 0) { rr$values - c(1, rr$values) rr$lengths - c(0, rr$lengths) } if (rr$values[length(rr$values)] == 0) { rr$values - c(rr$values, 1) rr$lengths - c(rr$lengths, 0) } zero.indices - seq(from=2, to=length(rr$values), by=2) one.indices - seq(from=3, to=length(rr$values), by=2) rr$lengths[zero.indices] - rr$lengths[zero.indices] + pmin(rr$lengths[one.indices], n) rr$lengths[one.indices] - pmax(0, rr$lengths[one.indices] - n) inverse.rle(rr) -- View this message in context: http://r.789695.n4.nabble.com/adding-zeroes-after-old-zeroes-in-a-vector-tp2534824p2535573.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Latex fonts in R graphics
Hello, R users. I am trying to embed Computer modern fonts to an R plot and I get the following error. CM - Type1Font(CM, + c(paste(cm-lgc/fonts/afm/public/cm-lgc/, + c(fcmr8a.afm, fcmb8a.afm, fcmri8a.afm, fcmbi8a.afm), sep=), + ./cmsyase.afm)) pdf(cm.pdf, width=3, height=3, family=CM) plot(1:length(y), y, xlab=ss, ylab=expression(x[2])) ## for any vector y dev.off() null device 1 embedFonts(cm.pdf, outfile=cmembed.pdf, fontpaths=c(cm-lgc/fonts/type1/public/cm-lgc, .)) Error in embedFonts(cm.pdf, outfile = cmembed.pdf, fontpaths = c(cm-lgc/fonts/type1/public/cm-lgc, : status -1 in running command 'gswin32c.exe -dNOPAUSE -dBATCH -q -dAutoRotatePages=/None -sDEVICE=pdfwrite -sOutputFile=C:\DOCUME~1\user\LOCALS~1\Temp\RtmpccEtgV\Rembed28163716 -sFONTPATH=cm-lgc/fonts/type1/public/cm-lgc;. cm.pdf' In addition: Warning message: In system(cmd) : gswin32c.exe not found Operating system: Windows XP, SP2. cm-lgc has been unzipped in the working directory C:/Program Files/R/R-2.10.1 and the AFM, PFB files are also in same directory. Any help? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to check available package
On 11/09/2010 12:25 AM, Stephen Liu wrote: Hi folk, How to chcek whether a package is available on R repo? What command shall I run? TIA ?available.packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to comment out entire code parts in Sweave files
On 11/09/2010 4:42 AM, Werner W. wrote: Hi, I am wondering if there is any convenient way to comment out an entire region of a Sweave file which comprises R and Latex code. Currently I'm doing it for the R and Latex parts separately or transfer the unwanted part into a different file. But both are not great solutions. (I am doing this when updating old files and debugging) Is there a way to do this with an equivalent of \iffalse \fi or is there some stop command after which Sweave just stops processing? Prefixing each line with % should work, if you're starting in LateX mode. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] 'programatically' list or call objects for use in a function?
Esteemed R users and developers, How does one 'programatically' list or call objects for use in a function? For example, i thought i could do something better than this: save(A.cwb, B.cwb, C.cwb, D.cwb, E.cwb, F.cwb, file=afile.RData) with something like these- prfxs - c(A, B, C, D, E, F) #** save(as.name(paste(prfxs, cwb, sep=.)), file=afile.RData) or this- do.call(save, paste(prfxs, cwb, sep=.), file=afile.RData) Both failed. #** And while i've got your attention- is there a 'letter equivalent' to seq() which would have worked nicely for prfxs? ie., letter.seq(A:F) Thoughts and suggestions sincerely appreciated, Karl -- Karl Brand Department of Genetics Erasmus MC Dr Molewaterplein 50 3015 GE Rotterdam T +31 (0)10 704 3457 |F +31 (0)10 704 4743 |M +31 (0)642 777 268 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Argument lib is missing
On Sep 11, 2010, at 6:29 AM, khush wrote: Dear all, I have installed R using yum install R-2.9. I am able to use R for general functions but when I installed some library say gplots I am getting the below error. install.packages(gplots) Warning in install.packages(gplots) : argument 'lib' is missing: using '/home/fedora/R/i386-redhat-linux-gnu-library/2.11' That warning should not cause much problem. Warning: unable to access index for repository http://cran.csdb.cn/src/contrib From time to time it happens that repositories are unavailable. I just checked and at the moment that repository is available. You could try again. (Or you could have tried another repository at that time. Trying another repository might make sense even now, since the version of gplots at that repository is fairly outdated. The current version is 2.8.0 and the one at csdb.cn is 2.7.1 from May 2009. There have been several revisions since that date.) Warning message: In getDependencies(pkgs, dependencies, available, lib) : package gplots is not available any suggestion will be appreciable. Thank you Khush David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Latex fonts in R graphics
On Sep 11, 2010, at 7:18 AM, KARAVASILIS GEORGE wrote: Hello, R users. I am trying to embed Computer modern fonts to an R plot and I get the following error. CM - Type1Font(CM, + c(paste(cm-lgc/fonts/afm/public/cm-lgc/, + c(fcmr8a.afm, fcmb8a.afm, fcmri8a.afm, fcmbi8a.afm), sep=), + ./cmsyase.afm)) pdf(cm.pdf, width=3, height=3, family=CM) plot(1:length(y), y, xlab=ss, ylab=expression(x[2])) ## for any vector y dev.off() null device 1 embedFonts(cm.pdf, outfile=cmembed.pdf, fontpaths=c(cm-lgc/ fonts/type1/public/cm-lgc, .)) Error in embedFonts(cm.pdf, outfile = cmembed.pdf, fontpaths = c(cm-lgc/fonts/type1/public/cm-lgc, : status -1 in running command 'gswin32c.exe -dNOPAUSE -dBATCH -q - dAutoRotatePages=/None -sDEVICE=pdfwrite -sOutputFile=C: \DOCUME~1\user\LOCALS~1\Temp\RtmpccEtgV\Rembed28163716 -sFONTPATH=cm- lgc/fonts/type1/public/cm-lgc;. cm.pdf' In addition: Warning message: In system(cmd) : gswin32c.exe not found Operating system: Windows XP, SP2. cm-lgc has been unzipped in the working directory C:/Program Files/ R/R-2.10.1 and the AFM, PFB files are also in same directory. The error message is telling us that you do not have Ghostscript installed properly. While you are at it, you should probably updated R as well. -- David Any help? -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 'programatically' list or call objects for use in a function?
On 11/09/2010 8:00 AM, Karl Brand wrote: Esteemed R users and developers, How does one 'programatically' list or call objects for use in a function? It depends on the function. For example, i thought i could do something better than this: save(A.cwb, B.cwb, C.cwb, D.cwb, E.cwb, F.cwb, file=afile.RData) with something like these- prfxs - c(A, B, C, D, E, F) #** save(as.name(paste(prfxs, cwb, sep=.)), file=afile.RData) For save, use list=paste(prfxs, cwb, sep=.). or this- do.call(save, paste(prfxs, cwb, sep=.), file=afile.RData) do.call wants a *list* of arguments, not a single vector of character strings. You could construct a list of the names of the objects you want to save, but that's a pain. Just use the list= argument (which doesn't want a list argument :-). Both failed. #** And while i've got your attention- is there a 'letter equivalent' to seq() which would have worked nicely for prfxs? ie., letter.seq(A:F) Not that I know of, but LETTERS[1:6] will give you the sequence, and it's easy to write a function that you'd call as letter.seq(A, F). Having your function work as in your example would be messy. Duncan Murdoch Thoughts and suggestions sincerely appreciated, Karl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] for loop
Hello, I have a simple question: I want to list numbers 1:k, but if k 1, I hope nothing listed. how should we do? k=2 for (i in 1:k) print(i) [1] 1 # -correct [1] 2 k=0 for (i in 1:k) print(i) [1] 1 # wrong [1] 0 thanks jian [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] for loop
I've been caught out by this more times than I care to admit - forgetting that an R for loop isn't a C for loop. Here's one solution... k - start.value while (k = end.value) { # do stuff k - k + 1 } Michael On 11 September 2010 18:39, Yuan Jian jayuan2...@yahoo.com wrote: Hello, I have a simple question: I want to list numbers 1:k, but if k 1, I hope nothing listed. how should we do? k=2 for (i in 1:k) print(i) [1] 1 # -correct [1] 2 k=0 for (i in 1:k) print(i) [1] 1 # wrong [1] 0 thanks jian [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] for loop
On Sat, Sep 11, 2010 at 4:39 AM, Yuan Jian jayuan2...@yahoo.com wrote: Hello, I have a simple question: I want to list numbers 1:k, but if k 1, I hope nothing listed. how should we do? k=2 for (i in 1:k) print(i) [1] 1 # -correct [1] 2 k=0 for (i in 1:k) print(i) [1] 1 # wrong [1] 0 Try: k - 0 for (i in seq_len(k)) print(i) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] for loop
or: k=0 for (i in 1:k) if(k0) print(i) -- View this message in context: http://r.789695.n4.nabble.com/for-loop-tp2535626p2535640.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 'programatically' list or call objects for use in a function?
Cheers Duncan, for your FAST answers and patience. (fast patience?!) I was close. But closer reading of ?save would also have worked i see now :$. LETTERS[] = :) thanks again, Karl On 9/11/2010 2:10 PM, Duncan Murdoch wrote: On 11/09/2010 8:00 AM, Karl Brand wrote: Esteemed R users and developers, How does one 'programatically' list or call objects for use in a function? It depends on the function. For example, i thought i could do something better than this: save(A.cwb, B.cwb, C.cwb, D.cwb, E.cwb, F.cwb, file=afile.RData) with something like these- prfxs - c(A, B, C, D, E, F) #** save(as.name(paste(prfxs, cwb, sep=.)), file=afile.RData) For save, use list=paste(prfxs, cwb, sep=.). or this- do.call(save, paste(prfxs, cwb, sep=.), file=afile.RData) do.call wants a *list* of arguments, not a single vector of character strings. You could construct a list of the names of the objects you want to save, but that's a pain. Just use the list= argument (which doesn't want a list argument :-). Both failed. #** And while i've got your attention- is there a 'letter equivalent' to seq() which would have worked nicely for prfxs? ie., letter.seq(A:F) Not that I know of, but LETTERS[1:6] will give you the sequence, and it's easy to write a function that you'd call as letter.seq(A, F). Having your function work as in your example would be messy. Duncan Murdoch Thoughts and suggestions sincerely appreciated, Karl -- Karl Brand Department of Genetics Erasmus MC Dr Molewaterplein 50 3015 GE Rotterdam T +31 (0)10 704 3457 |F +31 (0)10 704 4743 |M +31 (0)642 777 268 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] for loop
On Sep 11, 2010, at 8:39 AM, Peng, C wrote: or: k=0 for (i in 1:k) if(k0) print(i) Because of the way the : operator works, I would have tested k =1 k=0.5 for (i in 1:k) if (k0){print(i)} [1] 1 But Gabor's suggestion to use seq_len(k) is cleaner, anyway. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Argument lib is missing
On Sep 11, 2010, at 8:02 AM, David Winsemius wrote: On Sep 11, 2010, at 6:29 AM, khush wrote: Dear all, I have installed R using yum install R-2.9. I am able to use R for general functions but when I installed some library say gplots I am getting the below error. install.packages(gplots) Warning in install.packages(gplots) : argument 'lib' is missing: using '/home/fedora/R/i386-redhat-linux-gnu-library/2.11' That warning should not cause much problem. Or maybe it would. I just noticed that you said you were using an ancient version of R and that library location is for the current version. You probably need to get advice from a fellow Redhat user if you want to run an outdated version. Installing packages for the current version is not going to be very successful. There is a repository of packages for older systems and you can find the link at the bottom of the package list on CRAN. http://cran.r-project.org/web/packages/ Look for the Archive link. Warning: unable to access index for repository http://cran.csdb.cn/src/contrib From time to time it happens that repositories are unavailable. I just checked and at the moment that repository is available. You could try again. (Or you could have tried another repository at that time. Trying another repository might make sense even now, since the version of gplots at that repository is fairly outdated. The current version is 2.8.0 and the one at csdb.cn is 2.7.1 from May 2009. There have been several revisions since that date.) Warning message: In getDependencies(pkgs, dependencies, available, lib) : package ‘gplots’ is not available any suggestion will be appreciable. Thank you Khush David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] nonlinear programming package
There are currently 2 packages that can be of help for solving the type of problems that you are describing: 1. Rsolnp 2. alabama For optimizing nonlinear objective functions subject to linear equality/inequality constraints, you also have the `spg' function in the BB package. In contrast, the `constrOptim' function in the base distribution can handle only linear inequality constraints. All of these packages are available on CRAN. Hope this helps, Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Xiaoxi Gao rhel...@hotmail.com Date: Friday, September 10, 2010 9:26 pm Subject: [R] nonlinear programming package To: R Help r-help@r-project.org Hello R users, Can anyone recommend me any package that can be used to solve linear programming subject to nonlinear equality/inequality constraints. Rdonlp2 is now unavailable due to licensing issue. Thanks, Xiaoxi [[alternative HTML version deleted]] __ R-help@r-project.org mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] bootstrapping
Hi Everyone, I am implementing a special case of Random forests. At one point, I have a list of which I then sample for replacement. So if the list is 100 elements, I get 100 elements some of them duplicates. How can I easily get the elements that were not included in the list? I realize i can do this with a for loop by going through each element and checking if it's in the list but I am wondering if there is a faster way. Thank you for your help! Kind regards, Greg __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] bootstrapping
On Sep 11, 2010, at 9:50 AM, Gregory Ryslik wrote: Hi Everyone, I am implementing a special case of Random forests. At one point, I have a list of which I then sample for replacement. So if the list is 100 elements, I get 100 elements some of them duplicates. How can I easily get the elements that were not included in the list? I realize i can do this with a for loop by going through each element and checking if it's in the list but I am wondering if there is a faster way. ?setdiff ?%in% -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] approxfun-problems (yleft and yright ignored)
SW == Samuel Wuest wue...@tcd.ie on Thu, 26 Aug 2010 14:34:26 +0100 writes: SW Hi Greg, SW thanks for the suggestion: SW I have attached some small dataset that can be used to reproduce the SW odd behavior of the approxfun-function. SW If it gets stripped off my email, it can also be downloaded at: SW http://bioinf.gen.tcd.ie/approx.data.Rdata SW Strangely, the problem seems specific to the data structure in my SW expression set, when I use simulated data, everything worked fine. SW Here is some code that I run and resulted in the strange output that I SW have described in my initial post: ### load the data: a list called approx.data load(file=approx.data.Rdata) ### contains the slots x, y, input names(approx.data) SW [1] x y input ### with y ranging between 0 and 1 range(approx.data$y) SW [1] 0 1 ### compare ranges of x and input-x values (the latter is a small subset of 500 data points): range(approx.data$x) SW [1] 3.098444 7.268812 range(approx.data$input) SW [1] 3.329408 13.026700 ### generate the interpolation function (warning message benign) interp - approxfun(approx.data$x, approx.data$y, yleft=1, yright=0, rule=2) SW Warning message: SW In approxfun(approx.data$x, approx.data$y, yleft = 1, yright = 0, : SW collapsing to unique 'x' values ### apply to input-values y.out - sapply(approx.data$input, interp) ### still I find output values 1, even though yleft=1: range(y.out) SW [1] 0.00 7.207233 I get completely different (and correct) results, by the way the *same* you have in the bug report you've submitted (https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14377) and which does *not* show any bug: range(y.out) [1] 0.000 0.9816907 Of course, I do believe that you've seen the above problems, -- on 64-bit Mac ? as you report in sessionInfo() ? -- but I cannot reproduce them. And also, you seem yourself to be able to get different results for the same data... what are the circumstances? Regards, Martin Maechler, ETH Zurich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] approxfun-problems (yleft and yright ignored)
On 11/09/2010 10:04 AM, Martin Maechler wrote: SW == Samuel Wuest wue...@tcd.ie on Thu, 26 Aug 2010 14:34:26 +0100 writes: SW Hi Greg, SW thanks for the suggestion: SW I have attached some small dataset that can be used to reproduce the SW odd behavior of the approxfun-function. SW If it gets stripped off my email, it can also be downloaded at: SW http://bioinf.gen.tcd.ie/approx.data.Rdata SW Strangely, the problem seems specific to the data structure in my SW expression set, when I use simulated data, everything worked fine. SW Here is some code that I run and resulted in the strange output that I SW have described in my initial post: ### load the data: a list called approx.data load(file=approx.data.Rdata) ### contains the slots x, y, input names(approx.data) SW [1] x y input ### with y ranging between 0 and 1 range(approx.data$y) SW [1] 0 1 ### compare ranges of x and input-x values (the latter is a small subset of 500 data points): range(approx.data$x) SW [1] 3.098444 7.268812 range(approx.data$input) SW [1] 3.329408 13.026700 ### generate the interpolation function (warning message benign) interp - approxfun(approx.data$x, approx.data$y, yleft=1, yright=0, rule=2) SW Warning message: SW In approxfun(approx.data$x, approx.data$y, yleft = 1, yright = 0, : SW collapsing to unique 'x' values ### apply to input-values y.out - sapply(approx.data$input, interp) ### still I find output values 1, even though yleft=1: range(y.out) SW [1] 0.00 7.207233 I get completely different (and correct) results, by the way the *same* you have in the bug report you've submitted (https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14377) and which does *not* show any bug: range(y.out) [1] 0.000 0.9816907 Of course, I do believe that you've seen the above problems, -- on 64-bit Mac ? as you report in sessionInfo() ? -- but I cannot reproduce them. And also, you seem yourself to be able to get different results for the same data... what are the circumstances? I think Greg Snow's analysis (linked from the bug report) is right. length(unique(x)) can be different than length(levels(as.factor(x))) (which is what tapply uses to determine the number of levels). I've fixed it by replacing y - as.vector(tapply(y,x,ties)) with y - as.vector(tapply(y,match(x,x),ties)) since match() uses the same rules as unique. An argument could be made that tapply should be changed instead, but it is behaving as documented, so I didn't want to do that. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] approxfun-problems (yleft and yright ignored)
On Sep 11, 2010, at 10:04 AM, Martin Maechler wrote: SW == Samuel Wuest wue...@tcd.ie on Thu, 26 Aug 2010 14:34:26 +0100 writes: SW Hi Greg, SW thanks for the suggestion: SW I have attached some small dataset that can be used to reproduce the SW odd behavior of the approxfun-function. SW If it gets stripped off my email, it can also be downloaded at: SW http://bioinf.gen.tcd.ie/approx.data.Rdata SW Strangely, the problem seems specific to the data structure in my SW expression set, when I use simulated data, everything worked fine. SW Here is some code that I run and resulted in the strange output that I SW have described in my initial post: ### load the data: a list called approx.data load(file=approx.data.Rdata) ### contains the slots x, y, input names(approx.data) SW [1] x y input ### with y ranging between 0 and 1 range(approx.data$y) SW [1] 0 1 ### compare ranges of x and input-x values (the latter is a small subset of 500 data points): range(approx.data$x) SW [1] 3.098444 7.268812 range(approx.data$input) SW [1] 3.329408 13.026700 ### generate the interpolation function (warning message benign) interp - approxfun(approx.data$x, approx.data$y, yleft=1, yright=0, rule=2) SW Warning message: SW In approxfun(approx.data$x, approx.data$y, yleft = 1, yright = 0, : SW collapsing to unique 'x' values ### apply to input-values y.out - sapply(approx.data$input, interp) ### still I find output values 1, even though yleft=1: range(y.out) SW [1] 0.00 7.207233 #-- on another 64 bit Mac - load(file=approx.data.Rdata) names(approx.data) [1] x y input range(approx.data$y) [1] 0 1 range(approx.data$x) [1] 3.098444 7.268812 interp - approxfun(approx.data$x, approx.data$y, yleft=1, yright=0, rule=2) Warning message: In approxfun(approx.data$x, approx.data$y, yleft = 1, yright = 0, : collapsing to unique 'x' values y.out - sapply(approx.data$input, interp) range(y.out) [1] -5.143958e+284 9.816907e-01 interp function (v) .C(R_approxfun, as.double(x), as.double(y), as.integer(n), xout = as.double(v), as.integer(length(v)), as.integer(method), as.double(yleft), as.double(yright), as.double(f), NAOK = TRUE, PACKAGE = stats)$xout environment: 0x1598c91b8 # attempt to offer yright and yledft in the sapply call failed y.out - sapply(approx.data$input, interp, yright=0, yleft=1) Error in FUN(c(6.99984458535897, 4.85139079147721, 7.58922165833, 10.8135863246057, : unused argument(s) (yright = 0, yleft = 1) #Create yright and yleft in the calling environment: yright=0; yleft=1 y.out - sapply(approx.data$input, interp) range(y.out) [1] 0.000 0.9816907 Now it works as expected. It seems to me that the yleft and yright values may not be properly incorporated into the constructed function. sessionInfo() R version 2.11.1 Patched (2010-06-14 r52281) x86_64-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] grid splines stats graphics grDevices [6] utils datasets methods base other attached packages: [1] gplots_2.8.0 caTools_1.10 bitops_1.0-4.1 [4] gdata_2.8.0 gtools_2.6.2 sos_1.2-9 [7] brew_0.1-1 qpcR_1.3-2 minqa_1.1.9 [10] Rcpp_0.8.5 nlme_3.1-96 cluster_1.12.3 [13] rgl_0.91 minpack.lm_1.1-4 MASS_7.3-6 [16] chron_2.3-35 maps_2.1-4 gmodels_2.15.0 [19] rbenchmark_0.3 data.table_1.5 rms_3.0-0 [22] Hmisc_3.8-1 survival_2.35-8 plyr_1.1 [25] lattice_0.18-8 loaded via a namespace (and not attached): [1] tools_2.11.1 -- David Winsemius I get completely different (and correct) results, by the way the *same* you have in the bug report you've submitted (https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14377) and which does *not* show any bug: range(y.out) [1] 0.000 0.9816907 Of course, I do believe that you've seen the above problems, -- on 64-bit Mac ? as you report in sessionInfo() ? -- but I cannot reproduce them. And also, you seem yourself to be able to get different results for the same data... what are the circumstances? Regards, Martin Maechler, ETH Zurich David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] outputting arima models
sseq - c(1, seq(5, 120, by = 5)) for(i in 1:length(sseq)){ assign(paste(arima, i, sep=), arima0(data.ts[sseq[i]:(sseq[i]+115)], order=c(1,1,1))) } pred1 = predict(arima1, n.ahead = 5, se.fit = TRUE)$pred how do I traverse the arima models so I repeat the above prediction procedure(bold) on all arima models. Also, how do i automatically create one huge vector of the predictions from all the arima models? -- View this message in context: http://r.789695.n4.nabble.com/outputting-arima-models-tp2535695p2535695.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ggplot: stat_smooth() and nls method
Hi all, Does one of you know if there is any way to combine a nls method in the stat_smooth of ggplot? Regards -- - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] approxfun-problems (yleft and yright ignored)
MM == Martin Maechler maech...@stat.math.ethz.ch on Sat, 11 Sep 2010 16:04:37 +0200 writes: SW == Samuel Wuest wue...@tcd.ie on Thu, 26 Aug 2010 14:34:26 +0100 writes: SW Hi Greg, SW thanks for the suggestion: SW I have attached some small dataset that can be used to reproduce the SW odd behavior of the approxfun-function. SW If it gets stripped off my email, it can also be downloaded at: SW http://bioinf.gen.tcd.ie/approx.data.Rdata SW Strangely, the problem seems specific to the data structure in my SW expression set, when I use simulated data, everything worked fine. SW Here is some code that I run and resulted in the strange output that I SW have described in my initial post: ### load the data: a list called approx.data load(file=approx.data.Rdata) ### contains the slots x, y, input names(approx.data) SW [1] x y input ### with y ranging between 0 and 1 range(approx.data$y) SW [1] 0 1 ### compare ranges of x and input-x values (the latter is a small subset of 500 data points): range(approx.data$x) SW [1] 3.098444 7.268812 range(approx.data$input) SW [1] 3.329408 13.026700 ### generate the interpolation function (warning message benign) interp - approxfun(approx.data$x, approx.data$y, yleft=1, yright=0, rule=2) SW Warning message: SW In approxfun(approx.data$x, approx.data$y, yleft = 1, yright = 0, : SW collapsing to unique 'x' values ### apply to input-values y.out - sapply(approx.data$input, interp) ### still I find output values 1, even though yleft=1: range(y.out) SW [1] 0.00 7.207233 MM I get completely different (and correct) results, MM by the way the *same* you have in the bug report you've MM submitted MM (https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14377) MM and which does *not* show any bug: range(y.out) MM [1] 0.000 0.9816907 MM Of course, I do believe that you've seen the above problems, MM -- on 64-bit Mac ? as you report in sessionInfo() ? -- MM but I cannot reproduce them. MM And also, you seem yourself to be able to get different results MM for the same data... what are the circumstances? I now see that you *did* mention the fact that you see *different* results when you *RE*run the same code on this data. The subject ( ...yleft and yright ignored) is misleading in any case. These are not at all ignored..., but indeed (as Duncan Murdoch has noted on the bug website), there *is* a bug, so you are principally right in reporting -- thank you! and I could also confirm that -- as you mentioned in your first post -- this bug does not appear when using R 2.8.1 (at least on my platform). Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] xlab with text and expression
Dear R users, say plot(rnorm(1)~rnorm(1), xlab=paste('abc', expression(x=1)), I want proper sign of weak inequality not just '=' will appreciate! robert -- View this message in context: http://r.789695.n4.nabble.com/xlab-with-text-and-expression-tp2535732p2535732.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] approxfun-problems (yleft and yright ignored)
On 11/09/2010 10:53 AM, Martin Maechler wrote: MM == Martin Maechler maech...@stat.math.ethz.ch on Sat, 11 Sep 2010 16:04:37 +0200 writes: SW == Samuel Wuest wue...@tcd.ie on Thu, 26 Aug 2010 14:34:26 +0100 writes: SW Hi Greg, SW thanks for the suggestion: SW I have attached some small dataset that can be used to reproduce the SW odd behavior of the approxfun-function. SW If it gets stripped off my email, it can also be downloaded at: SW http://bioinf.gen.tcd.ie/approx.data.Rdata SW Strangely, the problem seems specific to the data structure in my SW expression set, when I use simulated data, everything worked fine. SW Here is some code that I run and resulted in the strange output that I SW have described in my initial post: ### load the data: a list called approx.data load(file=approx.data.Rdata) ### contains the slots x, y, input names(approx.data) SW [1] x y input ### with y ranging between 0 and 1 range(approx.data$y) SW [1] 0 1 ### compare ranges of x and input-x values (the latter is a small subset of 500 data points): range(approx.data$x) SW [1] 3.098444 7.268812 range(approx.data$input) SW [1] 3.329408 13.026700 ### generate the interpolation function (warning message benign) interp - approxfun(approx.data$x, approx.data$y, yleft=1, yright=0, rule=2) SW Warning message: SW In approxfun(approx.data$x, approx.data$y, yleft = 1, yright = 0, : SW collapsing to unique 'x' values ### apply to input-values y.out - sapply(approx.data$input, interp) ### still I find output values 1, even though yleft=1: range(y.out) SW [1] 0.00 7.207233 MM I get completely different (and correct) results, MM by the way the *same* you have in the bug report you've MM submitted MM (https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14377) MM and which does *not* show any bug: range(y.out) MM [1] 0.000 0.9816907 MM Of course, I do believe that you've seen the above problems, MM -- on 64-bit Mac ? as you report in sessionInfo() ? -- MM but I cannot reproduce them. MM And also, you seem yourself to be able to get different results MM for the same data... what are the circumstances? I now see that you *did* mention the fact that you see *different* results when you *sort(levels(as.factor(approx.data$x)))[285:287]RE*run the same code on this data. The subject ( ...yleft and yright ignored) is misleading in any case. These are not at all ignored..., but indeed (as Duncan Murdoch has noted on the bug website), there *is* a bug, so you are principally right in reporting -- thank you! and I could also confirm that -- as you mentioned in your first post -- this bug does not appear when using R 2.8.1 (at least on my platform). I see this too -- and it appears to be because as.factor() finds a different number of levels in R-devel than it did in 2.8.1. In 2.8.1, the level names are not unique, but in R-devel, they are, so there are fewer of them. In 2.8.1, I see sort(levels(as.factor(approx.data$x)))[285:287] [1] 3.97124402436476 3.97124402436476 3.97129741844245 (notice the first two are identical), whereas in R-devel, we get [1] 3.97124402436476 3.97129741844245 3.97408959567848 from the same expression. Duncan Murdoch Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] approxfun-problems (yleft and yright ignored)
Duncan Murdoch murdoch.dun...@gmail.com on Sat, 11 Sep 2010 10:32:38 -0400 writes: On 11/09/2010 10:04 AM, Martin Maechler wrote: SW == Samuel Wuest wue...@tcd.ie on Thu, 26 Aug 2010 14:34:26 +0100 writes: SW Hi Greg, SW thanks for the suggestion: SW I have attached some small dataset that can be used to reproduce the SW odd behavior of the approxfun-function. SW If it gets stripped off my email, it can also be downloaded at: SW http://bioinf.gen.tcd.ie/approx.data.Rdata SW Strangely, the problem seems specific to the data structure in my SW expression set, when I use simulated data, everything worked fine. SW Here is some code that I run and resulted in the strange output that I SW have described in my initial post: ### load the data: a list called approx.data load(file=approx.data.Rdata) ### contains the slots x, y, input names(approx.data) SW [1] x y input ### with y ranging between 0 and 1 range(approx.data$y) SW [1] 0 1 ### compare ranges of x and input-x values (the latter is a small subset of 500 data points): range(approx.data$x) SW [1] 3.098444 7.268812 range(approx.data$input) SW [1] 3.329408 13.026700 ### generate the interpolation function (warning message benign) interp - approxfun(approx.data$x, approx.data$y, yleft=1, yright=0, rule=2) SW Warning message: SW In approxfun(approx.data$x, approx.data$y, yleft = 1, yright = 0, : SW collapsing to unique 'x' values ### apply to input-values y.out - sapply(approx.data$input, interp) ### still I find output values 1, even though yleft=1: range(y.out) SW [1] 0.00 7.207233 I get completely different (and correct) results, by the way the *same* you have in the bug report you've submitted (https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14377) and which does *not* show any bug: range(y.out) [1] 0.000 0.9816907 Of course, I do believe that you've seen the above problems, -- on 64-bit Mac ? as you report in sessionInfo() ? -- but I cannot reproduce them. And also, you seem yourself to be able to get different results for the same data... what are the circumstances? I think Greg Snow's analysis (linked from the bug report) is right. length(unique(x)) can be different than length(levels(as.factor(x))) (which is what tapply uses to determine the number of levels). I've fixed it by replacing y - as.vector(tapply(y,x,ties)) with y - as.vector(tapply(y,match(x,x),ties)) since match() uses the same rules as unique. An argument could be made that tapply should be changed instead, but it is behaving as documented, so I didn't want to do that. I think you've worked around the problem (and I had seen Greg's analysis), thank you. BTW, the problem wasn't there in R 2.8.x, as we since had improved factor() {.. and btw, the same changes should happen to approx(), spline(), splinefun() ..} *However* why on earth can the results become *random*, i.e., differ from one call to the other, with identical data in the same R session? I currently guess that sometimes the operands (of the linear interpolation rational arithmetic) are kept in high-precision registers and sometimes not, I must say I am puzzled that this happens dynamically rather than determined by the exact compiler flags at (R's) build time ?? (and yes, this thread should have been on R-devel rather than R-help from the start ...) Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] xlab with text and expression
On Sep 11, 2010, at 11:07 AM, threshold wrote: Dear R users, say plot(rnorm(1)~rnorm(1), xlab=paste('abc', expression(x=1)), plot(rnorm(1)~rnorm(1), xlab=expression(abc~x = 1)) # or if you are uncertain whether abc is a plotmath-special then this also works plot(rnorm(1)~rnorm(1), xlab=expression(abc~x = 1)) I want proper sign of weak inequality not just '=' will appreciate! robert -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] approxfun-problems (yleft and yright ignored)
On 11/09/2010 11:13 AM, Martin Maechler wrote: Duncan Murdoch murdoch.dun...@gmail.com on Sat, 11 Sep 2010 10:32:38 -0400 writes: On 11/09/2010 10:04 AM, Martin Maechler wrote: SW == Samuel Wuest wue...@tcd.ie on Thu, 26 Aug 2010 14:34:26 +0100 writes: SW Hi Greg, SW thanks for the suggestion: SW I have attached some small dataset that can be used to reproduce the SW odd behavior of the approxfun-function. SW If it gets stripped off my email, it can also be downloaded at: SW http://bioinf.gen.tcd.ie/approx.data.Rdata SW Strangely, the problem seems specific to the data structure in my SW expression set, when I use simulated data, everything worked fine. SW Here is some code that I run and resulted in the strange output that I SW have described in my initial post: ### load the data: a list called approx.data load(file=approx.data.Rdata) ### contains the slots x, y, input names(approx.data) SW [1] x y input ### with y ranging between 0 and 1 range(approx.data$y) SW [1] 0 1 ### compare ranges of x and input-x values (the latter is a small subset of 500 data points): range(approx.data$x) SW [1] 3.098444 7.268812 range(approx.data$input) SW [1] 3.329408 13.026700 ### generate the interpolation function (warning message benign) interp - approxfun(approx.data$x, approx.data$y, yleft=1, yright=0, rule=2) SW Warning message: SW In approxfun(approx.data$x, approx.data$y, yleft = 1, yright = 0, : SW collapsing to unique 'x' values ### apply to input-values y.out - sapply(approx.data$input, interp) ### still I find output values 1, even though yleft=1: range(y.out) SW [1] 0.00 7.207233 I get completely different (and correct) results, by the way the *same* you have in the bug report you've submitted (https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14377) and which does *not* show any bug: range(y.out) [1] 0.000 0.9816907 Of course, I do believe that you've seen the above problems, -- on 64-bit Mac ? as you report in sessionInfo() ? -- but I cannot reproduce them. And also, you seem yourself to be able to get different results for the same data... what are the circumstances? I think Greg Snow's analysis (linked from the bug report) is right. length(unique(x)) can be different than length(levels(as.factor(x))) (which is what tapply uses to determine the number of levels). I've fixed it by replacing y - as.vector(tapply(y,x,ties)) with y - as.vector(tapply(y,match(x,x),ties)) since match() uses the same rules as unique. An argument could be made that tapply should be changed instead, but it is behaving as documented, so I didn't want to do that. I think you've worked around the problem (and I had seen Greg's analysis), thank you. BTW, the problem wasn't there in R 2.8.x, as we since had improved factor() {.. and btw, the same changes should happen to approx(), spline(), splinefun() ..} *However* why on earth can the results become *random*, i.e., differ from one call to the other, with identical data in the same R session? I currently guess that sometimes the operands (of the linear interpolation rational arithmetic) are kept in high-precision registers and sometimes not, I must say I am puzzled that this happens dynamically rather than determined by the exact compiler flags at (R's) build time I think it's because the y vector ends up shorter than x, after they've been assumed to be set to the same length. So at some point the function is looking at garbage in memory beyond the end of y, and that will vary from run to run. I didn't trace into the C code to check this, but that's what the symptoms look like. Duncan Murdoch ?? (and yes, this thread should have been on R-devel rather than R-help from the start ...) Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] approxfun-problems (yleft and yright ignored)
Duncan Murdoch murdoch.dun...@gmail.com on Sat, 11 Sep 2010 11:23:02 -0400 writes: On 11/09/2010 11:13 AM, Martin Maechler wrote: Duncan Murdoch murdoch.dun...@gmail.com on Sat, 11 Sep 2010 10:32:38 -0400 writes: On 11/09/2010 10:04 AM, Martin Maechler wrote: SW == Samuel Wuest wue...@tcd.ie on Thu, 26 Aug 2010 14:34:26 +0100 writes: SW Hi Greg, SW thanks for the suggestion: SW I have attached some small dataset that can be used to reproduce the SW odd behavior of the approxfun-function. SW If it gets stripped off my email, it can also be downloaded at: SW http://bioinf.gen.tcd.ie/approx.data.Rdata SW Strangely, the problem seems specific to the data structure in my SW expression set, when I use simulated data, everything worked fine. SW Here is some code that I run and resulted in the strange output that I SW have described in my initial post: ### load the data: a list called approx.data load(file=approx.data.Rdata) ### contains the slots x, y, input names(approx.data) SW [1] x y input ### with y ranging between 0 and 1 range(approx.data$y) SW [1] 0 1 ### compare ranges of x and input-x values (the latter is a small subset of 500 data points): range(approx.data$x) SW [1] 3.098444 7.268812 range(approx.data$input) SW [1] 3.329408 13.026700 ### generate the interpolation function (warning message benign) interp - approxfun(approx.data$x, approx.data$y, yleft=1, yright=0, rule=2) SW Warning message: SW In approxfun(approx.data$x, approx.data$y, yleft = 1, yright = 0, : SW collapsing to unique 'x' values ### apply to input-values y.out - sapply(approx.data$input, interp) ### still I find output values 1, even though yleft=1: range(y.out) SW [1] 0.00 7.207233 I get completely different (and correct) results, by the way the *same* you have in the bug report you've submitted (https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14377) and which does *not* show any bug: range(y.out) [1] 0.000 0.9816907 Of course, I do believe that you've seen the above problems, -- on 64-bit Mac ? as you report in sessionInfo() ? -- but I cannot reproduce them. And also, you seem yourself to be able to get different results for the same data... what are the circumstances? I think Greg Snow's analysis (linked from the bug report) is right. length(unique(x)) can be different than length(levels(as.factor(x))) (which is what tapply uses to determine the number of levels). I've fixed it by replacing y - as.vector(tapply(y,x,ties)) with y - as.vector(tapply(y,match(x,x),ties)) since match() uses the same rules as unique. An argument could be made that tapply should be changed instead, but it is behaving as documented, so I didn't want to do that. I think you've worked around the problem (and I had seen Greg's analysis), thank you. BTW, the problem wasn't there in R 2.8.x, as we since had improved factor() {.. and btw, the same changes should happen to approx(), spline(), splinefun() ..} *However* why on earth can the results become *random*, i.e., differ from one call to the other, with identical data in the same R session? I currently guess that sometimes the operands (of the linear interpolation rational arithmetic) are kept in high-precision registers and sometimes not, I must say I am puzzled that this happens dynamically rather than determined by the exact compiler flags at (R's) build time I think it's because the y vector ends up shorter than x, after they've been assumed to be set to the same length. So at some point the function is looking at garbage in memory beyond the end of y, and that will vary from run to run. I didn't trace into the C code to check this, but that's what the symptoms look like. aah, of course! (it seem I'm enjoying too much the warm late summer sun here at home in Zurich ..) Now, I'm happy it's the usual thing.. Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] approxfun-problems (yleft and yright ignored)
Hi Martin, indeed, as mentioned in the bug-report, the results are inconsistent, and each time I rerun, I get different results... Sometimes, the range is correct even on my machine, but mostly I get values 1 back: Here is another run: ### load the data: a list called approx.data load(file=approx.data.Rdata) ### contains the slots x, y, input names(approx.data) [1] x y input ### with y ranging between 0 and 1 ### generate the interpolation function (warning message benign) interp - approxfun(approx.data$x, approx.data$y, yleft=1, yright=0, rule=2) Warning message: In approxfun(approx.data$x, approx.data$y, yleft = 1, yright = 0, : collapsing to unique 'x' values ### apply to input-values y.out - interp(approx.data$input) ### still I find output values 1, even though yleft=1: range(y.out) [1] -1.360612e+81 2.151192e+249 This script was run on the same machine, same R-version ect. this demonstrates the issue again, and when running the script again before the bug-report, I had overlooked, that the range was indeed correct... I guess Greg Snow had suggested a fix for the bug correctly and the issue should be resolved as posted by Duncan Murdoch. Thanks a million!! Best, Sam On 11 September 2010 15:53, Martin Maechler maech...@stat.math.ethz.ch wrote: MM == Martin Maechler maech...@stat.math.ethz.ch on Sat, 11 Sep 2010 16:04:37 +0200 writes: SW == Samuel Wuest wue...@tcd.ie on Thu, 26 Aug 2010 14:34:26 +0100 writes: SW Hi Greg, SW thanks for the suggestion: SW I have attached some small dataset that can be used to reproduce the SW odd behavior of the approxfun-function. SW If it gets stripped off my email, it can also be downloaded at: SW http://bioinf.gen.tcd.ie/approx.data.Rdata SW Strangely, the problem seems specific to the data structure in my SW expression set, when I use simulated data, everything worked fine. SW Here is some code that I run and resulted in the strange output that I SW have described in my initial post: ### load the data: a list called approx.data load(file=approx.data.Rdata) ### contains the slots x, y, input names(approx.data) SW [1] x y input ### with y ranging between 0 and 1 range(approx.data$y) SW [1] 0 1 ### compare ranges of x and input-x values (the latter is a small subset of 500 data points): range(approx.data$x) SW [1] 3.098444 7.268812 range(approx.data$input) SW [1] 3.329408 13.026700 ### generate the interpolation function (warning message benign) interp - approxfun(approx.data$x, approx.data$y, yleft=1, yright=0, rule=2) SW Warning message: SW In approxfun(approx.data$x, approx.data$y, yleft = 1, yright = 0, : SW collapsing to unique 'x' values ### apply to input-values y.out - sapply(approx.data$input, interp) ### still I find output values 1, even though yleft=1: range(y.out) SW [1] 0.00 7.207233 MM I get completely different (and correct) results, MM by the way the *same* you have in the bug report you've MM submitted MM (https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14377) MM and which does *not* show any bug: range(y.out) MM [1] 0.000 0.9816907 MM Of course, I do believe that you've seen the above problems, MM -- on 64-bit Mac ? as you report in sessionInfo() ? -- MM but I cannot reproduce them. MM And also, you seem yourself to be able to get different results MM for the same data... what are the circumstances? I now see that you *did* mention the fact that you see *different* results when you *RE*run the same code on this data. The subject ( ...yleft and yright ignored) is misleading in any case. These are not at all ignored..., but indeed (as Duncan Murdoch has noted on the bug website), there *is* a bug, so you are principally right in reporting -- thank you! and I could also confirm that -- as you mentioned in your first post -- this bug does not appear when using R 2.8.1 (at least on my platform). Martin -- - Samuel Wuest Smurfit Institute of Genetics Trinity College Dublin Dublin 2, Ireland Phone: +353-1-896 2444 Web: http://www.tcd.ie/Genetics/wellmer-2/index.html Email: wue...@tcd.ie __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Solver in R
Use BBsolve in the BB package. It'll do darn near anything. Carl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Latex fonts in R graphics
Hi: This doesn't directly answer your question, but you may want to investigate the tikzDevice package. From its DESCRIPTION file: The TikZ device enables LaTeX-ready output from R graphics functions. This is done by producing code that can be understood by the TikZ graphics language. All text in a graphic output with the tikz() function will can be typeset by LaTeX and therefore will match whatever fonts are currently used in the document. This also means that LaTeX mathematics can be typeset directly into labels and annotations! Graphics produced this way can also be annotated with custom TikZ commands. HTH, Dennis On Sat, Sep 11, 2010 at 4:18 AM, KARAVASILIS GEORGE gkara...@ee.duth.grwrote: Hello, R users. I am trying to embed Computer modern fonts to an R plot and I get the following error. CM - Type1Font(CM, + c(paste(cm-lgc/fonts/afm/public/cm-lgc/, + c(fcmr8a.afm, fcmb8a.afm, fcmri8a.afm, fcmbi8a.afm), sep=), + ./cmsyase.afm)) pdf(cm.pdf, width=3, height=3, family=CM) plot(1:length(y), y, xlab=ss, ylab=expression(x[2])) ## for any vector y dev.off() null device 1 embedFonts(cm.pdf, outfile=cmembed.pdf, fontpaths=c(cm-lgc/fonts/type1/public/cm-lgc, .)) Error in embedFonts(cm.pdf, outfile = cmembed.pdf, fontpaths = c(cm-lgc/fonts/type1/public/cm-lgc, : status -1 in running command 'gswin32c.exe -dNOPAUSE -dBATCH -q -dAutoRotatePages=/None -sDEVICE=pdfwrite -sOutputFile=C:\DOCUME~1\user\LOCALS~1\Temp\RtmpccEtgV\Rembed28163716 -sFONTPATH=cm-lgc/fonts/type1/public/cm-lgc;. cm.pdf' In addition: Warning message: In system(cmd) : gswin32c.exe not found Operating system: Windows XP, SP2. cm-lgc has been unzipped in the working directory C:/Program Files/R/R-2.10.1 and the AFM, PFB files are also in same directory. Any help? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] xlab with text and expression
thanks a lot! -- View this message in context: http://r.789695.n4.nabble.com/xlab-with-text-and-expression-tp2535732p2535785.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scalable delimiters in plotmath
What do people use to show angle brackets in R graphics? Have I missed something obvious? Thanks, baptiste On 9 September 2010 17:57, baptiste auguie baptiste.aug...@googlemail.com wrote: Dear list, I read in ?plotmath that I can use bgroup to draw scalable delimiters such as [ ] and ( ). The same technique fails with however, and I cannot find a workaround, grid.text(expression(bgroup(,atop(x,y),))) Error in bgroup(, atop(x, y), ) : invalid group delimiter Regards, baptiste sessionInfo() R version 2.11.1 (2010-05-31) x86_64-apple-darwin9.8.0 locale: [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] TeachingDemos_2.7 loaded via a namespace (and not attached): [1] tools_2.11.1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Solver in R
You can also have a look at and try package nleqslv. Berend -- View this message in context: http://r.789695.n4.nabble.com/Solver-in-R-tp2535115p2535813.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Solver in R
Another idea. From your formulation it seems that r does not depend on t and Xt so you wouldn't need a solver. You could solve for r explicitly so r - R0/sum(Xt) /Berend -- View this message in context: http://r.789695.n4.nabble.com/Solver-in-R-tp2535115p2535815.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [Q] How to extract cross validation results from e1071's svm model
Dear all, Is it possible to extract cross-validation results from e1071's svm model? For example, the following R code shows the result from the 10 fold cross-validation. model = svm(spam ~ ., data = spam, cross = 10) summary(model) But, I could not figure out how to get to the accuracy values from the cross-validation. I looked at the svm method, but did not find any return values. Any comment would be highly appreciated. Thanks in advance. Young-Jin Lee __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] confidence bands for a quasipoisson glm
Dear all, I have a quasipoisson glm for which I need confidence bands in a graphic: gm6 - glm(num_leaves ~ b_dist_min_new, family = quasipoisson, data = beva) summary(gm6) library('VIM') b_dist_min_new - as.numeric(prepare(beva$dist_min, scaling=classical, transformation=logarithm)). My first steps for the solution are following: range(b_dist_min_new) x - seq(-1.496, 1.839, by=0.01) newdat - data.frame(b_dist_min_new=x) y - predict(gm6, newdata=newdat, type=response) plot(x,y, type=l, ylim=c(0,15), lty=2, xlab=Distance [scaled log.], ylab=Number of used plant, las=1) ilogit-function(x) exp(x)/(1 + exp(x)) logit -function(x) log(x/(1 - x)) newdat$logitpred - predict(gm6, newdata=newdat, type=link) newdat$sepred - predict(gm6, newdata=newdat, type=link, se.fit=TRUE)$se.fit newdat$logitlower - newdat$logitpred-1.96 * newdat$sepred newdat$logitupper - newdat$logitpred+1.96 * newdat$sepred newdat$upper - ilogit(newdat$logitupper) newdat$lower - ilogit(newdat$logitlower) lines(x, newdat$lower, lty=3) lines(x, newdat$upper, lty=3). In this way I could find a positive correlation. But my created confidence bands on the graph don't touch my regression line. Could it be a technical problem or is it a mistake in the calculation? I am new here and I hope you can help to solve my problem. I could not find any answers for quasipoisson glm on internet. Best regards Maik -- GMX DSL SOMMER-SPECIAL: Surf Phone Flat 16.000 für nur 19,99 Euro/mtl.!* __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Generating multinomial distribution and plotting
I have had plenty of succes generating one dimensional variables and plotting them, but what do i do for more (specifically 2) dimensional multinomial variables? I figure i have to create a vector consisting of two 1 dim normallly distributed variables, that way i can also control the correlation. But how do i do this :) ? Many thanks -- View this message in context: http://r.789695.n4.nabble.com/Generating-multinomial-distribution-and-plotting-tp2535895p2535895.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] confidence bands for a quasipoisson glm
On Sep 11, 2010, at 3:15 PM, Maik Rehnus wrote: Dear all, I have a quasipoisson glm for which I need confidence bands in a graphic: gm6 - glm(num_leaves ~ b_dist_min_new, family = quasipoisson, data = beva) summary(gm6) library('VIM') b_dist_min_new - as.numeric(prepare(beva$dist_min, scaling=classical, transformation=logarithm)). My first steps for the solution are following: range(b_dist_min_new) x - seq(-1.496, 1.839, by=0.01) newdat - data.frame(b_dist_min_new=x) y - predict(gm6, newdata=newdat, type=response) plot(x,y, type=l, ylim=c(0,15), lty=2, xlab=Distance [scaled log.], ylab=Number of used plant, las=1) ilogit-function(x) exp(x)/(1 + exp(x)) logit -function(x) log(x/(1 - x)) newdat$logitpred - predict(gm6, newdata=newdat, type=link) I'm puzzled. You specified that model as quasipoisson and are now treating it as if it were logistic? The link is going to be log(), nicht wahr? newdat$sepred - predict(gm6, newdata=newdat, type=link, se.fit=TRUE)$se.fit newdat$logitlower - newdat$logitpred-1.96 * newdat$sepred newdat$logitupper - newdat$logitpred+1.96 * newdat$sepred I'm not familiar with ilogit (sounds very useful assuming it to be an inverse logit), but if one were taking a first stab at an inverse function for quasipoisson wouldn't that be exp()? newdat$upper - ilogit(newdat$logitupper) newdat$lower - ilogit(newdat$logitlower) lines(x, newdat$lower, lty=3) lines(x, newdat$upper, lty=3). In this way I could find a positive correlation. But my created confidence bands on the graph don't touch my regression line. Could it be a technical problem or is it a mistake in the calculation? I am new here and I hope you can help to solve my problem. I could not find any answers for quasipoisson glm on internet. Best regards Maik David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Setting scales for ggplot2 with facets
Faceting in ggplot2 seems to permit different scales for different facets, but I fail to see how one could control ylim and xlim ranges for each facet separately. For instance, I would like to set the ylim = c(0,10) for facet A and ylim = c(42,102) for facet B. Since the data is out of these ranges, setting facet_grid(factor ~ ., scales = free_y) does not achieve the goal . Is there a decent way to achieve this or not? or I have to drop data points outside y-ranges as a quick hack? Swen Laur __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Setting scales for ggplot2 with facets
Swen, facet_grid forces the scale for plots along an axis to be shared. Try facet_wrap instead. Jonathan On Sat, Sep 11, 2010 at 2:21 PM, Sven Laur s...@math.ut.ee wrote: Faceting in ggplot2 seems to permit different scales for different facets, but I fail to see how one could control ylim and xlim ranges for each facet separately. For instance, I would like to set the ylim = c(0,10) for facet A and ylim = c(42,102) for facet B. Since the data is out of these ranges, setting facet_grid(factor ~ ., scales = free_y) does not achieve the goal . Is there a decent way to achieve this or not? or I have to drop data points outside y-ranges as a quick hack? Swen Laur __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Generating multinomial distribution and plotting
package: {mnormt} -- View this message in context: http://r.789695.n4.nabble.com/Generating-multinomial-distribution-and-plotting-tp2535895p2535934.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Setting scales for ggplot2 with facets
This does not solve the problem, as I still do not know how to control the y-range for individual facets. Data contains some outliers which make the y-range too wide for me and I would explicitly set the ylim = c(0,10) for facet A and ylim = c(42, 102) for facet B. How should I do it? On 11 Sep 2010, at 23:37, Jonathan Christensen wrote: Swen, facet_grid forces the scale for plots along an axis to be shared. Try facet_wrap instead. Jonathan On Sat, Sep 11, 2010 at 2:21 PM, Sven Laur s...@math.ut.ee wrote: Faceting in ggplot2 seems to permit different scales for different facets, but I fail to see how one could control ylim and xlim ranges for each facet separately. For instance, I would like to set the ylim = c(0,10) for facet A and ylim = c(42,102) for facet B. Since the data is out of these ranges, setting facet_grid(factor ~ ., scales = free_y) does not achieve the goal . Is there a decent way to achieve this or not? or I have to drop data points outside y-ranges as a quick hack? Swen Laur __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Swen Laur [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] confidence bands for a quasipoisson glm
Is this something you want to have (based on a simulated dataset)? counts - c(18,17,15,20,10,20,25,13,12) #risk - round(rexp(9,0.5),3) risk- c(2.242, 0.113, 1.480, 0.913, 5.795, 0.170, 0.846, 5.240, 0.648) gm - glm(counts ~ risk, family=quasipoisson) summary(gm) new.risk=seq(min(risk), max(risk),0.1) new.risk y - predict.glm(gm, newdata=data.frame(risk=new.risk), se.fit=TRUE, type=response) upper=y$fit+1.96*y$se.fit lower=y$fit-1.96*y$se.fit plot(new.risk,y$fit, type=l, col=4, lty=1, lwd=2) lines(new.risk, upper, type=l, col=2, lty=2, lwd=2) lines(new.risk, lower, type=l, col=2, lty=2, lwd=2) -- View this message in context: http://r.789695.n4.nabble.com/confidence-bands-for-a-quasipoisson-glm-tp2535883p2535952.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sorting a (homogenous) list of objects, based on a a field of the objects
Him I have a list of S4 objects. Each object has a field called name, and what I'd like to do is to sort the list based on the value of name. Currently I'm using the following code tmp - unlist(lapply(fps, function(x) as.integer(x...@name))) tmp - order(tmp, decreasing=FALSE) fps - fps[ tmp ] this seems a little klunky and I was wondering if there was another way to do this (by analogy with comparator functions in Java) Thanks, -- Rajarshi Guha NIH Chemical Genomics Center __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scalable delimiters in plotmath
Hi Baptiste, You need to use the symbol(\nnn) concept, where nnn denotes the octal symbol number. For it's 074 and for it's 076. This little test seemed to work: plot(1, 1, main = expression(symbol(\074)~'x, y'~symbol(\076))) HTH, Dennis On Sat, Sep 11, 2010 at 10:01 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: What do people use to show angle brackets in R graphics? Have I missed something obvious? Thanks, baptiste On 9 September 2010 17:57, baptiste auguie baptiste.aug...@googlemail.com wrote: Dear list, I read in ?plotmath that I can use bgroup to draw scalable delimiters such as [ ] and ( ). The same technique fails with however, and I cannot find a workaround, grid.text(expression(bgroup(,atop(x,y),))) Error in bgroup(, atop(x, y), ) : invalid group delimiter Regards, baptiste sessionInfo() R version 2.11.1 (2010-05-31) x86_64-apple-darwin9.8.0 locale: [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] TeachingDemos_2.7 loaded via a namespace (and not attached): [1] tools_2.11.1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Generating multinomial distribution and plotting
Hi: Do you mean multinomial or multivariate normal? If the latter, then in addition to the previous response, there is package mvtnorm and a function mvrnorm() in the MASS package to generate correlated multivariate normal samples. HTH, Dennis On Sat, Sep 11, 2010 at 12:52 PM, thedreamshaper thedreamsha...@gmail.comwrote: I have had plenty of succes generating one dimensional variables and plotting them, but what do i do for more (specifically 2) dimensional multinomial variables? I figure i have to create a vector consisting of two 1 dim normallly distributed variables, that way i can also control the correlation. But how do i do this :) ? Many thanks -- View this message in context: http://r.789695.n4.nabble.com/Generating-multinomial-distribution-and-plotting-tp2535895p2535895.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Setting scales for ggplot2 with facets
Use scales = 'free' in facet_wrap() to vary both scales across panels. From Ch. 7 of the ggplot2 book, the options are (in either type of faceting) scales = 'fixed' = both x and y scales are fixed in all plots scales = 'free_x'= fix y scale, vary x scale across panels scales = 'free_y'= fix x scale, vary y scale scales = 'free'= vary both HTH, Dennis On Sat, Sep 11, 2010 at 2:17 PM, Sven Laur s...@math.ut.ee wrote: This does not solve the problem, as I still do not know how to control the y-range for individual facets. Data contains some outliers which make the y-range too wide for me and I would explicitly set the ylim = c(0,10) for facet A and ylim = c(42, 102) for facet B. How should I do it? On 11 Sep 2010, at 23:37, Jonathan Christensen wrote: Swen, facet_grid forces the scale for plots along an axis to be shared. Try facet_wrap instead. Jonathan On Sat, Sep 11, 2010 at 2:21 PM, Sven Laur s...@math.ut.ee wrote: Faceting in ggplot2 seems to permit different scales for different facets, but I fail to see how one could control ylim and xlim ranges for each facet separately. For instance, I would like to set the ylim = c(0,10) for facet A and ylim = c(42,102) for facet B. Since the data is out of these ranges, setting facet_grid(factor ~ ., scales = free_y) does not achieve the goal . Is there a decent way to achieve this or not? or I have to drop data points outside y-ranges as a quick hack? Swen Laur __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Swen Laur [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] mapping array
Hi, Suppose I have array A with 100 elements all filled in with N/A. Array B has 25 elements with actual values. Lastly, I have array C that provides a map of where to put the elements from array A into array B. Thus C would say put element 1 from B into element 3 from array A. I realize I can do this with a for loop. However, because I'm doing a random forest with this, I'd like to avoid a for loop because it would take significantly more time. Thanks, Greg __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Supplying function inputs interactively
Dear all, I am looking for some procedure to send inputs to a function interactively. Here is an example: fn1 - function(x = 10) { y - 0 # ask user whether he wants to put some other value for y # R will show 2 options: 1. y = 2 # 2. y = 3 # user will choose either options 1 or 2 # once user is done, function will over-write the existing value of y, with say, option 2. Therefore current value of y is 2. Then R will continue calculation return(x*y) } Here obviously I can put y as the 2nd input of fn1(), however I want to do so interactively. Can friends here direct me how to do that? Thanks, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Supplying function inputs interactively
Have you tried scan()?: y=scan() 1: 2 2: Read 1 item y [1] 2 -- View this message in context: http://r.789695.n4.nabble.com/Supplying-function-inputs-interactively-tp2536003p2536004.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Supplying function inputs interactively
On Sat, Sep 11, 2010 at 7:17 PM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Dear all, I am looking for some procedure to send inputs to a function interactively. Here is an example: fn1 - function(x = 10) { y - 0 # ask user whether he wants to put some other value for y # R will show 2 options: 1. y = 2 # 2. y = 3 # user will choose either options 1 or 2 # once user is done, function will over-write the existing value of y, with say, option 2. Therefore current value of y is 2. Then R will continue calculation return(x*y) } Try this: ysquared - function(y) { if (missing(y)) y - as.numeric(readline(Enter y: )) y*y } ysquared() -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Supplying function inputs interactively
Is this what you would expect to have. Definitely you can make this function more elegant: fn1 - function(x = 10) { cat(Please type the option number to get your Y value:\n\n) cat( 1. Y = 1.\n 2. Y = 2.\n 3. Use the default y.\n 4. Choose my own value for y.\n\n) opt=scan() if (opt==3) y -0 else if (opt==4) { cat(Please type your Y value:\n\n) y=scan() } else y = opt return(x*y) } -- View this message in context: http://r.789695.n4.nabble.com/Supplying-function-inputs-interactively-tp2536003p2536012.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Generating multinomial distribution and plotting
Oh,You actually want a mixture of two different normal random variables. -- View this message in context: http://r.789695.n4.nabble.com/Generating-multinomial-distribution-and-plotting-tp2535895p2536026.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] mapping array
Hi Greg, I am sketchy on a few details of C, but does something like this work for you? I just created C1 (renamed because C() is a function) with two columns the first corresponding to A and the second to B. Then I just used the first column to select elements of A and the second to select elements of B. As a side note, this would work even if the same element of B replaced multiple elements in A. A - array(NA, 100) B - array(sample(1:10, 25, replace = TRUE), 25) C1 - array(c(sample(1:100, 25, replace = FALSE), sample(1:25, 25, replace = FALSE)), c(25, 2)) C1 # look at C1 # Now use the 1st column to select elements of A # and the 2nd to select elements of B to replace A A[C1[,1]] - B[C1[,2]] Cheers, Josh On Sat, Sep 11, 2010 at 3:54 PM, Gregory Ryslik rsa...@comcast.net wrote: Hi, Suppose I have array A with 100 elements all filled in with N/A. Array B has 25 elements with actual values. Lastly, I have array C that provides a map of where to put the elements from array A into array B. Thus C would say put element 1 from B into element 3 from array A. I realize I can do this with a for loop. However, because I'm doing a random forest with this, I'd like to avoid a for loop because it would take significantly more time. Thanks, Greg __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] mapping array
Is this the kind of thing you are talking about? ### 8 cut here 8 ### A - rep(NA, 100) B - sort(runif(25)) C - sort(sample(1:100, 25)) A[C] - B B C A ### 8 cut here 8 ### (The sorting is not necessary. It's only there to make checking what happened easier.) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gregory Ryslik Sent: Sunday, 12 September 2010 8:54 AM To: r-help@r-project.org Subject: [R] mapping array Hi, Suppose I have array A with 100 elements all filled in with N/A. Array B has 25 elements with actual values. Lastly, I have array C that provides a map of where to put the elements from array A into array B. Thus C would say put element 1 from B into element 3 from array A. I realize I can do this with a for loop. However, because I'm doing a random forest with this, I'd like to avoid a for loop because it would take significantly more time. Thanks, Greg __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scalable delimiters in plotmath
On 2010-09-11 16:14, Dennis Murphy wrote: Hi Baptiste, You need to use the symbol(\nnn) concept, where nnn denotes the octal symbol number. For it's 074 and for it's 076. This little test seemed to work: plot(1, 1, main = expression(symbol(\074)~'x, y'~symbol(\076))) HTH, Dennis It's a matter of taste, but I would use \341 and \361. However, these are still not scalable, AFAICS. -Peter Ehlers On Sat, Sep 11, 2010 at 10:01 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: What do people use to show angle bracketsin R graphics? Have I missed something obvious? Thanks, baptiste On 9 September 2010 17:57, baptiste auguie baptiste.aug...@googlemail.com wrote: Dear list, I read in ?plotmath that I can use bgroup to draw scalable delimiters such as [ ] and ( ). The same technique fails withhowever, and I cannot find a workaround, grid.text(expression(bgroup(,atop(x,y),))) Error in bgroup(, atop(x, y),) : invalid group delimiter Regards, baptiste sessionInfo() R version 2.11.1 (2010-05-31) x86_64-apple-darwin9.8.0 locale: [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] TeachingDemos_2.7 loaded via a namespace (and not attached): [1] tools_2.11.1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R-equivalent Stata command: poisson or quasipoisson?
Hello R-help, According to a research article that covers the topic I'm analyzing, in Stata, a Poisson pseudo-maximum-likelihood (PPML) estimation can be obtained with the command poisson depvar_ij ln(indepvar1_ij) ln(indepvar2_ij) ... ln(indepvarN_ij), robust I looked up Stata help for the command, to understand syntax and such: www.stata.com/help.cgi?poisson Which simply says that the command fits a Poisson regression of depvar on indepvars. However, in my google-searching, I noticed that pseudo- maximum-likelihood estimation is sometimes called 'quasi-maximum,' and that R has a quasipoisson family that seems to allow for overdispersion. So, am I missing something, or should I specify quasipoisson when implementing this estimation? Thanks a lot! Cheers, Wil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scalable delimiters in plotmath
On Sep 11, 2010, at 9:00 PM, Peter Ehlers wrote: On 2010-09-11 16:14, Dennis Murphy wrote: Hi Baptiste, You need to use the symbol(\nnn) concept, where nnn denotes the octal symbol number. For it's 074 and for it's 076. This little test seemed to work: plot(1, 1, main = expression(symbol(\074)~'x, y'~symbol(\076))) HTH, Dennis It's a matter of taste, but I would use \341 and \361. However, these are still not scalable, AFAICS. Not exactly scalable angles, but you can fake it: plot(1, 1, main = expression(symbol(\341)~scriptstyle( atop(x,y) )~symbol(\361)), cex.main=3) scriptstyle shrinks the inner atop() material, and since I tested on a Mac it should work for Baptiste. -- David. -Peter Ehlers On Sat, Sep 11, 2010 at 10:01 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: What do people use to show angle bracketsin R graphics? Have I missed something obvious? Thanks, baptiste On 9 September 2010 17:57, baptiste auguie baptiste.aug...@googlemail.com wrote: Dear list, I read in ?plotmath that I can use bgroup to draw scalable delimiters such as [ ] and ( ). The same technique fails withhowever, and I cannot find a workaround, grid.text(expression(bgroup(,atop(x,y),))) Error in bgroup(, atop(x, y),) : invalid group delimiter Regards, baptiste sessionInfo() R version 2.11.1 (2010-05-31) x86_64-apple-darwin9.8.0 David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Generating multinomial distribution and plotting
Hi, I actually largely solved the problem, i am using this code: var1 - rnorm(5000,0,5) var2 - 0.90*var1+0.10*rnorm(5000,0,10) plot(var1,var2) Its somewhat simplistic to say the least but it works more or less, i will definantly look into your suggestion though! Thanks Thor Denmark On Sun, Sep 12, 2010 at 12:23 AM, Dennis Murphy [via R] ml-node+2535974-1500011135-160...@n4.nabble.comml-node%2b2535974-1500011135-160...@n4.nabble.com wrote: Hi: Do you mean multinomial or multivariate normal? If the latter, then in addition to the previous response, there is package mvtnorm and a function mvrnorm() in the MASS package to generate correlated multivariate normal samples. HTH, Dennis On Sat, Sep 11, 2010 at 12:52 PM, thedreamshaper [hidden email] http://user/SendEmail.jtp?type=nodenode=2535974i=0wrote: I have had plenty of succes generating one dimensional variables and plotting them, but what do i do for more (specifically 2) dimensional multinomial variables? I figure i have to create a vector consisting of two 1 dim normallly distributed variables, that way i can also control the correlation. But how do i do this :) ? Many thanks -- View this message in context: http://r.789695.n4.nabble.com/Generating-multinomial-distribution-and-plotting-tp2535895p2535895.htmlhttp://r.789695.n4.nabble.com/Generating-multinomial-distribution-and-plotting-tp2535895p2535895.html?by-user=t Sent from the R help mailing list archive at Nabble.com. __ [hidden email] http://user/SendEmail.jtp?type=nodenode=2535974i=1mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ [hidden email] http://user/SendEmail.jtp?type=nodenode=2535974i=2mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View message @ http://r.789695.n4.nabble.com/Generating-multinomial-distribution-and-plotting-tp2535895p2535974.html To unsubscribe from Generating multinomial distribution and plotting, click herehttp://r.789695.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2535895code=dGhlZHJlYW1zaGFwZXJAZ21haWwuY29tfDI1MzU4OTV8LTEzOTQ5MDU4NA==. -- - Please note that this message may contain confidential information. If you are not the intended recipient you are hereby notified that any dissemination, copying, or distribution of this message or files associated with this message is strictly prohibited. If you have recieved this message in error, please notify me immediately. -- View this message in context: http://r.789695.n4.nabble.com/Generating-multinomial-distribution-and-plotting-tp2535895p2536011.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R-equivalent Stata command: poisson or quasipoisson?
In R, the glm families poisson and quasipoisson will give you the same estimates. Their standard errors will (usually) be different, though, and family = quasipoisson does not give you an AIC (since it does not maximise a true likelihood; it uses quasi-likelihood estimation). I hope you are not asking this list for help with Stata. We've never heard of it. It looks to me, though, that what you are doing below is fitting a robust poisson glm. If so, it is something different again. There is a package 'robust' which has a glmRob() fitting function in it that may do something similar, but there is so much tweaking allowed with robust fits the chance of getting the same result as with some other system (or even with R if you do it again, mostly) is effectively zero. Tip: use R and forget the others. It makes life so much easier all round. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Wil M Contreras Arbaje Sent: Sunday, 12 September 2010 11:27 AM To: r-help@r-project.org Subject: [R] R-equivalent Stata command: poisson or quasipoisson? Hello R-help, According to a research article that covers the topic I'm analyzing, in Stata, a Poisson pseudo-maximum-likelihood (PPML) estimation can be obtained with the command poisson depvar_ij ln(indepvar1_ij) ln(indepvar2_ij) ... ln(indepvarN_ij), robust I looked up Stata help for the command, to understand syntax and such: www.stata.com/help.cgi?poisson Which simply says that the command fits a Poisson regression of depvar on indepvars. However, in my google-searching, I noticed that pseudo- maximum-likelihood estimation is sometimes called 'quasi-maximum,' and that R has a quasipoisson family that seems to allow for overdispersion. So, am I missing something, or should I specify quasipoisson when implementing this estimation? Thanks a lot! Cheers, Wil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.