Re: [R] R report generator (for Word)?
Dear Michael, On Sun, Jan 1, 2012 at 10:50 AM, Michael comtech@gmail.com wrote: Happy New Year all! [snip] PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Nobody's yet mentioned that the latest version of Emacs Org mode (http://orgmode.org/) ships with an ODT (OpenDocument Text) exporter. This means that a person can now use the same single plain text file to integrate R code (and/or 30+ other languages) to process: - HTML: C-c C-e h- LaTeX: C-c C-e l- PDF: C-c C-e p (via pdflatex)- ODT: C-c C-e o- ...etc. You get syntax highlighting, integrated math formulae, code tangling,... there's even an elementary table editor for simple spreadsheet operations. And again, all exported formats originate from the same plain text file. MS-Word can definitely read HTML, and when I last checked (long ago) there existed plugins for MS_Word to read .odt. Of course, LibreOffice can convert ODT (and HTML) to MS-Word if necessary. GoogleDocs does an OK job converting back and forth, too, and if this option is available to you there are some pretty cool Google collaborative tools. On the flipside, Emacs in general is a tough pill to swallow, and that's an understatement. Two parting thoughts:1) Org mode is similar to, but not identical with, Sweave.2) Org mode originated as an organization/outlining tool, so it has all sorts of tricks for Getting Things Done, such as TODO lists, agendas, capturing-archiving, calendar integration, time tracking,... These could possibly address some of the other issues you mentioned. Good luck, and Happy New Year.Jay * G. Jay Kerns, Ph.D. Mathematics and Statistics Youngstown State University http://people.ysu.edu/~gkerns/ __ 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] Rcmdr Plugin error
Dear Erin, On Fri, Jun 17, 2011 at 1:45 AM, Erin Hodgess erinm.hodg...@gmail.com wrote: Dear R People: (particularly those who have build Rcmdr Plugin packages): I'm building a new Plugin and keep getting the following error: Error in if (is.null(where) || where = n) rbind(object1, object2) else if (where : missing value where TRUE/FALSE needed Error in library(RcmdrPlugin Have any of you run into this, please? I feel like I've seen it before but can't find the solution. Thanks, Erin If I remember correctly, the same thing happened to me when my Plugin removed a menu which was used (that is, added to) by some other Plugin (in particular, RcmdrPlugin.IPSUR deleted a menu to which RcmdrPlugin.HH added a submenu.) The solution in my case was don't do that. Can't really tell whether that problem has anything to do with yours, but anyway, I hope this helps. Jay *** G. Jay Kerns, Ph.D. Youngstown State University http://people.ysu.edu/~gkerns/ __ 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 calculate KMO?
Dear Thibault, On Tue, Apr 12, 2011 at 5:06 PM, Thibault Grava tybo.tout.s...@gmail.com wrote: Hello Jay, I know that an old post but I really need to calculate KMO for my data and this is the only thread I found on the subject. I'm a very newby to R so sorry for the odd questions. It looks like in your reply that you use kmo as a function and you apply it to your data D... I tried that on my data but it says Error: couldn't find function kmo. I installed and loaded the package corpcor but it still doesn't work... did I get it wrong? Also i would like to use the complete function (see http://tolstoy.newcastle.edu.au/R/help/05/12/17235.html), but I don't really understand how to use it... where should I enter the data directory?? I thank you a lot for your help. Thibault Please forgive me, but I'm not sure I really understand what your question is. My advice would be to go here: https://stat.ethz.ch/pipermail/r-help/2007-August/138049.html and copy-paste the function listed there - it looks like kmo = function( data ){ ...bunch of stuff here... } # end of kmo() into an R session, for instance, on the Windows RGui. If you like, you can test that everything works with the example shown right below that (just copy-paste, again). You don't need any corpcor package, all you need is MASS which should have shipped with the R you are using. You also don't need a data directory. What you need is a matrix (called X in my message) with the data stored in the correct order/positions. See the Trujillo-Ortiz et al. discussion (linked in my message) for lots more detail about what the matrix means and how to set it up. If you are having trouble setting up a data matrix in general then I recommend the R documentation which you can find under the Help menu. I just double-checked and both the function and example still work like a charm, almost 4 years later. (?!) Good luck, and I hope this helps. Jay __ G. Jay Kerns, Ph.D. Youngstown State University http://people.ysu.edu/~gkerns/ __ 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] A question to get all possible combinations
Dear Ron, On Wed, Dec 22, 2010 at 1:19 PM, Ron Michael ron_michae...@yahoo.com wrote: Let say, I have a matrix with 8 rows and 6 columns: df1 - matrix(NA, 8, 4) df1 [,1] [,2] [,3] [,4] [1,] NA NA NA NA [2,] NA NA NA NA [3,] NA NA NA NA [4,] NA NA NA NA [5,] NA NA NA NA [6,] NA NA NA NA [7,] NA NA NA NA [8,] NA NA NA NA Now I want to get **all possible** ways to fetch 6 cells at a time. Is there any function to do that? A matrix is just a vector, so each possible sample of size 6 from df1 corresponds to a sample of size 6 from the vector 1:32. There are many, many ways to get all of those (there are choose(32,6) such samples). The way I do it is library(prob) urnsamples(1:32, size = 6) and you can find lots of other, faster ways. If you store all of those in a data frame A, say, then you can get all possible samples from df1 with something like apply(A, 2, function(x) df1[x])) The good news is that the result will also be a matrix. Each row will be a possible sample of size 6 from df1. Hope this helps, Jay P.S. Note that urnsamples by default is replace = FALSE, ordered = FALSE, which is how I got away with the short command above. __ G. Jay Kerns, Ph.D. Youngstown State University http://people.ysu.edu/~gkerns/ __ 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 generate multivariate uniform distribution random
Dear Michael, On Sat, Nov 6, 2010 at 7:27 PM, michael tufemich...@gmail.com wrote: Ted, Thanks for your help, it is right on the money! for your comments: 1. Yes I mean 100 by 2, each variable x1, x2 is 100 by 1. 2. The correlation is the only free parameter. Michael I like Ted's solution. If all you are looking for is unif(0,1), you could use the Probability Integral Transform; something like this: set.seed(1) library(MASS) S - matrix(c(1, 0.9, 0.9, 1), nrow = 2) X - mvrnorm(100, mu = c(0,0), Sigma = S) Y - pnorm(X) var(Y) cor(Y) You could also use copulas, but those depend on contributed packages (and you can read more about them on the CRAN Task View for probability distributions). Hope this helps, Jay __ G. Jay Kerns, Ph.D. Youngstown State University http://people.ysu.edu/~gkerns/ __ 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 generate multivariate uniform distribution random
On Sat, Nov 6, 2010 at 8:22 PM, michael tufemich...@gmail.com wrote: Jay, Yes I'm looking for unif(0,1) and your method works just fine. I suppose your method should work for dimensions greater than 2, am I right? Michael Yes, but it gets that much more tricky to specify the covariance matrix. Two ways around this are to suppose that Sigma has a simplified correlation structure, or again, to use copulas. Jay __ 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] Is there a regression surface demo?
Dear Josh, On Mon, Oct 11, 2010 at 3:15 PM, Joshua Wiley jwiley.ps...@gmail.com wrote: Hi All, Does anyone know of a function to plot a regression surface for two predictors? RSiteSearch()s and findFn()s have not turned up what I was looking for. I was thinking something along the lines of: http://mallit.fr.umn.edu/fr5218/reg_refresh/images/fig9.gif I like the rgl package because showing it from different angles is nice for demonstrations. I started to write my own, but it has some issues (non functioning code start below), and I figured before I tried to work out the kinks, I would ask for the list's feedback. Any comments or suggestions (about functions or preferred idioms for what I tried below, or...) are greatly appreciated. Josh [snip] I haven't tried to debug your code, but wanted to mention that the Rcmdr:::scatter3d function does 3-d scatterplots (with the rgl package) and adds a regression surface, one of 4 or 5 different types. If nothing else, it might be a good place to start for making your own. A person can play around with the different types in the Rcmdr under the Graphs menu. Or, from the command line: library(Rcmdr) with(rock, scatter3d(area, peri, shape)) I hope that this helps, Jay __ 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] same random numbers in different sessions
Dear Liviu, On Sat, Oct 9, 2010 at 5:14 PM, Liviu Andronic landronim...@gmail.com wrote: Dear all I'm using Xubuntu Lucid and I keep getting the same random numbers whenever I start a new session of R. For example, I keep getting sample(1:1000, 1) [1] 87 or rnorm(1:10) [1] -1.3618103 0.4241701 1.0720076 0.2208145 -0.5375314 -0.4846588 [7] 0.7576768 0.6527407 -0.6868786 0.8718527 I expected that some set.seed() instruction woudl be present in a config file in /usr/lib/R/etc/ but after grepping the only reference came out in Rprofile.site and it was commented out: # set.seed(1234) What else could be causing this? Regards Liviu sessionInfo() R version 2.11.1 (2010-05-31) x86_64-pc-linux-gnu locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] fortunes_1.4-0 sos_1.3-0 brew_1.0-3 IPSUR_1.1 I notice that you have the IPSUR package loaded; you know, just a shot in the dark here, but did you try not loading it? I ask because the vignette is built by making a special choice for set.seed, and the workspace that ships with the package might be interacting in an unexpected way. Please let me know if IPSUR is the culprit. Regards, Jay __ 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-help
Dear Lemarian, I was going to reply to say this is how I would do (almost) the same thing with the prob package: library(prob) S - rolldie(2, makespace = TRUE) tmp - sim(S, ntrials = 1) with(tmp, mean(X1 == X2)) but then it occurred to me that Greg's dice was much faster than sim (plus that graph of the die faces is really cool!) so I was just going to let it go. But then again it occurred to me that simulation isn't needed for the problem at all: prob(S, X1 == X2) But finally as a reality-check it occurred to me that for a problem like this using R is like shooting a squirrel with a ballistic missile. Not that there's anything wrong with that; I don't like squirrels. Cheers, Jay P.S. Just kidding. On Tue, Oct 5, 2010 at 12:06 PM, Greg Snow greg.s...@imail.org wrote: I would do it like this: library(TeachingDemos) tmp - dice(1, 2) with(tmp, c(sum(Red==Green),mean(Red==Green)) ) plot(head(tmp,28)) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Lemarian WallaceIII Sent: Monday, October 04, 2010 10:14 PM To: r-help@r-project.org Subject: [R] R-help Im trying to simulate the rolling of a pair of dice this is my function: #function to simulate tosses of a pair of dice #from the simulation, the program returns the empirical probability of #observing a double count - 0 for(j in 1:sim){#begin loop die1 - sample(1:6,1) print(die1) die2 - sample(1:6,1) print(die2) count - ifelse(die1 == die2, count + 1, count) }#end loop emprob - count/sim return(count,emprob) } #end program these are the errors that keep coming up: Error in 1:sim : 'sim' is missing How do I correct this? [[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. -- *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX VoIP: gjke...@ekiga.net E-mail: gke...@ysu.edu http://people.ysu.edu/~gkerns/ __ 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] choose.dir() gone?
Dear Joh, On Wed, Sep 8, 2010 at 3:18 AM, Johannes Graumann johannes_graum...@web.de wrote: OK. Just checked and choose.file/choose.dir exists in the windows version - apparently not in the linux one ... does anybody have a nice platform-agnostic solution for this? Thanks, Joh [snip] Have a look at tk_choose.files in the tcltk package. library(tcltk) ?tk_choose.files Good luck, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX VoIP: gjke...@ekiga.net E-mail: gke...@ysu.edu http://people.ysu.edu/~gkerns/ __ 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-pkgs] IPSUR-1.0 is on CRAN, plus update to RcmdrPlugin.IPSUR
IPSUR-1.0 is making its way through CRAN. It is a snapshot of the development version of the following textbook: Title: Introduction to Probability and Statistics using R, First Edition ISBN: 978-0-557-24979-4 Publisher: me The book is targeted for an undergraduate course in probability and statistics. The prerequisites are a couple semesters of calculus and a little bit of linear algebra. I have used various drafts of this document to supplement my lectures for over four years. IPSUR is FREE, in the GNU sense of the word. A pdf copy (plus the LaTeX source) is on the R-Forge Project Page: http://ipsur.r-forge.r-project.org/ Alternatively, a person can do the following at the command prompt: install.packages(IPSUR) library(IPSUR) read(IPSUR) There are still many important topics, examples, and (especially) exercises missing. I will add them as time and two toddlers permit. If you would like to preview the daily-built, bleeding-edge latest version you can get it with install.packages(IPSUR, repos=http://R-Forge.R-project.org;) Please route IPSUR-specific emails to the respective R-Forge mailing lists: Questions or problems: ipsur-h...@lists.r-forge.r-project.org Mistakes, suggestions: ipsur-de...@lists.r-forge.r-project.org RcmdrPlugin.IPSUR is a plugin for the R Commander to accompany IPSUR. The update to version 0.1-7 is an important one, because it squashes a long-standing incompatibility problem with other plugins. The naming scheme for menus is also updated to be consistent with the other plugins in particular, and naming conventions in general. Cheers, Jay P.S. If you are thinking to print parts of IPSUR yourself then I recommend the publisher-quality PDF linked from the Downloads section of the R-Forge Project Page. G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA http://people.ysu.edu/~gkerns/ ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-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] Introductory statistics and introduction to R
Dear Marsh, On Tue, Jul 27, 2010 at 10:46 AM, Marsh Feldman marshfeld...@cox.net wrote: Hi, I have a bright, diligent second-year graduate student who wants to learn statistics and R and will, in effect, be taking a tutorial from me on these subjects. (If you've seen some of my questions on this list, please don't laugh.) As an undergrad he majored in philosophy, so this will be his first foray into computer programming and statistics. I'm thinking of having him use Introductory Statistics with R by Peter Dalgaard, but I'm unable to tell if the book requires calculus. I don't think this student knows calculus, so this would be a deal breaker. Can someone tell me if my student can get through this book starting out with just knowledge of algebra? Short answer: Yes. The long answer is also Yes. (Not really, it depends on what you mean by 'get through'.) Also, do you have other suggestions for texts, manuals, web sites, etc. that would introduce statistics and R simultaneously? Have you seen this? http://rwiki.sciviews.org/doku.php?id=books:intrstat Good luck, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX VoIP: gjke...@ekiga.net E-mail: gke...@ysu.edu http://people.ysu.edu/~gkerns/ __ 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] Gamma parametrization
Dear Randall, On Fri, Mar 19, 2010 at 10:24 AM, Randall Wrong randall.wr...@gmail.com wrote: Dear R users, ?rgamma gives me : rgamma(n, shape, rate = 1, scale = 1/rate) rate: an alternative way to specify the scale. The Gamma distribution with parameters ‘shape’ = a and ‘scale’ = s has density f(x)= 1/(s^a Gamma(a)) x^(a-1) e^-(x/s) Should I understand that scale=1/rate ? Is it written somewhere ? You are kidding, right? It is written 8 lines above your question, by my count. :-) Perhaps you meant rate = 1/scale. Then rgamma(n, shape=a, scale = s) should be equivalent to rgamma(n, shape=a, rate =1/s). Yep: dgamma(2, shape = 3, scale = 4) dgamma(2, shape = 3, rate = 1/4) I don't find this very clear. Thanks for your help. Randall The point is that some books (and software) parameterize by the 'scale', and a whole other bunch parameterize by the 'rate'. The reader (and user) always needs to be careful that the version used is the one expected. And the help file says that S doesn't have a 'scale' parameter at all. Just be careful, and you should be fine. And IMHO, given that the PDF of the density is shown it is reasonably clear as-is. Best, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX VoIP: gjke...@ekiga.net E-mail: gke...@ysu.edu http://people.ysu.edu/~gkerns/ __ 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] Update problem? Rcmdr disappears, won't re-open
Dear Brian, On Tue, Feb 2, 2010 at 3:02 PM, briancady413 briancady...@yahoo.com wrote: WinXP, R 2.10.1 I just updated R, and now have trouble. Perhaps it was the method I used to keep all the packages. I copied all the new packages from 2.10.1 back into the 2.10.0 folder, then copied them and all the others I've previously added from the 2.10.0 folder and pasted them back into 2.10.1's appropriate folder. Is this the source of my troubles? I am trying unsuccessfully to open RcmdrPlugin.IPSUR from within Rcmdr, via the pulldown tools menu. It insists I restart Rcmdr, which I let happen, then Rcmdr doesn't restart, and then I can not restart it using R's package loading function either. Please excuse the vast amount of text, below - I don't know what is and isn't relevant. I am not exactly sure what the problem is and do not have time to investigate at this exact moment, but until I get a chance to look at it might I suggest that you try Commander() at the command prompt when Rcmdr shuts down (and will not return); it is the basic way to restart Rcmdr when it goes away. I will have to boot into Windows later this evening to investigate, but in the meantime you may want to post your sessionInfo(). I have run RcmdrPlugin.IPSUR on R-2.10.1, Windows XP, as recently as yesterday during class without any problems. Gotta go for now. Jay -- *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX VoIP: gjke...@ekiga.net E-mail: gke...@ysu.edu http://people.ysu.edu/~gkerns/ __ 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] Update problem? Rcmdr disappears, won't re-open
Dear Brian, On Tue, Feb 2, 2010 at 4:33 PM, Liviu Andronic landronim...@gmail.com wrote: On 2/2/10, briancady413 briancady...@yahoo.com wrote: I am trying unsuccessfully to open RcmdrPlugin.IPSUR from within Rcmdr, via the pulldown tools menu. It insists I restart Rcmdr, which I let happen, then Rcmdr doesn't restart, and then I can not restart it using R's package loading function either. From the output I am not sure what you are doing, but this might help. There is some strange incompatibility between Rcmdr.HH and Rcmdr.IPSUR. Loading them in the following order Rcmdr.IPSUR Rcmdr.HH will work. Inverting the order will make Commander() fail to restart. You might want to experiment this in an R --vanilla session. Liviu I didn't see your sessionInfo and without it I am really stabbing in the dark, but it could be related to a problem I first noticed on October 20, 2008 and to which Liviu alluded above. I can generate a problem similar to yours (confirmed on Debian and Windows) if I do the following things, exactly in the following order. 1. load RcmdrPlugin.HH either with library() or via the Rcmdr Tools - Plugin menu, then 2. load RcmdrPlugin.IPSUR via the Rcmdr Tools - Plugin menu. The cause seems to be related to the fact that RcmdrPlugin.IPSUR removes the default Continuous/Discrete Distributions menus in their entirety (and replaces them with IPSUR menus). Since RcmdrPlugin.HH has certain submenus within those removed menus, there is a conflict between the added versus the subtracted. Here are three workarounds to the above problem. 1) Do what Liviu suggested (thanks for pointing that out, Liviu). 2) Load RcmdrPlugin.IPSUR with the command library(RcmdrPlugin.IPSUR) and do not use the Tools - Load Rcmdr Plugins menu. This method works every time, regardless of the order in which other packages were loaded, and is what I recommend to my students. 3) Locate the folder RcmdrPlugin.IPSUR in your local library. In the subdirectory /etc/ you will find a file menus.txt. Comment (or delete) from that file the following line: remove continuousMenu Thanks to John Fox for tracking this down back then. If you do method 3) then be warned that there will be a similar but non-identical Continuous distributions menu under the main Distributions menu. Visit here to see the differences between them. http://ipsur.r-forge.r-project.org/rcmdrplugin/features.php In principle I could remove the offending line from the distributed version of RcmdrPlugin.IPSUR but I have deliberately not done that because A) it confuses students and B) John went to nonzero trouble to make the remove capability functional; I think it's cool. I will think about it some more. Maybe there is a way to reorganize it to not confuse students and simultaneously avoid conflicts with other plugins. If this doesn't help then I am at a loss without something else like a sessionInfo(). Cheers, Jay __ 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] Starting with R and distributions graphics
Dear Andrea, On Tue, Dec 15, 2009 at 11:19 AM, Andrea Fui warloc...@gmail.com wrote: HI, i'm really new of R and i need some help. I have to describe some distributions for some dices throw: - launching 3 dices i need the distribution of the sum of the two higher values - launching 4 dices i need the distribution of the occurrences of the same value possibly i need a way to compare the two distribution adding the fourth dice to the first without summing it (only for occurrences count purpose) sorry for my english and thank you for the help :) Andrea [[alternative HTML version deleted]] I recommend the following, in the order given. http://www.r-project.org/posting-guide.html Then from the R command line: ?expand.grid ?transform ?apply ?aggregate install.packages(prob) library(prob) vignette(prob) # see section 8 ?rolldie ?addrv ?marginal Then turn off the computer, pick up a pencil, and solve the problems by hand. Wait a minute, maybe that should be step 1? Have fun, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX VoIP: gjke...@ekiga.net E-mail: gke...@ysu.edu http://people.ysu.edu/~gkerns/ __ 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] Need help to forecasting the data of the time series .
Dear R-help, This thread was started by a graduate student that I am supervising who is supposed to know how to do this already. I would appreciate it if the readers of this list would please refrain from any further responses to him; he was supposed to complete this project on his own to satisfy Master's degree requirements, and he is now in enough trouble as it is. On Thu, Dec 10, 2009 at 2:19 PM, stephen's mailinglist account stephen4mailingli...@googlemail.com wrote: http://cran.r-project.org/web/views/TimeSeries.html http://cran.r-project.org/doc/contrib/Ricci-refcard-ts.pdf http://www.statoek.wiso.uni-goettingen.de/veranstaltungen/zeitreihen/sommer03/ts_r_intro.pdf http://tur-www1.massey.ac.nz/~pscowper/ts/ http://www.maths.bris.ac.uk/~mazlc/TSA/r-ts.pdf turn it into a time series (ts is function - help(ts)) start plotting -- Stephen Thanks for the brief response, Stephen; he has seen (most of) this before. Unbelievable. Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX VoIP: gjke...@ekiga.net E-mail: gke...@ysu.edu http://people.ysu.edu/~gkerns/ __ 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] Combinations and joint probabilities
Dear Amelia, On 12/4/09, Amelia Livington amelia_living...@yahoo.com wrote: Dear R helpers Suppose I have two sets of ranges (interest rates) as Range 1 : (7 – 7.50, 7.50 – 8.50, 8.50 – 10.00) with respective probabilities 0.42, 0.22 and 0.36. Range II : (11-12, 12-14, 14-21) with respective probabilities 0.14, 0.56 and 0.30 respectively. My problem is to form the combinations of these ranges in a decreasing order of joint probabilities. It is assumed that these ranges are independent. Suppose A represents (7-7.50), B represents (7.50-8.50) and C represents (8.50 – 10.00). Also let X be (11-12), Y is (12-14) and Z is (14-21). These two groups are independent i.e. Prob(A and Y) = P(A) * P(Y) So there are 9 combinations possible as (AX, AY, AZ, BX, BY, BZ, CX, CY and CZ) respectively with the joint probabilities (0.059, 0.235, 0.126, 0.031, 0.123, 0.066, 0.05, 0.202, 0.108) respectively. My problem is (i) How to obtain these 9 combinations of probabilities in the sense how do I obtain the various combinations of these two ranges along-with their respective probabilities; (ii) How to arrange these 9 probabilities in descending order against the respective group combination i.e. for the combination AY, the joint probability is maximum at 0.235, followed by CY at 0.202 and so on. I sincerely apologize as perhaps I might not have raised the query properly. I have become member of this group today only and its been hardly a week since I have started learning R language. I have easily done this in Excel. My output should be something like this – Combination Probability AY 0.235 CY 0.202 AZ 0.126 BY 0.123 CZ 0.108 BZ 0.066 AX 0.059 CX 0.050 BX 0.031 I request you to guide me. Thanking in advance Amelia This sounds like a homework problem, which is a strict no-no for this list; be sure to read the Posting Guide. I will give you the benefit of the doubt for now, but be warned for the future. Are you looking for something like the following? Probspace - expand.grid(LETTERS[1:3], LETTERS[24:26]) marginals - list() marginals[[1]] - c(0.42, 0.22, 0.36) marginals[[2]] - c(0.14, 0.56, 0.30) pdf - expand.grid(marginals) Probspace$probs - apply(pdf, 1, prod) # the joint pmf xtabs(probs ~ Var1 + Var2, data = Probspace) # sorted by probability Probspace[order(Probspace$probs), ] See the prob package for other utilities in this vein. You can make the labels better with c(7 – 7.50, 7.50 – 8.50, 8.50 – 10.00), etc, in the first line instead of LETTERS. Welcome to R. Jay P.S. Please don't send HTML. Again, in the Posting Guide. [[alternative HTML version deleted]] *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX VoIP: gjke...@ekiga.net E-mail: gke...@ysu.edu http://people.ysu.edu/~gkerns/ __ 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 unordered combinations
Dear Dan, On Thu, Sep 17, 2009 at 5:31 PM, Erik Iverson eiver...@nmdp.org wrote: Dan, Still maybe a bit ugly, but no looping... unique(as.data.frame(t(apply(expand.grid(0:2, 0:2, 0:2), 1, sort The prob package provides a convenience wrapper for (essentially) Erik's solution: library(prob) urnsamples(0:2, size = 3, replace = TRUE, ordered = FALSE) Regards, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX VoIP: gjke...@ekiga.net E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ __ 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] faulty formatting of toLatex(sessionInfo())
Dear Liviu, On Wed, Aug 26, 2009 at 7:35 AM, Liviu Androniclandronim...@gmail.com wrote: Dear all I am writing an Sweave document and have encountered formatting issues with the locale part of toLatex(sessionInfo()). The fact that there is no spaces between the various locale variables means that LaTeX cannot easily find an appropriate place to break the lines, and some will get printed off screen. Below is the text output, and this .pdf document [1] shows the (faulty) tex result. Could anyone suggest how to get around this issue? Thank you Liviu There was a closely related discussion last April: https://stat.ethz.ch/pipermail/r-devel/2009-April/053094.html and IIRC this was fixed for R version 2.10. Hope this helps, Jay -- *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX VoIP: gjke...@ekiga.net E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ __ 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] Logistic regression and R
Dear Carlos, On Thu, Jul 30, 2009 at 6:11 PM, Carlos Lópeznato...@fisica.unam.mx wrote: Hello everybody :-) I have some data that I want to model with a logistic regression, most of the independent variables are numeric and the only dependent is categorical, I was thinking that I could apply a logistic regression using glm but I wanted to deepen my knowledge of this so I tried to do some reading and found the iris dataset, now I would like to ask two things, first if you know of any bibliography to read more about the logistic regression and R so I could understand and interpret better the output, See the following https://home.comcast.net/~lthompson221/ and the following specific link on that page: https://home.comcast.net/~lthompson221/Splusdiscrete2.pdf which is a manual to accompany Agresti's _Categorical Data Analysis_. In particular, you may want to check out Chapter 5 (and also some of 4). and second, what could I do when I have some independent variables that are not only numerical but categorical too, i.e. mixed (categorical and numerical), can I still use a logistic regression? Easy peasy, lemon squeezy. See page 78. Hope this helps, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX VoIP: gjke...@ekiga.net E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ __ 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] setdiff bizarre (was: odd behavior out of setdiff)
Jason, (moved back to R-help) On Sat, May 30, 2009 at 3:30 PM, Jason Rupert jasonkrup...@yahoo.com wrote: Jay, I really appreciate all your help help. I posted to Nabble an R file and input CSV files more accurately demonstrating what I am seeing and the output I desire to achieve when I difference two dataframes. http://n2.nabble.com/Support-SetDiff-Discussion-Items...-td2999739.html It may be that setdiff as intended in the base R functionality and prob was never intended to provide the type of result I desire. If that is the case then I will need to ask the Ninjas for help to produce the out come I seek. That is, when I different the data within RSetDiffEntry.csv and RSetDuplicatesRemoved.csv, I desire to get the result shown in RDesired.csv. Note that, it would not be enough to just work to remove duplicate CostPerSquareFoot values, since that variable is tied to EntryDate and HouseNumber. Any further help and insights are much appreciated. Thanks again, Jason From your description, something like the following should work: Let A = your RSetDiffEntry Let B = your RSetDuplicatesRemoved... library(prob) C - setdiff(A,B) D - rbind(A,C) E - D[duplicated(D),] The E should = your RDesired. Hope this helps, Jay P.S. I notice your row number 7 in RSetDuplicatesRemoved is duplicated by the following row. That's a typo, yes? If so, then E should have one more row than your RDesired. __ 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] Odd Behavior Out of setdiff(...) - addition of duplicate entries is not identified
Dear Jason, On Fri, May 29, 2009 at 2:48 PM, Jason Rupert jasonkrup...@yahoo.com wrote: I think I am using the improved version of setdiff(...) that handles data.frames, so I think some odd behavior was expected but this one is escaping me. It appears that the the addition of duplicate entries is not caught by the setdiff(...). Is this expected behavior? [snip] Thanks in advance for any feedback. Test1_DF-data.frame(HouseSize=c(1:100)) Test2_DF-rbind(Test1_DF, Test1_DF) setdiff(Test1_DF, Test2_DF) integer(0) setdiff(Test2_DF, Test1_DF) integer(0) However, Test3_DF-data.frame(HouseSize=c(1:25)) setdiff(Test1_DF, Test3_DF) [1] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 [17] 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 [33] 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 [49] 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 [65] 90 91 92 93 94 95 96 97 98 99 100 setdiff(Test3_DF, Test1_DF) integer(0) You didn't explicitly say which improved version of setdiff() that you are using, so I can only presume that you are using the setdiff.data.frame in the prob package. The behaviour you are observing is expected and matches the base:::setdiff behaviour in the case of vectors; cf. x1 - c(1:100) x2 - c(x1,x1) setdiff(x1, x2) # integer(0) setdiff(x2, x1) # integer(0) x3 - c(1:25) setdiff(x1, x3) # 26:100 setdiff(x3, x1) # integer(0) If so, is there another method or approach that should be used to identify duplicate row entries between two different data frames? The R-help archives are chock full of every possible variant of questions (and answers) about this, and you haven't said _exactly_ what you are looking for. In the absence of an already posted solution, please specify exactly what you want and I'll wager an R Ninja could dispatch it in moments. Regards, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ __ 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] Odd Behavior Out of setdiff(...) - addition of duplicate entries is not identified
Jason, On Fri, May 29, 2009 at 5:58 PM, Jason Rupert jasonkrup...@yahoo.com wrote: Jay, Thanks much for the reply. I think you are right about the prob. Unfortunately, I was not able to find the old emails I had discussing the use of the more powerful setdiff that essentially inherits from the base class R setdiff functionality but extends that functionality by now working with data.frames instead of just a simple array of values. Love this functionality. Your previous post is here [1] http://tolstoy.newcastle.edu.au/R/e6/help/09/03/7781.html and my earlier post is here: [2] https://stat.ethz.ch/pipermail/r-devel/2007-December/047706.html (please note that the link in [1] referring to [2] is now broken). As mentioned in [2], the notions of set and element are ambiguous in the data frame case... what is an element...? a row, a column, or a single entry? However, for the following example, Test1_DF-data.frame(HouseSize=c(1:100), LandLocation=c(Here)) Test1_DF-data.frame(HouseSize=c(1:100), LandLocation=c(Here), Price = c(Low)) Test2_DF-rbind(Test1_DF, Test1_DF) setdiff(Test1_DF, Test2_DF) [1] HouseSize LandLocation Price 0 rows (or 0-length row.names) setdiff(Test2_DF, Test1_DF) [1] HouseSize LandLocation Price 0 rows (or 0-length row.names) I was hoping for this example one of the setdiff's would have returned essentially Test1_DF, since it is duplicated and that is what is different between the two dataframes. So, I guess I am trying to figure out a way to truely diff the dataframes, i.e. determine when two data.frames are different from one another and then receive the output of the results. Does this capability exist in a function within a current R package or does it exist within a typically used pattern to create this functionality? Thanks again for any feedback you can provide. Your question speaks to the ambiguity above. For instance, your 2nd example would be solved by a setdiff for data frames that operates column-wise. If that is all you want, then IIRC there are at least 3 independent solutions in [2] to the row-wise problem. It should be easy enough to tweak one of them to operate on columns instead. For an efficient setdiff() for data frames that can decipher on-the-fly which of row/column/entry is desired, I am going to have to defer to the aforementioned Ninjas. :-) Also, I tried to determine my Session Info and the packages I have loaded, but I received the following: sessionInfo() Error in x$Priority : $ operator is invalid for atomic vectors Ninjas. Hope this helps, Jay __ 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 Books listing on R-Project
Jay: why not post your R-books how to on the wiki itself??? Because I thought that it would be better to write the instructions in R-wiki language that anybody could modify rather than post a PDF by me. Here is what I had in mind: http://wiki.r-project.org/rwiki/doku.php?id=links:books:howto Also, I put the books from the main page in the above format: http://wiki.r-project.org/rwiki/doku.php?id=links:books I wrote some R code to wikify the R-books list from the R web site -- it won't deal with LaTeX code in the abstract, but otherwise should convert automatically. Excellent a person could use what you have written to simply copy/paste into the wiki in the appropriate place(s). One of the advantages of the R wiki is the ease with which books may be categorized - which goes back to Stavros' OP. At the time, I went to Springer or CRC somewhere and found the below categories. Judging from the flyers that fill my office mailbox, I believe that all of them are currently covered by *some* book related to R. If it were the author's responsibility to put their book in the proper category or categories, and given that authors are typically of a mind to sell books... then perhaps the R wiki would populate and maintain itself? Jay Bayesian Statistics Biostatistics Computational Statistics Environmental Statistics Introductory Statistics Probability Theory Applications Programming in R and S Reference Statistics Collected Works SPC/Reliability/Quality Control Statistical Genetics Bioinformatics Statistical Learning Data Mining Statistical Theory Methods Statistics for Biological Sciences Statistics for Business, Finance Economics Statistics for Engineering and Physical Science Statistics for Psychology, Social Science Law Unclassified __ 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] can you tell what .Random.seed *was*?
Set.seed takes an integer argument, that is, 2^32-1 distinct values (cf NA_integer_), so the very simplest approach, brute-force search, has a hope of working: whatseed - function (v) { i - as.integer(-2^31+1); max - as.integer(2^31-1) while (imax) { set.seed(i); if (runif(1)==v) return(i); i-i+1 } } (OK, being able to figure it out in 2*10^68 years doesn't count, but within a couple months is acceptable.) set.seed(-2^31+10) system.time(whatseed(runif(1))) user system elapsed 1.53 0.00 1.53 2^32*(1.53/10)/3600 = 18.25 18 hours 3) does the answer change if there is a remove(.Random.seed) command right before the save.image() command? Depending on which RNG algorithm (RNGkind) you use, there may be cryptographic techniques that are more efficient than brute-force search, especially if the full internal state (.Random.seed) is preserved. This all assumes that the seed is set *only* with set.seed. If .Random.seed is modified directly, there are many more possibilities for most of the RNGs. -s Thanks very much to Warren and Stavros for their additional insight. Putting all of this together, I think I am now ready to formulate my question intelligently: Using Sweave, I want to distribute randomly generated problems AND answers to both teacher AND student. More precisely, I want to distribute: 1) the .Rnw file 2) the .RData file saved near the end of the Sweave process. I want it to be *easy* for the Instructor to change my seed and generate new problems. I want it to be *difficult* for students to figure out the seed and automatically generate solutions on their own. Of course, difficult is a relative term, since what is difficult for them may well be easy for me, and what is difficult for me will be trivial to cryptographers and some people on this list. The audience would be, say, upper division undergraduate students at a public university. What is clear so far: a brute force search of set.seed() is really pretty easy and fast... even for students at this level. However, relating to Duncan's second remark: what if the Instructor inserted an *unknown* very large number of calls to the RNG near the beginning of the .Rnw (but after the set.seed)... and did not distribute this information to the students... that would make it much harder, yes? Any ideas that are even better than this? Conceivably, some of my students will be searching these archives in the future; please feel free to respond off-list if appropriate. Jay -- *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ __ 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] can you tell what .Random.seed *was*?
Dear R-help, Suppose I write a script that looks something like this: script.R set.seed(something) x - rnorm(100) y - runif(500) # bunch of other stuff save.image() ### end of script.R Now, I give you a copy of my script.R (with the set.seed statement removed, of course) together with the .RData file that was generated by the save.image() command. Question: 1) can you tell me what my original set.seed() value was? (I wouldn't be able to figure it out, but maybe someone can) 2) is it possible *in principle* to figure out what set.seed was, given the above? (OK, being able to figure it out in 2*10^68 years doesn't count, but within a couple months is acceptable.) 3) does the answer change if there is a remove(.Random.seed) command right before the save.image() command? Any thoughts would be appreciated. Cheers, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ __ 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] can you tell what .Random.seed *was*?
Dear Duncan, On Thu, May 14, 2009 at 4:39 PM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 5/14/2009 3:36 PM, G. Jay Kerns wrote: Question: 1) can you tell me what my original set.seed() value was? (I wouldn't be able to figure it out, but maybe someone can) The only way I know is to test all 2^32 possible values of the seed. I think cryptographers would know faster ways. 2) is it possible *in principle* to figure out what set.seed was, given the above? (OK, being able to figure it out in 2*10^68 years doesn't count, but within a couple months is acceptable.) I think the brute force search would take about 4-5 days on my old computer, so a fast one could do it in a few hours. 3) does the answer change if there is a remove(.Random.seed) command right before the save.image() command? Not with the brute force search. The cryptographers would probably be able to make use of the random seed pretty well. Now, if the seed was removed just before the values were generated, the seed would be generated from the system clock. If you knew the time that this occurred approximately, the search could be a lot faster. On the other hand, if there was an unknown large amount of work between the time of seed generation and the generation of the values x and y, it would be much more difficult to brute force the solution, because most of the values of .Random.seed are not reachable either by the clock method or set.seed, they are only reachable by lots of calls to the underlying generator. So for each seed value you'd need to do every possible number of RNG generations before generating x and y. Duncan Murdoch Thanks. That is exactly what I was looking for. R-help is awesome. Jay __ 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] Kumaraswamy distribution
Dear Debbie, On Tue, May 12, 2009 at 5:37 AM, Debbie Zhang debbie0...@hotmail.com wrote: Dear R users, Does anyone know how to write function for Kumaraswamy distribution in R? Since I cannot write dkumar, pkumar, etc. in R. Please help. Thanks a lot, Debbie Check the CRAN Task View on Probability distributions: http://cran.r-project.org/web/views/Distributions.html and in particular, check out package VGAM. HTH, Jay __ 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] problem with rgl package
Dear Erin, On Tue, May 5, 2009 at 5:55 AM, Erin Hodgess erinm.hodg...@gmail.com wrote: Dear R People: Here is something strange. I'm using Ubuntu 9.04 with R 2.9.0. I need to have the rgl package. Here are my results from installing: install.packages(rgl) Warning in install.packages(rgl) : argument 'lib' is missing: using '/usr/local/lib/R/site-library' --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/rgl_0.84.tar.gz' Content type 'application/x-gzip' length 1670659 bytes (1.6 Mb) opened URL == downloaded 1.6 Mb * Installing *source* package 'rgl' ... checking for gcc... gcc -std=gnu99 checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc -std=gnu99 accepts -g... yes checking for gcc -std=gnu99 option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -std=gnu99 -E checking for gcc... (cached) gcc -std=gnu99 checking whether we are using the GNU C compiler... (cached) yes checking whether gcc -std=gnu99 accepts -g... (cached) yes checking for gcc -std=gnu99 option to accept ISO C89... (cached) none needed checking for libpng-config... yes configure: using libpng-config configure: using libpng dynamic linkage checking for X... no configure: error: X11 not found but required, configure aborted. ERROR: configuration failed for package 'rgl' ** Removing '/usr/local/lib/R/site-library/rgl' I had the same problem a few days ago, and followed the recommendations of this message: http://tolstoy.newcastle.edu.au/R/e6/help/09/03/9250.html which fixed it for me. HTH, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ __ 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 set up a function for Central Limit Theorem
Dear Ivan, On 3/23/09, pfc_ivan pfc_i...@hotmail.com wrote: Hello guys, I am stuck here: How do I make 1000 samples of n = 10 observations from an Exponential distribution and then compute the mean for all those 1000 samples? The R Commander will do this. See the menus Distributions - Continuous - Exponential - Sample... If you were wanting to normalize the row sums (or investigate the sampling distribution of some other statistic, for that matter) then check out the Sampling Distributions... menu in RcmdrPlugin.IPSUR. Good luck, Jay Basically I need to prove the Central Limit theorem, which states: http://www.nabble.com/file/p22664113/d175f06cbf200bd52a2c27a2e56dc594.png Where the Sn is sum of random variables, n we have from the question, mu is mean and (sigma)^2 is variance. I am having trouble setting up the function to do this. *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ __ 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] setdiff for data.frames?
Dear Jason, On Thu, Mar 12, 2009 at 6:11 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try this: library(sqldf) BODsub - BOD[1:3,] sqldf(select * from BOD except select * from BODsub) For more see: http://sqldf.googlecode.com Also, please see http://finzi.psych.upenn.edu/R/R-devel/archive/26683.html and as a consequence of that discussion: library(prob) setdiff(A,B) Best, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ __ 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] Bivarite Weibull Distribution
Dear A.S. Qureshi, On Sun, Jan 4, 2009 at 11:36 AM, saboorha...@gmail.com wrote: HI Every one Could some one provide me definitions of following bivariate distributions gamma, exponencial, Weibull, half-normal , Rayleigh, Erlang,chi-square See Johnson, Kotz, and Balakrishnan (2000) for a reference book for multivariate distributions. From there, you will see that there are _many_ bivariate distributions that have Weibull marginals (or any other marginal distribution, for that matter). In other words, there isn't a bivariate Weibull distribution... there are all kinds of them. A modern way to address this is by using copulas; see Nelson (1998, 2007). To this end, R has packages fCopulae and copula among others. There is a CRAN Task View for Probability Distributions: http://cran.r-project.org/web/views/Distributions.html Using copulas and (for example) the inverse CDF approach, one can generate bivariate samples that have any given marginal distribution. See Nelson for details. Best, Jay thanks A.S. Qureshi __ 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. -- *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ __ 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] generate combination multiset (set with repetition)
Dear Reuben, On Thu, Dec 11, 2008 at 12:53 PM, baptiste auguie ba...@exeter.ac.uk wrote: Hi, Perhaps you can use expand.grid and then remove the mirror combinations, values - 1:3 tmp - expand.grid(values, values) unique.combs - tmp[tmp[, 1]=tmp[, 2], ] unique.combs[do.call(order, unique.combs), ] # reorder if you wish Var1 Var2 111 412 713 522 823 933 I vaguely recall a discussion a few months ago on extending this approach to a variable number of arguments to expand.grid. Hope this helps, baptiste Here is another way: library(prob) urnsamples(1:3, size = 2, ordered = FALSE, replace = TRUE) You can convert to a matrix with as.matrix(), if desired. Regards, Jay -- *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ __ 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] generate combination multiset (set with repetition)
Dear Reuben, [snip] my questions now are... how would I generalize functions 3 and 4 for m And, which of the 4 functions would be best for varying ranges of n and m? I am expecting values for n to range between 1 and 1e3, while m will range between 1 and 1e6. Reuben Regarding your 2nd question, for the values of n and m that you request, the answer is none. The number of combinations is astronomically large. To get an idea, try library(prob) nsamp( n, m, ordered = FALSE, replace = TRUE ) for assorted values of n and m. Bearing the above in mind, it may be useful to think carefully about _why_ it is desired to have all possible combinations. In some circumstances, it is good enough to randomly generate combinations and draw inferences from a sampling distribution of some sort associated with the problem. Good luck. Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ __ 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] generate combination multiset (set with repetition)
Reuben, On Thu, Dec 11, 2008 at 9:28 PM, Reuben Cummings reub...@gmail.com wrote: Good point, I actually thought about doing some kind of sampling before, but now I think I don't have a choice. Essentially, what I am doing is calculating possible asset allocation possibilities, e.g. N is the number of available assets and M is the available buckets of money to spend on the assets. With N = 3 and M = 2, I am saying I have a choice to buy any of 3 three assets and I can afford to make 2 such purchases. These combinations are represented below: M1 M2 [1,]1 1 [2,]1 2 [3,]1 3 [4,]2 2 [5,]2 3 [6,]3 3 [1,] is saying I spend all of my money buying asset 1. this produces the following asset allocations A1 A2 A3 [1,]1 0 0 [2,].5 .5 0 [3,].5 0 .5 [4,]0 1 0 [5,]0 .5 .5 [6,]0 0 1 [1,] again, is saying that my allocation is 100% asset 1. from here, I plan to run some risk/performance metrics on the allocations and then come up with a list of the best allocation choices. The sampling will come in handy to give me random asset allocations. I've taken a statistical design of experiments class, so I am familiar with generating factorial experiment designs. So, how would I go about producing the random samples? how about this: rmultinom(10, 2, rep(1,3))/2 Please note that the above assumes a model in which it is equally likely to choose asset 1, 2, or 3. You should think about the model carefully and adjust the prob argument accordingly. And what # of combinations should I use as the cutoff for doing a sampling instead of testing every possible combination? There isn't a definitive answer to that question. Assuming that it is desired to find an 'average risk' of some sort, it would be good to increase the number of samples until the risk estimate stabilizes to a value with which you are comfortable. Best, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: gke...@ysu.edu http://www.cc.ysu.edu/~gjkerns/ __ 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] Create unique sets of 3 from a vector of IDs?
Dear Brandon, On Tue, Dec 2, 2008 at 10:46 PM, Dylan Beaudette [EMAIL PROTECTED] wrote: On Tue, Dec 2, 2008 at 7:42 PM, philozine [EMAIL PROTECTED] wrote: Dear all: This is one of those should be easy problems that I'm having great difficulty solving. I have a vector containing ID codes, and I need to generate a 3-column matrix that contains all possible combinations of three. For example, my ID vector looks like this: A B C D E I need to generate a matrix that looks like this: A B C A B D A B E A C B A C D A C E A D B A D C A D E Hi, Does this do what you want? expand.grid(letters[1:5], letters[1:5], letters[1:5]) D Have a look at urnsamples() in the prob package. ID - LETTERS[1:5] urnsamples(ID, size = 3, replace = FALSE, ordered = FALSE) Best, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ __ 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] Create unique sets of 3 from a vector of IDs?
Dear Kingsford, You are quite right, my mistake: urnsamples(ID, size = 3, replace = FALSE, ordered = TRUE) Thanks. Jay On Wed, Dec 3, 2008 at 12:04 AM, Kingsford Jones [EMAIL PROTECTED] wrote: However, I believe Brandon was trying to get the permutations of size 3, rather than combinations. Dylan provided a solution including repeats. Here's one without: library(gtools) permutations(5, 3, LETTERS[1:5]) [,1] [,2] [,3] [1,] A B C [2,] A B D [3,] A B E [4,] A C B [5,] A C D [6,] A C E [7,] A D B [8,] A D C [9,] A D E [10,] A E B [11,] A E C [12,] A E D [13,] B A C [14,] B A D [15,] B A E [16,] B C A [17,] B C D [18,] B C E [19,] B D A [20,] B D C [21,] B D E [22,] B E A [23,] B E C [24,] B E D [25,] C A B [26,] C A D [27,] C A E [28,] C B A [29,] C B D [30,] C B E [31,] C D A [32,] C D B [33,] C D E [34,] C E A [35,] C E B [36,] C E D [37,] D A B [38,] D A C [39,] D A E [40,] D B A [41,] D B C [42,] D B E [43,] D C A [44,] D C B [45,] D C E [46,] D E A [47,] D E B [48,] D E C [49,] E A B [50,] E A C [51,] E A D [52,] E B A [53,] E B C [54,] E B D [55,] E C A [56,] E C B [57,] E C D [58,] E D A [59,] E D B [60,] E D C Kingsford Jones On Tue, Dec 2, 2008 at 9:41 PM, G. Jay Kerns [EMAIL PROTECTED] wrote: Dear Brandon, On Tue, Dec 2, 2008 at 10:46 PM, Dylan Beaudette [EMAIL PROTECTED] wrote: On Tue, Dec 2, 2008 at 7:42 PM, philozine [EMAIL PROTECTED] wrote: Dear all: This is one of those should be easy problems that I'm having great difficulty solving. I have a vector containing ID codes, and I need to generate a 3-column matrix that contains all possible combinations of three. For example, my ID vector looks like this: A B C D E I need to generate a matrix that looks like this: A B C A B D A B E A C B A C D A C E A D B A D C A D E Hi, Does this do what you want? expand.grid(letters[1:5], letters[1:5], letters[1:5]) D Have a look at urnsamples() in the prob package. ID - LETTERS[1:5] urnsamples(ID, size = 3, replace = FALSE, ordered = FALSE) Best, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ __ 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. -- *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ __ 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 test for the empty set
Dear R-help, I first thought that the empty set (for a vector) would be NULL. x - c() x However, the documentation seems to make clear that there _many_ empty sets depending on the vector's mode, namely, numeric(0), character(0), logical(0), etc. This is borne out by y - letters[1:3] z - letters[4:6] intersect(y,z) which, of course, is non-NULL: is.null(character(0)) # FALSE So, how can we test if a vector is, say, character(0)? The following doesn't (seem to) work: x - character(0) x == character(0) # logical(0) More snooping led to the following: wiki.r-project.org/rwiki/doku.php?id=tips:surprises:emptysetfuncs and at the bottom of the page it says logical(0) is an empty set, thus is TRUE. However, I get isTRUE(logical(0)) # FALSE but, on the other hand, all.equal(x, character(0)) # TRUE This would seem to be the solution, but am I missing something? and in particular, is there an elegant way to check in the case that the mode of the vector is not already known? Thanks in advance for any insight you may have. Best, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ __ 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 test for the empty set
Dear Steven, length(x) Does this cover all your use cases? Yes, and thanks again to everybody else who later replied. I had falsely imagined something so much more complicated...!? Next time, I will wait 8*runif(1) before posting. :-) Best, Jay HTH Steven McKinney Statistician Molecular Oncology and Breast Cancer Program British Columbia Cancer Research Centre email: smckinney +at+ bccrc +dot+ ca tel: 604-675-8000 x7561 BCCRC Molecular Oncology 675 West 10th Ave, Floor 4 Vancouver B.C. V5Z 1L3 Canada -Original Message- From: [EMAIL PROTECTED] on behalf of G. Jay Kerns Sent: Mon 11/24/2008 9:41 AM To: r-help@r-project.org Subject: [R] how to test for the empty set Dear R-help, I first thought that the empty set (for a vector) would be NULL. x - c() x However, the documentation seems to make clear that there _many_ empty sets depending on the vector's mode, namely, numeric(0), character(0), logical(0), etc. This is borne out by y - letters[1:3] z - letters[4:6] intersect(y,z) which, of course, is non-NULL: is.null(character(0)) # FALSE So, how can we test if a vector is, say, character(0)? The following doesn't (seem to) work: x - character(0) x == character(0) # logical(0) More snooping led to the following: wiki.r-project.org/rwiki/doku.php?id=tips:surprises:emptysetfuncs and at the bottom of the page it says logical(0) is an empty set, thus is TRUE. However, I get isTRUE(logical(0)) # FALSE but, on the other hand, all.equal(x, character(0)) # TRUE This would seem to be the solution, but am I missing something? and in particular, is there an elegant way to check in the case that the mode of the vector is not already known? Thanks in advance for any insight you may have. Best, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ __ 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. -- *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ __ 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 test for the empty set
Dear Everybody, Thanks, length() is the answer. Best, Jay On Mon, Nov 24, 2008 at 1:15 PM, Ted Harding [EMAIL PROTECTED] wrote: On 24-Nov-08 17:41:25, G. Jay Kerns wrote: Dear R-help, I first thought that the empty set (for a vector) would be NULL. x - c() x However, the documentation seems to make clear that there _many_ empty sets depending on the vector's mode, namely, numeric(0), character(0), logical(0), etc. This is borne out by y - letters[1:3] z - letters[4:6] intersect(y,z) which, of course, is non-NULL: is.null(character(0)) # FALSE In the above (and below) cases, would not (length(x)==0) do? Ted. So, how can we test if a vector is, say, character(0)? The following doesn't (seem to) work: x - character(0) x == character(0) # logical(0) More snooping led to the following: wiki.r-project.org/rwiki/doku.php?id=tips:surprises:emptysetfuncs and at the bottom of the page it says logical(0) is an empty set, thus is TRUE. However, I get isTRUE(logical(0)) # FALSE but, on the other hand, all.equal(x, character(0)) # TRUE This would seem to be the solution, but am I missing something? and in particular, is there an elegant way to check in the case that the mode of the vector is not already known? Thanks in advance for any insight you may have. Best, Jay E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 24-Nov-08 Time: 18:15:31 -- XFMail -- -- *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ __ 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] Bivariate normal
Dear Sasha, On Wed, Oct 1, 2008 at 11:43 AM, Sasha Pustota [EMAIL PROTECTED] wrote: Package mvtnorm provides dmvnorm, pmvnorm that can be used to compute Pr(X=x,Y=y) and Pr(Xx,Yy) for a bivariate normal. Are there functions that would compute Pr(Xx,Y=y)? I'm currently using integrate with dmvnorm but it is too slow. Strictly speaking, the probability that you are asking to calculate is always 0, for every value of y. The reason is that the quantity you are requesting is the _volume_ of a vertical slice, at the value y, which is zero. It may be useful to think carefully about the problem you are trying to solve... perhaps a conditional probability is more appropriate. You did not say exactly which integral you are trying to compute: conceivably it would be \int_{-\infty}^{x} f(u, y) du, where f(.,.) is the bivariate normal pdf. If this is indeed what you want, then a work-around would be to calculate P( X x | Y = y ). We know that given Y=y, X is normal with mean and variance formulas given in most introductory statistics books. Thus, you could compute P( X x | Y = y ) with pnorm(x, mean = something, sd = something). In that case, the integral above would simply be P( X x | Y=y ) * f(y), where f(y) is the marginal pdf of Y (a dnorm). Note that the above is assuming that y is a fixed constant; if not, then you may want to check out the Ryacas package. I hope that this helps, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ __ 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] Plot qnorm
Dear Talina, On Thu, Sep 11, 2008 at 2:28 PM, Talina Ruiz [EMAIL PROTECTED] wrote: Hi, I have this problem: X is hazardous variable N(mean 2, sd=3) question 1) Find the c value, so that P(Xc)=0.10. using R question 2) Graph the function N(2,3) and with this graph, explain what you do in question number 1. I just found question number one but not the second one. So, I'd like to make a plot form this distribution N (2,3) using the functions plot and qnorm. I couldn't find how make it in R. Thanks for any hint. The notation that you have used is somewhat ambiguous, in that N(2,3) typically denotes the normal CDF (or sometimes the PDF), neither of which being the quantile function qnorm(). But as to your specific question, the IPSUR plugin for the R Commander will plot quantile functions. After installing Rcdmr and RcmdrPlugin.IPSUR (version = 0.1-5), do library(RcmdrPlugin.IPSUR) and after the Commander restarts take a look at the Distributions menu. You can plot any of the above. In addition, you will have code echoed to you for the console that you can use for other problems. Best wishes, Jay *** G. Jay Kerns, Ph.D. Associate Professor Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ __ 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] Writing Rcmdr Plugins
...[snipped] The /inst directory: in here you will need to put a file menus.txt This should have been the /inst/etc directory, as you noted in your original post. Jay __ 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] SLLN for loggamma fails for 2 order moments
Dear Michael, The SLLN hasn't failed. :-)In this particular example, it looks like the sample means are simply converging at a rate which is slower than desired. Unfortunately, your particular loggamma doesn't have a finite fourth moment; so you don't have the usual (worst case) convergence rate proportional to sqrt(log (log(n)) / n) by the law of the iterated logarithm. In fact, your loggamma has only finite moments less than 2.6... see below. Again, the SLLN still holds. But convergence is slow. I have double-checked and the source code for both mlgamma AND rlgamma in the actuar package are correct. There may be other people who can identify numerical issues that slow down the convergence rate even more. Best, Jay P.S. the MGF of gamma is all you need for the moments of loggamma... E(X^k) = (1 - k / 2.6)^(-25) On Sat, Jun 14, 2008 at 4:54 AM, michaelhk82 [EMAIL PROTECTED] wrote: Hi. I was trying to calculate 2. order moment for a loggamma sample. Also, I checked it with the function mlgamma from the package actuar, which calculates moments based on loggamma parameters. Se below - I get big deviations. Numerical integration suggests that mlgamma gets it right. What fails in my attempt to use SLLN to estimate the 2. order moments? Code: sum(rlgamma(10^6,25,2.6)^2)/10^6 #Estimation by SLLN [1] 1.964011e+13 mlgamma(2,25,2.6) #2.order moment by mlgamma [1] 8.328225e+15 The difference is more than a factor 100! I have tried to run the code several times but I never manage to exceed the value of mlgamma - that is, by SLLN I keep underestimating the 2. order moment. (and tried with larger samples as well, but my cpu wont accept sample larger than 10^7). Does anyone have an idea of what is happening? Michael -- View this message in context: http://www.nabble.com/SLLN-for-loggamma-fails-for-2-order-moments-tp17837233p17837233.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. -- *** G. Jay Kerns, Ph.D. Assistant Professor / Statistics Coordinator Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ __ 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] Multiset Permutations
Dear Steven, The prob package does this, too. (Please see the * fix below). x - c(0, 0, 1, 2, 2) library(prob) A - permsn(x, 5) # with repeated columns B - unique( data.frame( t(A) )) # no repeated rows The data frame B will have 56 rows and 5 columns. If you need the columns collapsed, then you can use the apply(B, 1, paste, sep = , collapse = ) command that Johannes suggested. Details are in the prob package vignette, vignette(prob) I hope that this helps, Jay * fix: As it happens, your particular question helped to identify a bug in the current CRAN version of prob. Thank you! :-) Below is a fix until the updated version appears. permsn - function (x, m) { require(combinat) if (is.numeric(x) length(x) == 1 x 0 trunc(x) == x) x - seq(x) temp - combn(x, m) if ( isTRUE(all.equal(m,1)) ) { P - temp } else if (isTRUE(all.equal(m, length(x { temp - matrix(x, ncol = 1) P - array(unlist(permn(temp[, 1])), dim = c(m, factorial(m))) } else { k - dim(temp)[1] n - dim(temp)[2] P - array(unlist(permn(temp[, 1])), dim = c(k, factorial(k))) for (i in 2:n) { a - temp[, i] perms - array(unlist(permn(a)), dim = c(k, factorial(k))) P - cbind(P, perms) } } return(P) } *** G. Jay Kerns, Ph.D. Assistant Professor / Statistics Coordinator Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ __ 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] (Small) problem with barchart
Dear Kimmo, It doesn't appear that anyone has yet mentioned pareto.chart() in the qcc package; it may serve your purposes. Please note that it does not require the data frame to be ordered beforehand. x - DATA[[2]] names(x) - DATA[[1]] library(qcc) pareto.chart(x) Best wishes, Jay On Feb 3, 2008 11:53 AM, Deepayan Sarkar [EMAIL PROTECTED] wrote: On 2/3/08, K. Elo [EMAIL PROTECTED] wrote: Hi, I have a small problem when using barchart. I have the following data: letters a 6f 18 1a 15 10 j 12 9i 12 4d 9 5e 6 The data is from a survey and summaries the alternatives selected in one question. The idea is to have a bar chart illustrating the count of each selection in descending order. The data frame is already ordered in descending order. Thus, the chart _should_ look like this: f |xx a |xxx j | i | d |x e |xx But if I use the command: barchart(DATA[[2]] ~ DATA[[1]]) The bars are displayed in alphabetical order. How could I get the graph I would like to have? You have the choice of (1) ordering the levels by their appearance in DATA (2) ordering them in increasing order of 'a' (irrespective of original order) For (1), you should use the 'levels' argument of factor(). For (2), the reorder() function is helpful, and more general for your use (but note that it's first argument already has to be a factor). Assuming that DATA is a data frame and the 'letters' variable is already a factor, you could try barchart(factor(letters, levels = unique(letters) ~ a, data = DATA) or barchart(reorder(letters, a) ~ a, data = DATA) I would also encourage you to use 'origin = 0', or if you don't like that, use dotplot() instead of barchart(). -Deepayan __ 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. -- *** G. Jay Kerns, Ph.D. Assistant Professor / Statistics Coordinator Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ __ 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-pkgs] prob package: elementary probability on finite sample spaces
Dear R Community, I am pleased to announce the beta-release of the prob package. The source code is now on CRAN, and binaries should be generated there before long. In the meantime, you can get it with install.packages(prob, repos = http://r-forge.r-project.org;) The prob package gives a framework for doing elementary probability on finite sample spaces in R. The primary notion of probability space has been built around the data frame structure, both for simplicity and to maximize compatibility with the R Commander by John Fox. The package addresses an ample proportion of material in a typical undergraduate course in elementary probability, or the probability material in an introductory statistics course. For details, see vignette(prob). Since the focus is on sample/probability spaces, the prob package could be used as a precursor to the more sophisticated distrxxx-family of packages. Topics: * construction of sample spaces (in the sense of 'prob' ) of various kinds. Some standard sample spaces are included (toss a coin, roll a die, sample from an urn, draw cards, roulette, etc.) * counting and the Multiplication Principle, * subsets and events including methods for intersect, union, and setdiff extending those in the base package, * the prob function for finding probability and conditional probability of events, * simulation and relative frequencies, * random variables, marginal distributions, * extensions for more general sample spaces, * discrete multivariate distributions with finite support, * more... Some discussion and examples can be found at the R-Forge prob project web page: http://prob.r-forge.r-project.org/ There are many avenues for future development/improvement; all suggestions and comments are welcomed. I would appreciate hearing about your experiences with it in the classroom and elsewhere. The audience for this package would include teachers and students of elementary probability, or simply anyone wanting to dabble with probability on a finite sample space. Regards, Jay *** G. Jay Kerns, Ph.D. Assistant Professor / Statistics Coordinator Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-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] number of count of each unique row
Hi Louis, If I am understanding your question correctly, here is one way: suppose your matrix is M of dimension n x k. D - data.frame(M) # convert to data frame ones - rep(1, n) # a column of 1s Now you can count the number of repeats of each unique row. aggregate( ones, by = as.list(D), FUN = sum) The output will be a data frame with the unique rows, and a column at the end labeled x with the frequency of each unique row. Once you get this you can convert to a list, manipulate, etc. I am sure that there exist faster/better methods. Best, Jay On Dec 21, 2007 5:03 PM, Louis Martin [EMAIL PROTECTED] wrote: Hi, I have a matrix of duplicate rows. How to output a list the unique rows with their count? I have used unique to have the unique rows, but can't produce the occurences of each unique row. Thanks Louis - [[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. -- *** G. Jay Kerns, Ph.D. Assistant Professor / Statistics Coordinator Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ __ 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] analytical solution to Sum of binominal distributed random numbers?
Hi Rainer, The distr package can calculate the distribution for you: library(distr) X - Binom(size = 7, prob = 0.3) Y - Binom(size = 11, prob = 0.5) Z - X + Y d(Z)( 0:18 ) # the pmf r(Z)( n = 5 ) # random variates Please note, however, that size and prob must be of length 1. Best, Jay On 10/24/07, Rainer M. Krug [EMAIL PROTECTED] wrote: Frede Aakmann Tøgersen wrote: Perhaps http://stinet.dtic.mil/cgi-bin/GetTRDoc?AD=ADA266969Location=U2doc=GetTRDoc.pdf is something that you can use? Thanks a lot - that might help. Rainer Best regards Frede Aakmann Tøgersen Scientist UNIVERSITY OF AARHUS Faculty of Agricultural Sciences Dept. of Genetics and Biotechnology Blichers Allé 20, P.O. BOX 50 DK-8830 Tjele Phone: +45 8999 1900 Direct: +45 8999 1878 E-mail: [EMAIL PROTECTED] Web: http://www.agrsci.org This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email. -Oprindelig meddelelse- Fra: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] På vegne af Rainer M Krug Sendt: 24. oktober 2007 09:11 Til: Charles C. Berry Cc: r-help Emne: Re: [R] analytical solution to Sum of binominal distributed random numbers? Hi Charles thanks for the pointing out that size and prob can be vectors as well - I tried it out but used 1 as the number of observations, assuming that and it only gave me one randon mumbewr (as it should be but not expected). But I was more looking at a analytical solution, as I have to sum up a huge number of random numbers. But I am going to try your solution as it should be much faster already. Thanks Rainer Charles C. Berry wrote: ?rbinom only says: size: number of trials (zero or more). prob: probability of success on each trial. But they can be vectors. BTW, you were aked to PLEASE ... provide minimal, self-contained, reproducible code. What you show cannot run without correction. Most likely, you intended size(n) to be the n-th element of the vector 'size', which in R is written 'size[ n ]' . In which case sum (rbinom( length(prob) , size, prob ) ) works. Chuck On Tue, 23 Oct 2007, Rainer M Krug wrote: Hi I have two vectors, prob and size, and I want to add the random deviates of these two, i.e. sum( sapply( 1:length(prob), function(n){ rbinom(1, size(n), prob(n) } ) ) My problem is that I have to do this for a large number of value combinations. Is there a faster way of doing this? Rainer __ 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. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- *** G. Jay Kerns, Ph.D. Assistant Professor / Statistics Coordinator Department of Mathematics Statistics Youngstown State University Youngstown, OH 44555-0002 USA Office: 1035 Cushwa Hall Phone: (330) 941-3310 Office (voice mail) -3302 Department -3170 FAX E-mail: [EMAIL PROTECTED] http://www.cc.ysu.edu/~gjkerns/ __ 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.