Re: [R] rggobi is crashing R-2.7.0
Hard as it is for me to imagine, the ggobi windows stay open and functional while R (in emacs) has crashed in the background after throwing the error messages. As a perhaps naive Linux user, I thought that if a parent process crashed any processes it spawned would crash too. I guess not in this case. Ubuntu currently is distributing graphviz 2.16.1 Thanks, Mark On Wed, May 7, 2008 at 12:14 AM, Michael Lawrence [EMAIL PROTECTED] wrote: On Tue, May 6, 2008 at 6:06 PM, Mark Kimpel [EMAIL PROTECTED] wrote: R crashed just after the warnings were issued, but ggobi kept running (if that makes sense). I am not sure if that makes sense; GGobi should exit when the R process does. I have Graphviz and Rgraphiz installed and use Rgraphviz regularly without a problem, so I'm not sure why it didn't load. Mark Which version of graphviz? I am not sure which version the Ubuntu binary expects, but this may be a binary compatibility issue. That said, I am not sure if the GraphLayout plugin is the reason for R crashing... On Tue, May 6, 2008 at 4:37 PM, Michael Lawrence [EMAIL PROTECTED] wrote: On Tue, May 6, 2008 at 10:32 AM, Mark Kimpel [EMAIL PROTECTED] wrote: I am running 64-bit Ubuntu 8.04 and when I invoke rggobi the interactive graph displays but R crashes. See my sessionInfo() and a short example below. Ggobi and rggobi installed without complaints. Mark sessionInfo() R version 2.7.0 Patched (2008-05-04 r45620) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rggobi_2.1.9 RGtk2_2.12.5-3 graph_1.18.0 loaded via a namespace (and not attached): [1] cluster_1.11.10 tools_2.7.0 a - matrix(rnorm(1000), nrow = 10) g - ggobi(a) ** (R:25146): CRITICAL **: Error on loading plugin library plugins/GraphLayout/plugin.la: libgvc.so.3: cannot open shared object file: No such file or directory ** (R:25146): CRITICAL **: Error on loading plugin library plugins/GraphLayout/plugin.la: libgvc.so.3: cannot open shared object file: No such file or directory ** (R:25146): CRITICAL **: can't locate required plugin routine addToToolsMenu in GraphLayout It's not clear to me - did R crash or did you just receive these warnings? These warnings are due to a missing graphviz, so the GraphLayout plugin fails to load. -- Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, Mobile VoiceMail (317) 663-0513 Home (no voice mail please) ** [[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. -- Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, Mobile VoiceMail (317) 663-0513 Home (no voice mail please) ** -- Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, Mobile VoiceMail (317) 663-0513 Home (no voice mail please) ** [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] figure margins too large for a barplot in png, pdf ok
On May 6, 2008, at 10:30 PM, Prof Brian Ripley wrote: What were H W? For png() they are (by default) in pixels, for pdf() in inches. You haven't told us your OS, but I guess Mac OS. Please update to R 2.7.0: that offers you two new png() devices for higher-quality plots, and various other improvements. (If you want to use the cairo-based png() at other than 72dpi, use R-patched or remember that the pointsize is mistakenly in pixels.) For some reason, R 2.6.2 on Mac OSX (indeed) stopped doing png at all, even for plot(1:10). I've been using a postcard printer with A5 size in between, was wondering if that affected things -- and changed that in Page Setup to US Letter, to no avail. H an W were 600 x 800, resp., and most importantly this same code worked with R 2.6.0 before... In any case, simply went and installed the 2.7.0, recompiled littler, and it all works fine now, just as before. (Hope the 4/22 build for Mac OSX incorporates Simon's recentmost fixes.) Thanks! Cheers, Alexy __ 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] use list elements to subtract values from the dataframe
Hi, I have a dataframe wf existing of a header with different labels and beneath the values of those labels : wf: label1 label2 ... 0,450,21 0,100,45 I have a list fl - c(label2,label3,..) Isn't possible to use the list elements in the list in order to subtract values from the dataframe? like : wf$fl[[1]] When I do in R I get :NULL fl[[1]] gives label2 so no problem here... While wf$label1 works fine. -- View this message in context: http://www.nabble.com/use-list-elements-to-subtract-values-from-the-dataframe-tp17098923p17098923.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Significance analysis of Microarrays (SAM)
Thanks Martin, I also posted the question on the bioconductor list but I have no reply yet. In the meanwhile I found out that instead of saying d=list(data.matrix2,y,censored) I should specify the arguments: d=list(x=data.matrix2,y=y,censoring.status=censored) Strange, huh? Anyway, it solves the problem. Thanks once again, Eleni On Tue, May 6, 2008 at 6:43 PM, Martin Morgan [EMAIL PROTECTED] wrote: Hi Eleni -- Although samr is not a Bioconductor package, you might have more luck asking on the Bioconductor mailing list, http://bioconductor.org. The obvious place to start, and probably you have already done this, is to ensure that the class of the objects passed to the function agree with the classes described on the function help page. Martin Eleni Christodoulou [EMAIL PROTECTED] writes: Dear list, I am trying to perform a significance analysis of a microarray experiment with survival data using the {samr} package. I have a matrix containing my data which has 17816 rows corresponding to genes, and 286 columns corresponding to samples. The name of this matrix is data.matrix2. Some of the first values of this matrix are: data.matrix2[1:3,1:5] GSM36777 GSM36778 GSM36779 GSM36780 GSM36781 [1,] 1.009274 1.0740659 1.048540 1.015946 1.022650 [2,] 1.007992 0.8768410 0.962442 1.111742 1.121150 [3,] 0.981853 0.9606492 1.024987 1.053302 1.063408 I also have the time in which each patient-sample is examined for relapse. This information is in vector y, which has length 286, and is declared in months. Indicatively: y[1:5] [1] 101 118 9 106 37 Finally, I have a variable censored, which is 1 if the patient has relapsed when examined at the examined time and 0 if not. Indicatively: censored[1:5] [1] 0 0 1 0 1 I am trying to perform the following sam analysis: d=list(data.matrix2,y,censored) samr.obj=samr(d,resp.type=Survival, nperms=20) When I am running the above commands I get the error: Error in check.format(y, resp.type = resp.type, censoring.status = censoring.status) : Error in input response data: response type Survival specified; error in censoring indicator In addition: Warning message: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL' I really cannot understand what is wrong with my code. Could anyone please help me with this? Thank you all, Eleni [[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. -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M2 B169 Phone: (206) 667-2793 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Solution of function
Hi, I want to find solution of function : f(x,y) = x'Cx - a under constraints : 0 x,y p 0 x-y q where a, p,q are given constants and x = (x, y) and C is a 2X2 matrix (given) Can anyone suggest me any R function to do that? - [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rggobi is crashing R-2.7.0
On Tue, May 6, 2008 at 11:11 PM, Mark Kimpel [EMAIL PROTECTED] wrote: Hard as it is for me to imagine, the ggobi windows stay open and functional while R (in emacs) has crashed in the background after throwing the error messages. As a perhaps naive Linux user, I thought that if a parent process crashed any processes it spawned would crash too. I guess not in this case. Well running it within Emacs may explain it. We actually aren't spawning a new GGobi process - just dynamically linking the GGobi library and starting it that way. Ubuntu currently is distributing graphviz 2.16.1 Do you have libgvc.so.3 on your system? Michael Thanks, Mark On Wed, May 7, 2008 at 12:14 AM, Michael Lawrence [EMAIL PROTECTED] wrote: On Tue, May 6, 2008 at 6:06 PM, Mark Kimpel [EMAIL PROTECTED] wrote: R crashed just after the warnings were issued, but ggobi kept running (if that makes sense). I am not sure if that makes sense; GGobi should exit when the R process does. I have Graphviz and Rgraphiz installed and use Rgraphviz regularly without a problem, so I'm not sure why it didn't load. Mark Which version of graphviz? I am not sure which version the Ubuntu binary expects, but this may be a binary compatibility issue. That said, I am not sure if the GraphLayout plugin is the reason for R crashing... On Tue, May 6, 2008 at 4:37 PM, Michael Lawrence [EMAIL PROTECTED] wrote: On Tue, May 6, 2008 at 10:32 AM, Mark Kimpel [EMAIL PROTECTED] wrote: I am running 64-bit Ubuntu 8.04 and when I invoke rggobi the interactive graph displays but R crashes. See my sessionInfo() and a short example below. Ggobi and rggobi installed without complaints. Mark sessionInfo() R version 2.7.0 Patched (2008-05-04 r45620) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rggobi_2.1.9 RGtk2_2.12.5-3 graph_1.18.0 loaded via a namespace (and not attached): [1] cluster_1.11.10 tools_2.7.0 a - matrix(rnorm(1000), nrow = 10) g - ggobi(a) ** (R:25146): CRITICAL **: Error on loading plugin library plugins/GraphLayout/plugin.la: libgvc.so.3: cannot open shared object file: No such file or directory ** (R:25146): CRITICAL **: Error on loading plugin library plugins/GraphLayout/plugin.la: libgvc.so.3: cannot open shared object file: No such file or directory ** (R:25146): CRITICAL **: can't locate required plugin routine addToToolsMenu in GraphLayout It's not clear to me - did R crash or did you just receive these warnings? These warnings are due to a missing graphviz, so the GraphLayout plugin fails to load. -- Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, Mobile VoiceMail (317) 663-0513 Home (no voice mail please) ** [[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. -- Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, Mobile VoiceMail (317) 663-0513 Home (no voice mail please) ** -- Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, Mobile VoiceMail (317) 663-0513 Home (no voice mail please) ** [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] i-best, grep function
Hi, I'm trying to use the i-best software. Does anyone have experience from this, I can't get it to work with my data. Here is the code: T1 - read.delim(file=S://SEDIM//Yvonne//2_5//T1.txt,col.names= c(Dye/Sample_Peak, Sample_File_Name, Size, Height, Area_in_Point, Area_in_BP, Data_Point, Begin_Point,Begin_BP, End_Point, End_BP, Width_in_Point, Width_in_BP, User_Comments, User_Edit)) T1 - subset(T1, Size 1000 Size 50) T1.B - cbind(T1[grep(^B, as.character(T1$Color),perl=T),3],T1[grep(^B, as.character(T1$Color),perl=T),5]) T1.B - cbind(T1.B, T1.B[,2]/sum(T1.B[,2])) It works alright until the last two lines. I try to grep the columns 3 and 5, but the outcome is T1.B [,1] [,2]. I don´t quite understand the code of as.character(t1$Color), perl=T. Could anyone please explane what this does, I havn´t found it anyware and I am so stuck. Maybe I'm doing something else wrong as well.. I would really appreciate some help, thank you. Yvonne _ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Installing A2R in Windows
Hello Kate, Sorry I've only seen that thread. I've not been using A2R for some time, and never really found the time to release it properly, in CRAN for example. I'll try to allocate some time to that. If you have the sufficient tools installed (http://www.murdoch-sutherland.com/Rtools/), installing the package on windows is very similar to installing it on linux. Cheers, Romain Prof Brian Ripley wrote: On Tue, 6 May 2008, Kate wrote: Thanks. I used the command you mention and it works fine in Linux. But I need to get it to work for Windows XP as well (currently running R-2.7.0). Any idea if it's possible? Yes, same commmand works -- I've just tested it. You need the tools installed, or to submit to Uwe Ligges' win-builder (mentioned in the manual). On Tue, May 6, 2008 at 5:18 PM, Prof Brian Ripley [EMAIL PROTECTED] wrote: How did you install it? You need to get A2R_0.0-4.tar.gz and do R CMD INSTALL A2R_0.0-4.tar.gz, after reading the 'R Installation and Administration manual, especially the sections for your OS. The package in A2R/lastVersion/ was built for Unix on R 2.2.1. An expert might be able to get it working, but we don't even know your OS and R version. On Tue, 6 May 2008, Kate wrote: Hi there, I've tried to install the A2R package using the files from http://addictedtor.free.fr/packages/A2R/lastVersion/ This is the error I get when trying to load the library: library(A2R) Error in library(A2R) : 'A2R' is not a valid package -- installed 2.0.0? Can anyone please help? Thanks. Kate [[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. PLEASE do read it. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Mango Solutions data analysis that delivers Tel: +44(0) 1249 76 77 00 Fax: +44(0) 1249 76 77 07 Mob: +44(0) 7813 52 61 23 __ 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] Regarding nls()
Spencer Graves: Bates' condemnation of R^2 has merit, but I would not go as far as he did in the comment cited below (dated 13 Aug 2000). A standard definition of R^2 is as follows: R^2 = (1 - var(prediction error) / var(obs)). I can name several different ways of getting a negative R^2 in this case. When that happens, it says the model is worse than useless, and you would be better off using the training set mean. If I have an audience who wants an R^2 in an application where it is not clear what it even means, I try to briefly explain some of the difficulties while asking what question they are trying to solve using R^2. Their answers will help me make a recommendation, which may include selecting which of the possible generalizations of R^2 to use. I would like to recommend the following two articles on R²: Model Comparisons and R² Richard Anderson-Sprecher The American Statistician, Vol. 48, No. 2. (May, 1994), pp. 113-117. http://www.jstor.org/stable/2684259 Cautionary Note about R² Tarald O. Kvalseth The American Statistician, Vol. 39, No. 4, (Nov., 1985), pp. 279-285. http://www.jstor.org/stable/2683704 -- Karl Ove Hufthammer __ 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] use list elements to subtract values from the dataframe
What you want is: wf[[fl[1]]] 'fl' is a vector, so you should only be using a single '[' for indexing. On Wed, May 7, 2008 at 3:20 AM, Dirkheld [EMAIL PROTECTED] wrote: Hi, I have a dataframe wf existing of a header with different labels and beneath the values of those labels : wf: label1 label2 ... 0,450,21 0,100,45 I have a list fl - c(label2,label3,..) Isn't possible to use the list elements in the list in order to subtract values from the dataframe? like : wf$fl[[1]] When I do in R I get :NULL fl[[1]] gives label2 so no problem here... While wf$label1 works fine. -- View this message in context: http://www.nabble.com/use-list-elements-to-subtract-values-from-the-dataframe-tp17098923p17098923.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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ 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] Fwd: Re: Solution of function
Forgot to send one copy to R help. Sorry Megh Dal [EMAIL PROTECTED] wrote: Date: Wed, 7 May 2008 02:45:09 -0700 (PDT) From: Megh Dal [EMAIL PROTECTED] Subject: Re: [R] Solution of function To: Berwin A Turlach [EMAIL PROTECTED] Hi Berwin, Thanks for having look on my problem. However on ipop() function I see following: ipop solves the quadratic programming problem : min(c'*x + 1/2 * x' * H * x) subject to: b = A * x = b + r l = x = u But my problem is not to find maxima or minima rather to get solution at that defined region. How to modify that function for my problem? Berwin A Turlach [EMAIL PROTECTED] wrote: G'day Megh, On Wed, 7 May 2008 01:11:34 -0700 (PDT) Megh Dal wrote: I want to find solution of function : f(x,y) = x'Cx - a under constraints : 0 x,y p 0 x-y q where a, p,q are given constants and x = (x, y) and C is a 2X2 matrix (given) Can anyone suggest me any R function to do that? ipop() in package kernlab solve.QP in package quadprog Depending on the form of C, package LowRankQP could also be of interest. HTH. Cheers, Berwin === Full address = Berwin A Turlach Tel.: +65 6515 4416 (secr) Dept of Statistics and Applied Probability +65 6515 6650 (self) Faculty of Science FAX : +65 6872 3919 National University of Singapore 6 Science Drive 2, Blk S16, Level 7 e-mail: [EMAIL PROTECTED] Singapore 117546 http://www.stat.nus.edu.sg/~statba - [[elided Yahoo spam]] - [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] unable to use functions require DLL from package base
Thanks, I had indeed several versions of R and removed the older ones and it worked. I suspect you have more than one version of R installed and are mixing them up. Those symbols have been in package stats for quite a while. Try starting R with --vanilla, and if that works, clean out your startup files (see ?Startup). If not, remove all your R installations and reinstall R 2.7.0 (or R-patched). -- View this message in context: http://www.nabble.com/unable-to-use-functions-require-DLL-from-package-%22base%22-tp17086783p17101073.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] i-best, grep function
T1 - read.delim(file=S://SEDIM//Yvonne//2_5//T1.txt,col.names= c(Dye/Sample_Peak, Sample_File_Name, Size, Height, Area_in_Point, Area_in_BP, Data_Point, Begin_Point, Begin_BP, End_Point, End_BP, Width_in_Point, Width_in_BP, User_Comments, User_Edit)) T1 - subset(T1, Size 1000 Size 50) T1.B - cbind(T1[grep(^B, as.character(T1$Color),perl=T),3], T1[grep(^B, as.character(T1$Color),perl=T),5]) T1.B - cbind(T1.B, T1.B[,2]/sum(T1.B[,2])) It works alright until the last two lines. I try to grep the columns 3 and 5, but the outcome is T1.B [,1] [,2]. I don´t quite understand the code of as.character(t1$Color), perl=T. T1 is a data frame, and T1$Color is one of the columns. as.character converts the column T1$Color from type factor to type character (i.e. a vector of strings). grep(^B, as.character(T1$Color),perl=T) means 'find all strings in the vector T1$Color that begin with the letter (capital) B'. ^B is an example of a regular expression. There is a very good guide to them here: http://www.regular-expressions.info/quickstart.html The relevant help pages in R are ?grep and ?regexp. Don't worry about the parameter perl=TRUE; there are subtle variations on regular expression syntax, and it just means that you follow PERL-style syntax. Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:21}} __ 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 do I write a power of matrices?? [was: How do I write a sum of matrixes??]
Jorge Ivan Velez wrote: I think the function could be better but try this: # Function: M is your matrix and n MUST be an integer0 mat.pow-function(M,n) { result-M if(n1){ for ( iter in 2:n) result-M%*%result result } else {result} result } There are much more efficient ways to compute a power, just check: http://en.wikipedia.org/wiki/Exponentiation_by_squaring Or, translating the pseudo-code to R: mat.pow - function(M, n) { result - diag(1, ncol(M)) while (n 0) { if (n %% 2 == 1) { result - result %*% M n - n - 1 } M - M %*% M n - n / 2 } return(result) } # The matrix m - rbind(c(1,1,0), c(0,1,1), c(0,0,1)) # Goal m^6 = m x m x m x m x m x m goal= m %*% m %*% m %*% m %*% m %*% m # matpow res=mat.pow(m,6) # Check point all.equal(goal,res) This algorithm would be fast, unless n is a _very_ big number. Alberto Monteiro __ 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] Aling elmentos into Windows with TK
Hello!! I would like create a window that has diferent element as: http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/checkboxes.html http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/radiobuttons.html I know as make it, but I don´t know as I could (align the diferent elemnts to left, right, top, bottom) or (put in a coordinates into windows). If anybody know as I could make it, I would like you say me. Thank you very much, Luismi A greetings -- View this message in context: http://www.nabble.com/Aling-elmentos-into-Windows-with-TK-tp17103275p17103275.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] i-best, grep function
[EMAIL PROTECTED] wrote: T1 - read.delim(file=S://SEDIM//Yvonne//2_5//T1.txt,col.names= c(Dye/Sample_Peak, Sample_File_Name, Size, Height, Area_in_Point, Area_in_BP, Data_Point, Begin_Point, Begin_BP, End_Point, End_BP, Width_in_Point, Width_in_BP, User_Comments, User_Edit)) T1 - subset(T1, Size 1000 Size 50) T1.B - cbind(T1[grep(^B, as.character(T1$Color),perl=T),3], T1[grep(^B, as.character(T1$Color),perl=T),5]) T1.B - cbind(T1.B, T1.B[,2]/sum(T1.B[,2])) It works alright until the last two lines. I try to grep the columns 3 and 5, but the outcome is T1.B [,1] [,2]. I don´t quite understand the code of as.character(t1$Color), perl=T. T1 is a data frame, and T1$Color is one of the columns. With all due respect: I think you missed the point: T1$Color is NOT one of the columns (look at the col.names). So T1$Color is NULL and things go downhill from there. But what is i-best This looks like a plain R issue. -p as.character converts the column T1$Color from type factor to type character (i.e. a vector of strings). grep(^B, as.character(T1$Color),perl=T) means 'find all strings in the vector T1$Color that begin with the letter (capital) B'. ^B is an example of a regular expression. There is a very good guide to them here: http://www.regular-expressions.info/quickstart.html The relevant help pages in R are ?grep and ?regexp. Don't worry about the parameter perl=TRUE; there are subtle variations on regular expression syntax, and it just means that you follow PERL-style syntax. Regards, Richie. Mathematical Sciences Unit HSL -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@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] list manipulation
Beautiful! Thanks Jim. DaveT. -Original Message- From: jim holtman [mailto:[EMAIL PROTECTED] Sent: May 6, 2008 07:33 PM To: Thompson, David (MNR) Subject: Re: [R] list manipulation The reason for the NULLs is that is the output of the lapply you are executing. If you don't want to see the value, then use 'invisible' or assign to an object since you are executing this at the command level, the default is to print the value. invisible(lapply(...)) On Tue, May 6, 2008 at 2:35 PM, Thompson, David (MNR) [EMAIL PROTECTED] wrote: Hello, I have a set of one-liners (many thanks to previous responses from this list) that I use to look at newly imported data sets with functions like dim(), names(), str(), etc. within lapply(). Generally, these commands work for me but, I am apparently still missing some aspect of list manipulation. I don't understand why I get a set of NULL list elements at the end of each output as demonstrated below. How can I generate this (and similar) result(s) without all the trailing NULLs? lapply(ls(pattern='bn'), function(x) cat(x, dim(get(x)), \t, names(get(x)), \n)) bn1993 2885 11 oplt rplt rsiz tree bd ht oaz odst raz rdst spr bn1994 3158 7oplt tree bd ht spr stat dam bn1995 734 7 oplt tree bd ht spr stat dam bn1996 293 7 oplt tree bd ht spr stat dam bn1997 264 7 oplt tree bd ht spr stat dam bn1998 768 7 oplt tree bd ht spr stat dam bn1999 654 7 oplt tree bd ht dbh stat dam bn2003 1407 9oplt tree bd94 ht94 ht99 ht02 ht03 stat dam [[1]] NULL [[2]] NULL [[3]] NULL [[4]] NULL [[5]] NULL [[6]] NULL [[7]] NULL [[8]] NULL Thanx, DaveT. * Silviculture Data Analyst Ontario Forest Research Institute Ontario Ministry of Natural Resources [EMAIL PROTECTED] http://ofri.mnr.gov.on.ca __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ 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] Citation in the literature
Hello everyone, Very quick question: How should I cite the use of R in a publication ? Thanks in advance. Sebastien __ 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] Citation in the literature
citation() To cite R in publications use: R Development Core Team (2008). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. ISBN 3-900051-07-0, URL http://www.R-project.org. A BibTeX entry for LaTeX users is @Manual{, title = {R: A Language and Environment for Statistical Computing}, author = {{R Development Core Team}}, organization = {R Foundation for Statistical Computing}, address = {Vienna, Austria}, year = {2008}, note = {{ISBN} 3-900051-07-0}, url = {http://www.R-project.org}, } We have invested a lot of time and effort in creating R, please cite it when using it for data analysis. See also 'citation(pkgname)' for citing R packages. On Wed, May 7, 2008 at 9:03 PM, Sébastien [EMAIL PROTECTED] wrote: Hello everyone, Very quick question: How should I cite the use of R in a publication ? Thanks in advance. Sebastien __ 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. -- HUANG Ronggui, Wincent Bachelor of Social Work, Fudan University, China Master of sociology, Fudan University, China Ph.D. Candidate, CityU of HK, http://www.cityu.edu.hk/sa/psa_web2006/students/rdegree/huangronggui.html __ 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] Citation in the literature
Sébastien wrote: Hello everyone, Very quick question: How should I cite the use of R in a publication ? Thanks in advance. Sebastien See the FAQs: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Citing-R This is also referenced in the startup banner in an R console: ... R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. ... HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] fft: characteristic function to distribution
Thank you Prof Ripley for your answer. The characteristic function is the inverse Fourier transform of the distribution function. The characteristic function of a normaly distributed random variable is exp(-t^2/2). The fft is a discrete Fourier transforn, not a continuous one. This is correct. I try to approximate the continous normal distribution with infinite support by a set of discrete and bounded points. A real discrete baby example would be the bernoulli distribution: p=0.4 t=seq(-0.01,1.001,length=100) char=1-p+p*exp(1i*t) cdf=stepfun(c(0,1),c(0,1-p,1)) plot(t,cdf(t),type=l,col=red,ylim=range(cdf(t),Re(fft(char)[2:99]))) lines(t,fft(char),col=blue) This is more or less like the normal example. Further in each case where the normalizing constants are placed and the units of frequecy differ from source to source. ?fft has references to exactly what it computes: please consult them. I read the documentation/help page. More details there would be helpful. For example an example (it says example*s*) something where explicit expressions are known (as I tried it here). Another possible improvement could be to make for example the following sentence nicer/clearer: (the inverse has a + in the exponent of e, but here, we do not divide by 1/length(x)). I did not consult the two given references (two old but surely valuable books). Enough prattled. Can you give a working example where the cummulative distribution function and the fourier transform are explicitly known? I cannot add any value neither to wonderful R nor to this helpful function. But perhaps my question isn't that stupid and you can give a hint to proceed. Thank you very much in advance, Thomas __ 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] CRAN and Multiple Linear Regression
Hello I have to solve a multiple linear regression. Most programs like Excel or Mathlab only support 5-10 dimensions. Now I have installed CRAN and I have no clue what to do next. At the moment I am entering my data into an excelsheet (for quick copy- paste). The Y-array will be 20 columns (=dimensions) and 128 rows (=variables). The X-array may also be 128 rows in Excel. Which package do I need - or does it work without any package? What commands do I have to enter? I'm not familiar with CRAN and I didn't find any example. Best regards, Thomas __ 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] Not to draw the xaxis ticks in ggplot2
On Tue, May 6, 2008 at 11:44 PM, ronggui [EMAIL PROTECTED] wrote: library(ggplot2) (p- qplot(mpg, wt, data=mtcars)) What I am doing is to set color of the ticks to hide them. grid.gedit(gPath(xaxis, ticks), gp=gpar(col=white)) It should be a better way to achieve the purpose. Thanks. Agreed. I've added it to my ggplot2 customisation to do list. Thanks, Hadley -- http://had.co.nz/ __ 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] categorical data analysis
The last example in ?fisher.test is not a 2x2 table, in fact it uses levels with a natural ordering similar to the original question. Why would this not be applicable to the situation? From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of David Winsemius [EMAIL PROTECTED] Sent: Wednesday, May 07, 2008 7:34 AM To: [EMAIL PROTECTED] Subject: Re: [R] categorical data analysis Simon Blomberg [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: But see these posts: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/119079.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/119080.html Simon. Interesting reading, but the OP specifically said he was not dealing with 2x2 tables, so neither fisher.test nor the suggested alternatives would be applicable to his data situation. -- David Winsemius __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Solution of function
Megh Dal wrote: Hi, I want to find solution of function : f(x,y) = x'Cx - a under constraints : 0 x,y p 0 x-y q where a, p,q are given constants and x = (x, y) and C is a 2X2 matrix (given) Can anyone suggest me any R function to do that? Not likely. What you have (if C is positive definite) is the intersection between the boundary of an ellipse and the interior of a parallelepiped, where the center of the ellipse and one corner of the parallelepiped is at (0,0). This is the union of between zero and three curve segments (hmm, maybe only two) and I don't think any of the standard solvers and minimizers can come up with that kind of result. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@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] CRAN and Multiple Linear Regression
Multiple linear regression is handled by the function lm() in the default installation of R. This takes inputs as lm(y~x1+x2+x3). If you're going to be using R regularly, there are several books which cover the basic statistical analyses available in R (and then some), including those by Peter Daalgard and by Brian Ripley, who are very regular contributors to this list. Abhijit Anja und Th. Sponsel wrote: Hello I have to solve a multiple linear regression. Most programs like Excel or Mathlab only support 5-10 dimensions. Now I have installed CRAN and I have no clue what to do next. At the moment I am entering my data into an excelsheet (for quick copy- paste). The Y-array will be 20 columns (=dimensions) and 128 rows (=variables). The X-array may also be 128 rows in Excel. Which package do I need - or does it work without any package? What commands do I have to enter? I'm not familiar with CRAN and I didn't find any example. Best regards, Thomas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplo2: x_discrete labels size/direction
PS Perhaps it'd still be really useful to be able to change text direction in labels. Hadley, what do you think? Agreed. I've added it to my ggplot2 customisation to do list. Thanks, Hadley -- http://had.co.nz/ __ 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] Importing data
First step would be to read the manual on the R site R Data Import/Export describes the import and export facilities available either in R itself or via packages which are available from CRAN Then if that does not solve the problem you need to explain in detail what the problems are, preferably with the code that you are using. See the instructions at the bottom of the post. --- Yemi Oyeyemi [EMAIL PROTECTED] wrote: Hi everyone, please I'm having problem importing data from Stata and excel. Help me out. Thanks - [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] p values for polychor
hello, i have been using cor.test() for calculating the correlation coefficient and p values for some data. however, since the data consist of two dichotomous sequences (actually just binary data), i understand that simply using the pearson correlation is not sufficient. however, having done a bit of research i found that the tetrachoric correlation is what i am after. found the polycor package and the polychor routine, which seem to do precisely what i want. however, i don't get p values out of polychor, just the standard deviation. so, in a rather naive way i have tried to write a function which will return a list with similar fields as what one gets from cor.test(). not being terribly strong with statistics though, i am not sure whether this is entirely correct. could someone tell me if i am on the right track... or point out where i am going wrong? tetrachoric.test - function(x, y) { p - polychor(x, y, std.err = TRUE) # p$statistic - p$rho / sqrt(c(p$var)) # p$estimate - p$rho p$p.value = 2 * (1 - pnorm(abs(p$statistic))) p } the assumption is that the p value is the integration of the two tails of the distribution? x - as.integer(runif(20) 0.5) y - as.integer(runif(20) 0.5) p - tetrachoric.test(x, y) p$statistic [1] -0.2616866 p$p.value [1] 0.7935631 p$var [,1] [1,] 0.1452105 thanks for any help! best regards, andrew. __ 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] categorical data analysis
Greg Snow [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: The last example in ?fisher.test is not a 2x2 table, in fact it uses levels with a natural ordering similar to the original question. Why would this not be applicable to the situation? Apologies. Clearly I misunderstood the R implementation. My parsing of the fisher.test code (influenced by having just read the Campbell article) lead me to erroneously conclude that it was only applicable to 2x2 tables. I see now that the error message says _at_least_ 2 rows and columns and that the error check is an inquality. -- David Winsemius From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of David Winsemius [EMAIL PROTECTED] Sent: Wednesday, May 07, 2008 7:34 AM To: [EMAIL PROTECTED] Subject: Re: [R] categorical data analysis Simon Blomberg [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: But see these posts: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/119079.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/119080.html Simon. Interesting reading, but the OP specifically said he was not dealing with 2x2 tables, so neither fisher.test nor the suggested alternatives would be applicable to his data situation. -- David Winsemius __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Importing data
i usually import data from exel, using read.table or read.csv (which implies that i have to save exel files as .txt or .csv) JM El Miércoles, 7 de Mayo de 2008 11:25, John Kane escribió: First step would be to read the manual on the R site R Data Import/Export describes the import and export facilities available either in R itself or via packages which are available from CRAN Then if that does not solve the problem you need to explain in detail what the problems are, preferably with the code that you are using. See the instructions at the bottom of the post. --- Yemi Oyeyemi [EMAIL PROTECTED] wrote: Hi everyone, please I'm having problem importing data from Stata and excel. Help me out. Thanks - [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] CRAN and Multiple Linear Regression
Abhijit Dasgupta wrote: Multiple linear regression is handled by the function lm() in the default installation of R. This takes inputs as lm(y~x1+x2+x3). If you're going to be using R regularly, there are several books which cover the basic statistical analyses available in R (and then some), including those by Peter Daalgard and by Brian Ripley, who are very regular contributors to this list. Thanks for saving me a shameless plug (notice that the double a comes last, though...). For people just out to get their feet wet, there's also a collection of shorter and longer documents in the contributed section on CRAN, http://cran.r-project.org/other-docs.html . I particularly like Jason Owen's The R Guide as a kickstart document. As far as I can tell, you can just skip things that rely on math that you haven't heard of (such as matrix algebra) without getting lost. -pd Abhijit Anja und Th. Sponsel wrote: Hello I have to solve a multiple linear regression. Most programs like Excel or Mathlab only support 5-10 dimensions. Now I have installed CRAN and I have no clue what to do next. At the moment I am entering my data into an excelsheet (for quick copy- paste). The Y-array will be 20 columns (=dimensions) and 128 rows (=variables). The X-array may also be 128 rows in Excel. Which package do I need - or does it work without any package? What commands do I have to enter? I'm not familiar with CRAN and I didn't find any example. Best regards, Thomas __ 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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@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] Importing data
Yemi Oyeyemi wrote: Hi everyone, please I'm having problem importing data from Stata and excel. Help me out. Thanks You don't provide... a) the code that you've tried b) the error message that relates to the problem you are having ...without these people have little information on what _exactly_ your problem is. Please read the R-help posting guide as advised in the signature of every mail that appears on the list. For clarity its... PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. In this instance you would also do well to read the R Data Import/Export manual at http://cran.r-project.org/doc/manuals/R-data.html and pay particular attention to section 3 titled Importing from other Statistical Systems (http://cran.r-project.org/doc/manuals/R-data.html#Importing-from-other-statistical-systems). This would lead you to the read.dta() and write.dta() functions for respectively reading and writing Stata formatted data sets. Neil -- View this message in context: http://www.nabble.com/Importing-data-tp17104951p17106184.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Importing data
import stata data should be straight. take a look at foreign package On Wed, May 7, 2008 at 9:30 AM, Yemi Oyeyemi [EMAIL PROTECTED] wrote: Hi everyone, please I'm having problem importing data from Stata and excel. Help me out. Thanks - [[elided Yahoo spam]] [[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. -- === WenSui Liu ChoicePoint Precision Marketing Phone: 678-893-9457 Email : [EMAIL PROTECTED] Blog : statcompute.spaces.live.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] use of sequence on ridge regression
What do you mean by 'the sequence option'? The authot of lm.ridge On Wed, 7 May 2008, Rodrigo Briceño wrote: Dear R users. I have a doubt about the use of the sequence option on Ridge regression. I'm trying to understand the use of this option when variables are highly linear correlated. I'm running a model where the variables HtShoes and Ht have high VIF values. My program is written below, but I'm not sure about the correct way of using the sequence option: library (faraway) data (seatpos) attach (seatpos) spos.mod - lm(hipcenter ~ .,seatpos) summary (spos.mod) library(MASS) lm.ridge(hipcenter ~ .,seatpos) plot(lm.ridge(hipcenter ~ .,seatpos, lambda = seq(0,0.1,0.001))) select(lm.ridge(hipcenter ~ ., seatpos,lambda = seq(0,0.1,0.001))) Any advice will be appreaciated. Rodrigo B. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] function in nls argument
Greetings R users, maybe there is someone who can help me with this problem: I define a function optim.fun and want as output the sum of squared errors between predicted and measured values, as follows: optim.fun - function (ST04, SM08b, ch2no, a, b, d, E) { predR - (a*SM08b^I(2)+b*SM08b+d)*exp(E*((1/(283.15-227.13))-(1/(ST04+273.15-227.13 abserr - abs(ch2no-predR) qnum - quantile(abserr, probs=0.95, na.rm=T) is.na(abserr) - (abserr qnum) errsq - sum(abserr^2, na.rm=T) errsq } Then I want to optimize parameters a,b,d and E as to minimize the function output with the following: optim.model-nls(nulldat ~ optim.fun(ST04, SM08b, ch2no, a, b, d, E), data=tower, start=list(a=-0.003,b=0.13,d=0.50, E=400), na.action = na.exclude ) were nulldat=0 At this point I get the following error message: Error in qr.default(.swts * attr(rhs, gradient)) : NA/NaN/Inf in foreign function call (arg 1) Warning messages: 1: In if (na.rm) x - x[!is.na(x)] else if (any(is.na(x))) stop(missing values and NaN's not allowed if 'na.rm' is FALSE) ... : the condition has length 1 and only the first element will be used (this warning is repeated 12 times) Question: what does the error mean? What am I doing wrong? Thanks a bunch. Nano Jen, Germany Max Planck for Biogeochemistry [[elided Yahoo spam]] __ 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] categorical data analysis - fisher.exact for 2x2 and greater
Hi Simon and all, I'm pretty sure that you are correct about this. I think it is a misconception to say that the fisher exact test is only for a 2 by 2 table. It is presented that way in textbooks because, for a 2x2 table, it is easy to perform. For larger tables, it becomes complex quickly due to the rate at which the permutations increase. When I use it for larger tables, it is hit or miss as to whether R will be able to do it. It's not uncommon to get an error implying that R is out of memory. Check out Agresti's Categorical Data Analysis on the use of the fisher exact for larger than 2x2 tables, and check out the R archives (and Google search) for all the posts about the error message people run into sometimes. On April 29th, Marc Schwartz replied to my question about this as follows: Take a look at the 'workspace' argument in ?fisher.test and review the second paragraph in Details: For 2 by 2 cases, p-values are obtained directly using the (central or non-central) hypergeometric distribution. Otherwise, computations are based on a C version of the FORTRAN subroutine FEXACT which implements the network developed by Mehta and Patel (1986) and improved by Clarkson, Fan and Joe (1993). The FORTRAN code can be obtained from http://www.netlib.org/toms/643. Note this fails (with an error message) when the entries of the table are too large. (It transposes the table if necessary so it has no more rows than columns. One constraint is that the product of the row marginals be less than 2^31 - 1.) Thank you, Jeff -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greg Snow Sent: Wednesday, May 07, 2008 9:55 AM To: David Winsemius; [EMAIL PROTECTED] Subject: Re: [R] categorical data analysis The last example in ?fisher.test is not a 2x2 table, in fact it uses levels with a natural ordering similar to the original question. Why would this not be applicable to the situation? From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of David Winsemius [EMAIL PROTECTED] Sent: Wednesday, May 07, 2008 7:34 AM To: [EMAIL PROTECTED] Subject: Re: [R] categorical data analysis Simon Blomberg [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: But see these posts: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/119079.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/119080.html Simon. Interesting reading, but the OP specifically said he was not dealing with 2x2 tables, so neither fisher.test nor the suggested alternatives would be applicable to his data situation. -- David Winsemius __ 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. Internal Virus Database is out-of-date. 11:27 AM Internal Virus Database is out-of-date. 11:27 AM __ 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] predict lmer
Hi, I am using lmer to analyze habitat selection in wolverines using the following model: (me.fit.of - lmer(USED~1+STEP+ALT+ALT2+relM+relM:ALT+(1|ID)+(1|ID:TRKPT2),data=vdata, control=list(usePQL=TRUE),family=poisson,method=Laplace)) Here, the habitat selection is calaculated using a so-called discrete choice model where each used location has a certain number of alternatives which the animal could have chosen. These sets of locations are captured using the TRKPT2 random grouping. However, these sets are also clustered over the different individuals (ID). USED is my binary dependent variable which is 1 for used locations and zero for unused locations. The other are my predictors. I would like to predict the model fit at different values of the predictors, but does anyone know whether it is possible to do this? I have looked around at the R-sites and in help but it seems that there doesn't exist a predict function for lmer??? I hope someone can help me with this; point me to the right functions or tell me to just forget it Thanks in advance! Cheers Roel Roel May Norwegian Institute for Nature Research Tungasletta 2, NO-7089 Trondheim, Norway [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] use of sequence on ridge regression
Nice to meet you Brian. The question is about the numbers that appears after lambda (0,0, 0.1, 0.0001). I know that seq is a set of values used for testing which value fits best. But I'm not sure if I need to put whatever I think or what. I tried also with a set of 5 values and I get an error. Is there a maximum allowed? plot(lm.ridge(hipcenter ~ .,seatpos, lambda = seq(0,0.1,0.001))) select(lm.ridge(hipcenter ~ ., seatpos,lambda = seq(0,0.1,0.001))) __ *Rodrigo Briceño* Project Manager Sanigest Internacional +506 22-91-12-00 ext. 113 * Oficina* *Costa Rica* +506 22-32-08-30 *Fax *+506 88-86-11-77* Celular** [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] www.sanigest.com http://www.sanigest.com/ MSN: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] SKYPE: rbriceno1087 _ This communication contains legal information which is privileged and confidential. It is for the exclusive use of the address and distribution, dissemination, copying or use by others is strictly prohibited. If you have received this communication by error, please delete the original message and e-mail us. Esta comunicación contiene información legal privilegiada y confidencial para el uso exclusivo del destinatario. La distribución, diseminación, copia u otro uso por terceras personas es estrictamente prohibida. Si usted ha recibido esta comunicación por error, le rogamos borrar el mensaje original y comunicárnoslo a esta misma dirección. Prof Brian Ripley wrote: What do you mean by 'the sequence option'? The authot of lm.ridge On Wed, 7 May 2008, Rodrigo Briceño wrote: Dear R users. I have a doubt about the use of the sequence option on Ridge regression. I'm trying to understand the use of this option when variables are highly linear correlated. I'm running a model where the variables HtShoes and Ht have high VIF values. My program is written below, but I'm not sure about the correct way of using the sequence option: library (faraway) data (seatpos) attach (seatpos) spos.mod - lm(hipcenter ~ .,seatpos) summary (spos.mod) library(MASS) lm.ridge(hipcenter ~ .,seatpos) plot(lm.ridge(hipcenter ~ .,seatpos, lambda = seq(0,0.1,0.001))) select(lm.ridge(hipcenter ~ ., seatpos,lambda = seq(0,0.1,0.001))) Any advice will be appreaciated. Rodrigo B. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help with the unique function
Hi, The unique function is easy to understand and use. Beyond that, I want to get also the frequency of repetition of each individual row in a data frame Let me explain with an example : x-data.frame(a=c(1,2,3,1,2),b=c(2,3,4,2,3),c=c(10,20,30,10,20)) xu-unique(x) We have, x a b c 1 1 2 10 2 2 3 20 3 3 4 30 4 1 2 10 5 2 3 20 xu a b c 1 1 2 10 2 2 3 20 3 3 4 30 I want to get the following data frame : a b c Freq 1 1 2 10 2 2 2 3 20 2 3 3 4 30 1 That is, in addition to the unique rows, I want to get the frequency of repetion of each individual row. I will appreciate all the help that I can get. Thank You, Ravi __ 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] help with the unique function
Hi Ravi, Try this: x-data.frame(a=c(1,2,3,1,2),b=c(2,3,4,2,3),c=c(10,20,30,10,20)) cbind(unique(x),lapply(x,table)$c)[,-4] a b c Freq 1 1 2 102 2 2 3 202 3 3 4 301 HTH, Jorge On Wed, May 7, 2008 at 12:11 PM, ravi [EMAIL PROTECTED] wrote: Hi, The unique function is easy to understand and use. Beyond that, I want to get also the frequency of repetition of each individual row in a data frame Let me explain with an example : x-data.frame(a=c(1,2,3,1,2),b=c(2,3,4,2,3),c=c(10,20,30,10,20)) xu-unique(x) We have, x a b c 1 1 2 10 2 2 3 20 3 3 4 30 4 1 2 10 5 2 3 20 xu a b c 1 1 2 10 2 2 3 20 3 3 4 30 I want to get the following data frame : a b cFreq 1 1 2 102 2 2 3 202 3 3 4 301 That is, in addition to the unique rows, I want to get the frequency of repetion of each individual row. I will appreciate all the help that I can get. Thank You, Ravi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with the unique function
ravi - This may get you started count.reps - function(df) { hash - do.call(paste, c(df, sep = \r)) cbind(unique(df), Freq = unclass(table(hash))) } test - data.frame(a = rep(1:10, 2), b = rep(1:10, 2)) count.reps(test) Best, Erik Iverson ravi wrote: Hi, The unique function is easy to understand and use. Beyond that, I want to get also the frequency of repetition of each individual row in a data frame Let me explain with an example : x-data.frame(a=c(1,2,3,1,2),b=c(2,3,4,2,3),c=c(10,20,30,10,20)) xu-unique(x) We have, x a b c 1 1 2 10 2 2 3 20 3 3 4 30 4 1 2 10 5 2 3 20 xu a b c 1 1 2 10 2 2 3 20 3 3 4 30 I want to get the following data frame : a b cFreq 1 1 2 102 2 2 3 202 3 3 4 301 That is, in addition to the unique rows, I want to get the frequency of repetion of each individual row. I will appreciate all the help that I can get. Thank You, Ravi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with the unique function
ravi wrote: Hi, The unique function is easy to understand and use. Beyond that, I want to get also the frequency of repetition of each individual row in a data frame Let me explain with an example : x-data.frame(a=c(1,2,3,1,2),b=c(2,3,4,2,3),c=c(10,20,30,10,20)) xu-unique(x) We have, x a b c 1 1 2 10 2 2 3 20 3 3 4 30 4 1 2 10 5 2 3 20 xu a b c 1 1 2 10 2 2 3 20 3 3 4 30 I want to get the following data frame : a b cFreq 1 1 2 102 2 2 3 202 3 3 4 301 That is, in addition to the unique rows, I want to get the frequency of repetion of each individual row. I will appreciate all the help that I can get. Thank You, Ravi As usual in R, there are several options: table(apply(x, 1, paste, collapse = ,)) 1,2,10 2,3,20 3,4,30 2 2 1 or: table(interaction(x, sep = ,, drop = TRUE)) 1,2,10 2,3,20 3,4,30 2 2 1 So: cbind(unique(x), Freq = as.vector(table(apply(x, 1, paste, collapse = , a b c Freq 1 1 2 102 2 2 3 202 3 3 4 301 or: cbind(unique(x), Freq = as.vector(table(interaction(x, sep = ,, drop = TRUE a b c Freq 1 1 2 102 2 2 3 202 3 3 4 301 HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] PC configuration you are using
Hello, As I mentioned in the previous message we are developing solution for wholesale companies to analyze their sales transactions by associative rules. I would very much appreciated if the community could give us some hint of what is a typical PC configuration of a professional statist (processor, RAM, HDD...)? Thanks a lot in advance and I highly appreciate your feedback! Kind regards, endre -- Endre Domiczi, CEO Sevana Oy, http://www.sevana.fi Email : [EMAIL PROTECTED] GSM : +372 53485178 Skype : emddom __ 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] Solution of function
I think I should be clear exactly what I want : take following example : a = b = seq(1, 5, by=500) v = matrix(0, nrow=length(a), ncol=length(a)) for (i in 1:length(a)) { for (j in 1:length(a)) { d = c(17989*a[i], -18109*b[j]) v[i,j] = t(d) %*% matrix(c(0.0001741, 0.0001280, 0.0001280, 0.0002570), nrow=2) %*% d } } library(rgl) open3d() persp3d(a,b,v,col=green,alpha=0.7,aspect=c(1,1,0.5)) shade - outer(a, b, function(x,y) (0 (x-y)) ((x-y) 2)) persp3d(a,b,v,col=ifelse(shade, red, green), alpha=0.7,aspect=c(1,1,0.5)) Here you see that the surface is the plot of a x'Cx for different values of components of x. And the red region is the portion of that plot that satisfy 0 x-y 2.. Now suppose user choose a point on red portion of that surface. Now I have to tell (through some computationally efficient way) what is the corresponding component values of x. Any suggestion please? Peter Dalgaard [EMAIL PROTECTED] wrote: Megh Dal wrote: Hi, I want to find solution of function : f(x,y) = x'Cx - a under constraints : 0 x,y p 0 x-y q where a, p,q are given constants and x = (x, y) and C is a 2X2 matrix (given) Can anyone suggest me any R function to do that? Not likely. What you have (if C is positive definite) is the intersection between the boundary of an ellipse and the interior of a parallelepiped, where the center of the ellipse and one corner of the parallelepiped is at (0,0). This is the union of between zero and three curve segments (hmm, maybe only two) and I don't think any of the standard solvers and minimizers can come up with that kind of result. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 - [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to define .Renviron to work with different R-versions
Hi, I have a simple R script for printing arguments cat printargs.R EOF args = commandArgs() print(args) q() EOF To run this script, first I set PATH to ~/src/R-2.6.2 and execute R --no-save printargs.R I want to run this script with different R versions by defining an .Renviron file in the same directory as printargs.R cat .Renviron EOF R_VERISON=R-2.7.0 R_HOME=~/src/${R_VERSION} PATH=${R_HOME}/bin:${PATH} R_LIBS=${R_HOME}/library EOF Now when I run R --no-save printargs.R, I get Error in gzfile(file, rb) : cannot open the connection In addition: Warning message: In gzfile(file, rb) : cannot open compressed file '/home/ppreddy/src//library/base/R/base.rdx', probable reason 'No such file or directory' Execution halted I do not know for sure, if I can define R_VERSION, R_HOME, and PATH in .Renviron. All I have seen is defining R_LIBS/JAV_HOME in r-help archives. So, please explain how to use the .Renviron to work with R-different R-versions and also Should I place .Renviron in the home dir instead of cwd? Thanks, Poornima. __ 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] help with the unique function
On 07-May-08 16:31:23, Erik Iverson wrote: ravi - This may get you started count.reps - function(df) { hash - do.call(paste, c(df, sep = \r)) cbind(unique(df), Freq = unclass(table(hash))) } test - data.frame(a = rep(1:10, 2), b = rep(1:10, 2)) count.reps(test) That doesn't work: It muddles the Association of the unique values with the counts: A-sample(c(0,1),100,replace=TRUE) B-sample(c(0,1),100,replace=TRUE) C-sample(c(0,1),100,replace=TRUE) sum((A==0)(B==0)(C==0)) ## [1] 26 sum((A==0)(B==0)(C==1)) ## [1] 9 sum((A==0)(B==1)(C==0)) ## [1] 10 sum((A==0)(B==1)(C==1)) ## [1] 7 sum((A==1)(B==0)(C==0)) ## [1] 15 sum((A==1)(B==0)(C==1)) ## [1] 11 sum((A==1)(B==1)(C==0)) ## [1] 5 sum((A==1)(B==1)(C==1)) ## [1] 17 test-data.frame(A=A,B=B,C=C) count.reps(test) #A B C Freq # 1 0 0 1 26 # 2 0 1 09 # 3 1 0 1 10 # 4 1 0 07 # 5 1 1 1 15 # 6 0 0 0 11 #14 1 1 05 #25 0 1 1 17 So the freqencies come out in the order I found them (binary counting: ABC=000,001,010,011,100,101,110,111) but with the (A,B,C) values in a quite different order. I can't, myself, make out why this is happening, but no doubt someone else can, and may sugest a correction! Ted. Best, Erik Iverson ravi wrote: Hi, The unique function is easy to understand and use. Beyond that, I want to get also the frequency of repetition of each individual row in a data frame Let me explain with an example : x-data.frame(a=c(1,2,3,1,2),b=c(2,3,4,2,3),c=c(10,20,30,10,20)) xu-unique(x) We have, x a b c 1 1 2 10 2 2 3 20 3 3 4 30 4 1 2 10 5 2 3 20 xu a b c 1 1 2 10 2 2 3 20 3 3 4 30 I want to get the following data frame : a b cFreq 1 1 2 102 2 2 3 202 3 3 4 301 That is, in addition to the unique rows, I want to get the frequency of repetion of each individual row. I will appreciate all the help that I can get. Thank You, Ravi __ 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. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 07-May-08 Time: 18:02:09 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] predict lmer
?fixef gets you the coefficient vector, from which you can make your predictions. -- Bert Gunter Genentech -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of May, Roel Sent: Wednesday, May 07, 2008 7:23 AM To: r-help@r-project.org Subject: [R] predict lmer Hi, I am using lmer to analyze habitat selection in wolverines using the following model: (me.fit.of - lmer(USED~1+STEP+ALT+ALT2+relM+relM:ALT+(1|ID)+(1|ID:TRKPT2),data=vdata, control=list(usePQL=TRUE),family=poisson,method=Laplace)) Here, the habitat selection is calaculated using a so-called discrete choice model where each used location has a certain number of alternatives which the animal could have chosen. These sets of locations are captured using the TRKPT2 random grouping. However, these sets are also clustered over the different individuals (ID). USED is my binary dependent variable which is 1 for used locations and zero for unused locations. The other are my predictors. I would like to predict the model fit at different values of the predictors, but does anyone know whether it is possible to do this? I have looked around at the R-sites and in help but it seems that there doesn't exist a predict function for lmer??? I hope someone can help me with this; point me to the right functions or tell me to just forget it Thanks in advance! Cheers Roel Roel May Norwegian Institute for Nature Research Tungasletta 2, NO-7089 Trondheim, Norway [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] predict lmer
Sorry, my reply below may be too terse. You'll need to also construct the appropriate design matrix to which to apply the fixef() results to. If newDat is a data.frame containing **exactly the same named regressor and response columns** as your original vdata dataframe, and if me.fit.of is your fitted lmer object as you have defined it below, then model.matrix(terms(me.fit.of),newDat) %*% fixef(me.fit.of) gives your predictions. Note that while the response column in newDat is obviously unnecessary for prediction (you can fill it with 0's,say), it is nevertheless needed for model.matrix to work. This seems clumsy to me, so there may well be better ways to do this, and **I would appreciate suggestions for improvement.*** Cheers, Bert -Original Message- From: bgunter Sent: Wednesday, May 07, 2008 9:53 AM To: May, Roel; r-help@r-project.org Subject: RE: [R] predict lmer ?fixef gets you the coefficient vector, from which you can make your predictions. -- Bert Gunter Genentech -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of May, Roel Sent: Wednesday, May 07, 2008 7:23 AM To: r-help@r-project.org Subject: [R] predict lmer Hi, I am using lmer to analyze habitat selection in wolverines using the following model: (me.fit.of - lmer(USED~1+STEP+ALT+ALT2+relM+relM:ALT+(1|ID)+(1|ID:TRKPT2),data=vdata, control=list(usePQL=TRUE),family=poisson,method=Laplace)) Here, the habitat selection is calaculated using a so-called discrete choice model where each used location has a certain number of alternatives which the animal could have chosen. These sets of locations are captured using the TRKPT2 random grouping. However, these sets are also clustered over the different individuals (ID). USED is my binary dependent variable which is 1 for used locations and zero for unused locations. The other are my predictors. I would like to predict the model fit at different values of the predictors, but does anyone know whether it is possible to do this? I have looked around at the R-sites and in help but it seems that there doesn't exist a predict function for lmer??? I hope someone can help me with this; point me to the right functions or tell me to just forget it Thanks in advance! Cheers Roel Roel May Norwegian Institute for Nature Research Tungasletta 2, NO-7089 Trondheim, Norway [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with the unique function
Another way to produce the data frame is subset(as.data.frame(table(x)),Freq0) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley [EMAIL PROTECTED] On Wed, 7 May 2008, ravi wrote: Hi, The unique function is easy to understand and use. Beyond that, I want to get also the frequency of repetition of each individual row in a data frame Let me explain with an example : x-data.frame(a=c(1,2,3,1,2),b=c(2,3,4,2,3),c=c(10,20,30,10,20)) xu-unique(x) We have, x a b c 1 1 2 10 2 2 3 20 3 3 4 30 4 1 2 10 5 2 3 20 xu a b c 1 1 2 10 2 2 3 20 3 3 4 30 I want to get the following data frame : a b c Freq 1 1 2 10 2 2 2 3 20 2 3 3 4 30 1 That is, in addition to the unique rows, I want to get the frequency of repetion of each individual row. I will appreciate all the help that I can get. Thank You, Ravi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] categorical data analysis - fisher.exact for 2x2 and greater
Jeff and others: Paul Mielke and Ken Berry at Colorado State University developed very fast Fortran routines for doing Fisher exact tests (as well as some others like Chi-square and Zelterman's statistics). Their book (Permutation Methods: A Distance Function Approach, 2nd ed. 2007. Springer) indicates that these algorithms were only efficient for = 5 conditional loops so 2x2, 3x2, 4x2, 5x2, 6x2, 3x3, and 2x2x2 were feasible back in the 1990's. I'm not sure whether more recent computing capability permits larger tables now. Brian Brian S. Cade U. S. Geological Survey Fort Collins Science Center 2150 Centre Ave., Bldg. C Fort Collins, CO 80526-8818 email: [EMAIL PROTECTED] tel: 970 226-9326 Dr. Jeff Miller [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 05/07/2008 09:56 AM To 'Greg Snow' [EMAIL PROTECTED], 'David Winsemius' [EMAIL PROTECTED], [EMAIL PROTECTED] cc Subject Re: [R] categorical data analysis - fisher.exact for 2x2 and greater Hi Simon and all, I'm pretty sure that you are correct about this. I think it is a misconception to say that the fisher exact test is only for a 2 by 2 table. It is presented that way in textbooks because, for a 2x2 table, it is easy to perform. For larger tables, it becomes complex quickly due to the rate at which the permutations increase. When I use it for larger tables, it is hit or miss as to whether R will be able to do it. It's not uncommon to get an error implying that R is out of memory. Check out Agresti's Categorical Data Analysis on the use of the fisher exact for larger than 2x2 tables, and check out the R archives (and Google search) for all the posts about the error message people run into sometimes. On April 29th, Marc Schwartz replied to my question about this as follows: Take a look at the 'workspace' argument in ?fisher.test and review the second paragraph in Details: For 2 by 2 cases, p-values are obtained directly using the (central or non-central) hypergeometric distribution. Otherwise, computations are based on a C version of the FORTRAN subroutine FEXACT which implements the network developed by Mehta and Patel (1986) and improved by Clarkson, Fan and Joe (1993). The FORTRAN code can be obtained from http://www.netlib.org/toms/643. Note this fails (with an error message) when the entries of the table are too large. (It transposes the table if necessary so it has no more rows than columns. One constraint is that the product of the row marginals be less than 2^31 - 1.) Thank you, Jeff -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greg Snow Sent: Wednesday, May 07, 2008 9:55 AM To: David Winsemius; [EMAIL PROTECTED] Subject: Re: [R] categorical data analysis The last example in ?fisher.test is not a 2x2 table, in fact it uses levels with a natural ordering similar to the original question. Why would this not be applicable to the situation? From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of David Winsemius [EMAIL PROTECTED] Sent: Wednesday, May 07, 2008 7:34 AM To: [EMAIL PROTECTED] Subject: Re: [R] categorical data analysis Simon Blomberg [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: But see these posts: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/119079.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/119080.html Simon. Interesting reading, but the OP specifically said he was not dealing with 2x2 tables, so neither fisher.test nor the suggested alternatives would be applicable to his data situation. -- David Winsemius __ 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. Internal Virus Database is out-of-date. 11:27 AM Internal Virus Database is out-of-date. 11:27 AM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] use list elements to subtract values from the dataframe
Try get(paste(wf$,fl[[1]],sep=)) See ?get Julian Dirkheld wrote: Hi, I have a dataframe wf existing of a header with different labels and beneath the values of those labels : wf: label1 label2 ... 0,450,21 0,100,45 I have a list fl - c(label2,label3,..) Isn't possible to use the list elements in the list in order to subtract values from the dataframe? like : wf$fl[[1]] When I do in R I get :NULL fl[[1]] gives label2 so no problem here... While wf$label1 works fine. __ 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 with updating to R2.7
Hi, From R 2.6, I would like to update to R2.7. I would like to have some tips on the recommended method of installing the latest versions of an entire list of packages in R2.7 - i.e. all the packages that I have presently installed in R2.6. I am hoping that there is an easier method than fetching the packages individually as I did, to begin with, for R2.6. Additionally, I would like to install R2.7 on another pc which is not connected to the internet. I have previously installed R2.6 on it by fetching the zip files from another pc and installed them from the local zip files. I would like to know if there is a method of transferring an entire installation (base+selected packages) from one pc to another. Will there be a special problem if the first is a win vista pc and the 2nd has win 2000? One problem that I have in continuing to use R2.6 is in getting compatible versions of a new package that happens to attract my interest. For example, I was interested in getting the arm package for R2.6.1. I could not find the package in the R Binaries list on CRAN webpage. In the packages list, I did find old versions in the arm archive. However, the files were in .tar.gz format. How does one install from this format? It does not appear to be as straightforward as in installing from the zip format files.Recently, I had the same problem in installing a compatible version of the norm package also. I am interested to know how I can tackle these problems. I will appreciate all the help that I can get. Thanks, Ravi __ 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] dlm with constant terms
Hi, I am trying to figure how to use dlm with constant terms (possibly time-dependent) added to both equations y_t = c_t + F_t\theta_t + v_t \theta_t = d_t + G_t\theta_{t-1} + w_t, in the way that S-PLUS Finmetrics does? Is there any straightforward way to transform the above to the default setup? Thanks, Tsvetan NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. __ 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] PC configuration you are using
Hi Endre, I'm not sure if my configuration is typical. I'm running XP SP2, 4GB RAM and Intel Core 2-Duo Processor of 2.4 GHz with 200GB HDD. My R version is R 2.7.0 Patched. HTH, Jorge On Wed, May 7, 2008 at 12:49 PM, Endre Domiczi [EMAIL PROTECTED] wrote: Hello, As I mentioned in the previous message we are developing solution for wholesale companies to analyze their sales transactions by associative rules. I would very much appreciated if the community could give us some hint of what is a typical PC configuration of a professional statist (processor, RAM, HDD...)? Thanks a lot in advance and I highly appreciate your feedback! Kind regards, endre -- Endre Domiczi, CEO Sevana Oy, http://www.sevana.fi Email : [EMAIL PROTECTED] GSM : +372 53485178 Skype : emddom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Estimating QAIC using glm with the quasibinomial family
Thank you for the rapid response. I have no trouble in following your example, but I was specificly interested in calculating QAIC and QAICc from a glm fitted with the family=quasibinomial option. This provides an estimate of dispersion, but does not contain an explicit value for AIC or log-likelihood. Do you have any insights into how to deal with the output from this specific option? Or are you suggesting not to use family=quasibinomial when faced with potential overdispersion? Regardless, thank you again for your response. Cheers, Darren -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kunio takezawa Sent: Tuesday, May 06, 2008 8:41 PM To: r-help@r-project.org Subject: Re: [R] Estimating QAIC using glm with the quasibinomial family R-users E-mail: r-help@r-project.org My question is: Will this calculation be valid with the residual deviance returned by the glm() function using the quasibinomial family as reported in R? Let me show you a simple example, assuming c=2.5: function () { xx - c(1,2,3,4,5,6,7,8,9,10) yy - c(1,0,1,0,0,1,0,1,1,1) data1 - data.frame(x=xx, y=yy) out1 - glm(y~x, data=data1, family=binomial) print(out1) aic0 - out1$aic print(aic0) print(aic0) dev1 - out1$deviance aic1 - dev1+ 2*2 print(aic1) print(aic1) c1 - 2.5 qaic1 - dev1/c1+ 2*2 print(qaic1) print(qaic1) } The result is: Call: glm(formula = y ~ x, family = binomial, data = data1) Coefficients: (Intercept)x -0.7300 0.2131 Degrees of Freedom: 9 Total (i.e. Null); 8 Residual Null Deviance: 13.46 Residual Deviance: 12.63AIC: 16.63 [1] aic0 [1] 16.63054 [1] aic1 [1] 16.63054 [1] qaic1 [1] 9.052216 I hope that this R program will be of some help to you. K. Takezawa [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] algorithmic or automatic differentiation
Hi R People: Is there a package for automatic differentiation, please? thanks in advance, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ 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] rggobi is crashing R-2.7.0
On Tue, May 6, 2008 at 12:32 PM, Mark Kimpel [EMAIL PROTECTED] wrote: I am running 64-bit Ubuntu 8.04 and when I invoke rggobi the interactive graph displays but R crashes. See my sessionInfo() and a short example below. Ggobi and rggobi installed without complaints. Mark sessionInfo() R version 2.7.0 Patched (2008-05-04 r45620) x86_64-unknown-linux-gnu In the R 2.7 release notes, there is a comment about a change in the GUI libraries and it says that one must recompile everything that relies on R. If your R 2.7 was an upgrade, not a fresh install, it could explain why this is happening. If there's some old library or R package sitting around, it could account for this. The part that concerned me about the R release note is that they don't give a very clear guide on how far back in the toolchain we are supposed to go. Certainly, ggobi has to be rebuilt from scratch. But are any of the things on which ggobi depends needing recompliation as well. pj -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ 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] rggobi is crashing R-2.7.0
Uninstalling and reinstalling ggobi via Synaptic solved the problem, at least for the demo data mtcars. Rotation works fine. No crashes on exit. Thanks for the good advice. Mark On Wed, May 7, 2008 at 2:12 PM, Paul Johnson [EMAIL PROTECTED] wrote: On Tue, May 6, 2008 at 12:32 PM, Mark Kimpel [EMAIL PROTECTED] wrote: I am running 64-bit Ubuntu 8.04 and when I invoke rggobi the interactive graph displays but R crashes. See my sessionInfo() and a short example below. Ggobi and rggobi installed without complaints. Mark sessionInfo() R version 2.7.0 Patched (2008-05-04 r45620) x86_64-unknown-linux-gnu In the R 2.7 release notes, there is a comment about a change in the GUI libraries and it says that one must recompile everything that relies on R. If your R 2.7 was an upgrade, not a fresh install, it could explain why this is happening. If there's some old library or R package sitting around, it could account for this. The part that concerned me about the R release note is that they don't give a very clear guide on how far back in the toolchain we are supposed to go. Certainly, ggobi has to be rebuilt from scratch. But are any of the things on which ggobi depends needing recompliation as well. pj -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas -- Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, Mobile VoiceMail (317) 663-0513 Home (no voice mail please) ** [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with updating to R2.7
There are a few different methods discussed in the README to the batchfiles distribution. Home page at: http://batchfiles.googlecode.com On Wed, May 7, 2008 at 12:51 PM, ravi [EMAIL PROTECTED] wrote: Hi, From R 2.6, I would like to update to R2.7. I would like to have some tips on the recommended method of installing the latest versions of an entire list of packages in R2.7 - i.e. all the packages that I have presently installed in R2.6. I am hoping that there is an easier method than fetching the packages individually as I did, to begin with, for R2.6. Additionally, I would like to install R2.7 on another pc which is not connected to the internet. I have previously installed R2.6 on it by fetching the zip files from another pc and installed them from the local zip files. I would like to know if there is a method of transferring an entire installation (base+selected packages) from one pc to another. Will there be a special problem if the first is a win vista pc and the 2nd has win 2000? One problem that I have in continuing to use R2.6 is in getting compatible versions of a new package that happens to attract my interest. For example, I was interested in getting the arm package for R2.6.1. I could not find the package in the R Binaries list on CRAN webpage. In the packages list, I did find old versions in the arm archive. However, the files were in .tar.gz format. How does one install from this format? It does not appear to be as straightforward as in installing from the zip format files.Recently, I had the same problem in installing a compatible version of the norm package also. I am interested to know how I can tackle these problems. I will appreciate all the help that I can get. Thanks, Ravi __ 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] pivoting - summing up factors
Hi I would like to know how to pivot a table that will sum the number of plants (a or b) for each location (x,y,z) I have read on the listserve similar questions but which involve summing up numbers rather than factors. I have also read about the R package reshape on the listserve but wanted to know if there's a way to do it easily without the package Thanks for the help! location plant x a x b x b y b y b y a z a z a into a table like this xy z a 11 2 b 22 0 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] pivoting - summing up factors
Is this what you want: x location plant 1x a 2x b 3x b 4y b 5y b 6y a 7z a 8z a table(x$plant,x$location) x y z a 1 1 2 b 2 2 0 On Wed, May 7, 2008 at 2:56 PM, juanita choo [EMAIL PROTECTED] wrote: Hi I would like to know how to pivot a table that will sum the number of plants (a or b) for each location (x,y,z) I have read on the listserve similar questions but which involve summing up numbers rather than factors. I have also read about the R package reshape on the listserve but wanted to know if there's a way to do it easily without the package Thanks for the help! location plant x a x b x b y b y b y a z a z a into a table like this xy z a 11 2 b 22 0 [[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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ 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] pivoting - summing up factors
assuming what you have is a dataframe called x try: table(Plant=x$plant,Location=x$location) Location Plant x y z a 1 1 2 b 2 2 0 or simply: table(x$plant,x$location) x y z a 1 1 2 b 2 2 0 thanks juanita choo wrote: Hi I would like to know how to pivot a table that will sum the number of plants (a or b) for each location (x,y,z) I have read on the listserve similar questions but which involve summing up numbers rather than factors. I have also read about the R package reshape on the listserve but wanted to know if there's a way to do it easily without the package Thanks for the help! location plant x a x b x b y b y b y a z a z a into a table like this xy z a 11 2 b 22 0 [[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. - Yasir H. Kaheil, Ph.D. Catchment Research Facility The University of Western Ontario -- View this message in context: http://www.nabble.com/pivoting---summing-up-factors-tp17112158p17112407.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] coxph - weights- robust SE
Hi, I am using coxph with weights to represent sampling fraction of subjects. Our simulation results show that the robust SE of beta systematically under-estimate the empirical SD of beta. Does anyone know how the robust SE are estimated in coxph using weights? Is there any analytical formula for the âweightedâ robust SE? Any help is appreciated! Thanks so much in advance Willy [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] 2D correlation/convolution ?
What is the command for 2D fft? Or 2D convolution and or auto-correlation? Thanks, Paul __ 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] Advanced R/S-Plus Course by XLSolutions Corp / May 2008 in San Francisco Boston
Please check out these upcoming courses offered by XLSolutions Corporation. **Payments due after the class R/Splus Advanced Programming course: May 29-30, 2008 in San Francisco - 4 seats left. R/Splus Advanced Programming course: May 29-30, 2008 in Boston - 2 seats left. R/Splus Fundamentals and Programming Techniques: June 19-20 in Boston Payment due AFTER the class Email us for group discounts. Email Sue Turner: [EMAIL PROTECTED] Phone: 206-686-1578 Visit us: www.xlsolutions-corp.com/courselist.htm Please let us know if you and your colleagues are interested in this class to take advantage of group discount. Register now to secure your seat! Cheers, Elvis Miller, PhD Manager Training. XLSolutions Corporation 206 686 1578 www.xlsolutions-corp.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem installing tseries under FC7 x86_64
I have just installed the 64 bit version of R, using yum. The version is: 2.6.2-1.fc7.1.x86_64. I installed zoo without any major problem and the same with quadprog (a few warnings). However, when I came to install tseries I get the following: install.packages() Warning in install.packages() : argument 'lib' is missing: using '/home/xx/R/x86_64-redhat-linux-gnu-library/2.6' trying URL 'http://cran.uk.r-project.org/src/contrib/tseries_0.10-14.tar.gz' Content type 'application/x-gzip' length 171219 bytes (167 Kb) opened URL == downloaded 167 Kb * Installing *source* package 'tseries' ... ** libs gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/include/R -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c arma.c -o arma.o gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/include/R -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c bdstest.c -o bdstest.o bdstest.c:25:15: error: R.h: No such file or directory bdstest.c: In function ‘freeall’: bdstest.c:86: warning: implicit declaration of function ‘Free’ bdstest.c: In function ‘evalc’: bdstest.c:172: warning: implicit declaration of function ‘Rprintf’ bdstest.c: In function ‘fkc’: bdstest.c:289: warning: implicit declaration of function ‘Calloc’ bdstest.c:289: error: expected expression before ‘int’ bdstest.c:289: warning: assignment makes pointer from integer without a cast bdstest.c:290: error: expected expression before ‘int’ bdstest.c:290: warning: assignment makes pointer from integer without a cast bdstest.c:295: error: expected expression before ‘struct’ bdstest.c:295: warning: assignment makes pointer from integer without a cast bdstest.c:300: error: expected expression before ‘short’ bdstest.c:300: warning: assignment makes pointer from integer without a cast bdstest.c:307: error: expected expression before ‘short’ bdstest.c:307: warning: assignment makes pointer from integer without a cast bdstest.c:309: warning: implicit declaration of function ‘error’ bdstest.c:352: warning: implicit declaration of function ‘qsort’ make: *** [bdstest.o] Error 1 ERROR: compilation failed for package 'tseries' ** Removing '/home/x/R/x86_64-redhat-linux-gnu-library/2.6/tseries' The downloaded packages are in /tmp/RtmpocpCZU/downloaded_packages Warning message: In install.packages() : installation of package 'tseries' had non-zero exit status I realise that R.h is missing and is not on my machine anywhere. What have I missed? Thanks, Michael __ 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] cross-correlation lag.plot?
Hi, Does anyone know if R has a function that is similar to lag.plot but instead of auto-correlation, it plots cross-correlation with lags? Thanks, -- Tom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] solution to differences in sequential and marginal ANOVA using a mixed model
Yesterday I posted the following question to the help list. Thanks to John Fox (copied below) who pointed out the solution. Original question: I have come across a result that I cannot explain, and am hopingthat someone else can provide an answer. A student fitted a mixed model usingthe lme function: out- lme(fixed=Y~A+B+A:B, random=~1|Site). Y is a continuous variable while A and B are factors. The data set is balanced with the same number of observations in each combination of A and B. There are two hierarchical levels: Site and plots nested in site. He tried two different ways of getting theANOVA table: anova(out) and anova(out, type=marginal). Since the data were balanced, these two ways should (I think) give the same output since they correspond to Type I and III sums of squares in the SAS terminology. At least, this is the case with normal (i.e. not mixed) linear models. However, he finds very different results of these two types of ANOVA tables. Why? Response of John Fox: Dear Bill, I expect that the problem is in the contrasts that your student used for A and B, though I haven't thought specifically about the context of a mixed model. If he or she used the default contr.treatment(), then the contrasts for different factors (and the interaction) are not orthogonal in the row basis of the model matrix and hence are not orthogonal, even for balanced data. Using, e.g., contr.sum() should provide A, B, and A:B contrasts that are orthogonal to each other. Indeed, changing to an appropriate type of contrast did solve the problem! My problem was in forgetting that R uses treatment contrasts by default while SPLUS uses Helmert contrasts by default (which would have worked as well as sum contrasts). [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rggobi is crashing R-2.7.0
On Wed, May 7, 2008 at 11:40 AM, Mark Kimpel [EMAIL PROTECTED] wrote: Uninstalling and reinstalling ggobi via Synaptic solved the problem, at least for the demo data mtcars. Rotation works fine. No crashes on exit. Thanks for the good advice. I am pretty sure what Paul is referring to is the graphics device stuff. GGobi does not link against R anyway, so R would not be the problem here. The reason rebuilding GGobi fixed it, is that your GGobi binary was linked against an old version of graphviz. The new version broke binary compatibility, thus you needed to install a GGobi binary built against the new version. Mark On Wed, May 7, 2008 at 2:12 PM, Paul Johnson [EMAIL PROTECTED] wrote: On Tue, May 6, 2008 at 12:32 PM, Mark Kimpel [EMAIL PROTECTED] wrote: I am running 64-bit Ubuntu 8.04 and when I invoke rggobi the interactive graph displays but R crashes. See my sessionInfo() and a short example below. Ggobi and rggobi installed without complaints. Mark sessionInfo() R version 2.7.0 Patched (2008-05-04 r45620) x86_64-unknown-linux-gnu In the R 2.7 release notes, there is a comment about a change in the GUI libraries and it says that one must recompile everything that relies on R. If your R 2.7 was an upgrade, not a fresh install, it could explain why this is happening. If there's some old library or R package sitting around, it could account for this. The part that concerned me about the R release note is that they don't give a very clear guide on how far back in the toolchain we are supposed to go. Certainly, ggobi has to be rebuilt from scratch. But are any of the things on which ggobi depends needing recompliation as well. pj -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas -- Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, Mobile VoiceMail (317) 663-0513 Home (no voice mail please) ** [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cross-correlation lag.plot?
Hi! Try ?ccf HTH, Erin On 5/7/08, tom soyer [EMAIL PROTECTED] wrote: Hi, Does anyone know if R has a function that is similar to lag.plot but instead of auto-correlation, it plots cross-correlation with lags? Thanks, -- Tom [[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. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ 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 installing tseries under FC7 x86_64
On Wed, 2008-05-07 at 21:09 +0100, Michael Steinbeck-Reeves wrote: I have just installed the 64 bit version of R, using yum. The version is: 2.6.2-1.fc7.1.x86_64. Could it be that you don't have the development headers for R? Try: yum install R-devel as root in a console and then try installing tseries within R. HTH G I installed zoo without any major problem and the same with quadprog (a few warnings). However, when I came to install tseries I get the following: install.packages() Warning in install.packages() : argument 'lib' is missing: using '/home/xx/R/x86_64-redhat-linux-gnu-library/2.6' trying URL 'http://cran.uk.r-project.org/src/contrib/tseries_0.10-14.tar.gz' Content type 'application/x-gzip' length 171219 bytes (167 Kb) opened URL == downloaded 167 Kb * Installing *source* package 'tseries' ... ** libs gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/include/R -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c arma.c -o arma.o gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/include/R -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c bdstest.c -o bdstest.o bdstest.c:25:15: error: R.h: No such file or directory bdstest.c: In function ‘freeall’: bdstest.c:86: warning: implicit declaration of function ‘Free’ bdstest.c: In function ‘evalc’: bdstest.c:172: warning: implicit declaration of function ‘Rprintf’ bdstest.c: In function ‘fkc’: bdstest.c:289: warning: implicit declaration of function ‘Calloc’ bdstest.c:289: error: expected expression before ‘int’ bdstest.c:289: warning: assignment makes pointer from integer without a cast bdstest.c:290: error: expected expression before ‘int’ bdstest.c:290: warning: assignment makes pointer from integer without a cast bdstest.c:295: error: expected expression before ‘struct’ bdstest.c:295: warning: assignment makes pointer from integer without a cast bdstest.c:300: error: expected expression before ‘short’ bdstest.c:300: warning: assignment makes pointer from integer without a cast bdstest.c:307: error: expected expression before ‘short’ bdstest.c:307: warning: assignment makes pointer from integer without a cast bdstest.c:309: warning: implicit declaration of function ‘error’ bdstest.c:352: warning: implicit declaration of function ‘qsort’ make: *** [bdstest.o] Error 1 ERROR: compilation failed for package 'tseries' ** Removing '/home/x/R/x86_64-redhat-linux-gnu-library/2.6/tseries' The downloaded packages are in /tmp/RtmpocpCZU/downloaded_packages Warning message: In install.packages() : installation of package 'tseries' had non-zero exit status I realise that R.h is missing and is not on my machine anywhere. What have I missed? Thanks, Michael __ 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. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ 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] predict lmer
One question that arises is: at what level is the prediction desired? Within a given ID:TRKPT2 level? Within a given ID level? At the marginal level (which Bert's code appears to produce). Also, there is the question: how confident can you be in your predictions. This thread discusses possible ways to get prediction intervals: https://stat.ethz.ch/pipermail/r-sig-mixed-models/2008q2/thread.html#841 Finally, why assume a Poisson error distribution for a binary response? Kingsford Jones On Wed, May 7, 2008 at 10:13 AM, Bert Gunter [EMAIL PROTECTED] wrote: Sorry, my reply below may be too terse. You'll need to also construct the appropriate design matrix to which to apply the fixef() results to. If newDat is a data.frame containing **exactly the same named regressor and response columns** as your original vdata dataframe, and if me.fit.of is your fitted lmer object as you have defined it below, then model.matrix(terms(me.fit.of),newDat) %*% fixef(me.fit.of) gives your predictions. Note that while the response column in newDat is obviously unnecessary for prediction (you can fill it with 0's,say), it is nevertheless needed for model.matrix to work. This seems clumsy to me, so there may well be better ways to do this, and **I would appreciate suggestions for improvement.*** Cheers, Bert -Original Message- From: bgunter Sent: Wednesday, May 07, 2008 9:53 AM To: May, Roel; r-help@r-project.org Subject: RE: [R] predict lmer ?fixef gets you the coefficient vector, from which you can make your predictions. -- Bert Gunter Genentech -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of May, Roel Sent: Wednesday, May 07, 2008 7:23 AM To: r-help@r-project.org Subject: [R] predict lmer Hi, I am using lmer to analyze habitat selection in wolverines using the following model: (me.fit.of - lmer(USED~1+STEP+ALT+ALT2+relM+relM:ALT+(1|ID)+(1|ID:TRKPT2),data=vdata, control=list(usePQL=TRUE),family=poisson,method=Laplace)) Here, the habitat selection is calaculated using a so-called discrete choice model where each used location has a certain number of alternatives which the animal could have chosen. These sets of locations are captured using the TRKPT2 random grouping. However, these sets are also clustered over the different individuals (ID). USED is my binary dependent variable which is 1 for used locations and zero for unused locations. The other are my predictors. I would like to predict the model fit at different values of the predictors, but does anyone know whether it is possible to do this? I have looked around at the R-sites and in help but it seems that there doesn't exist a predict function for lmer??? I hope someone can help me with this; point me to the right functions or tell me to just forget it Thanks in advance! Cheers Roel Roel May Norwegian Institute for Nature Research Tungasletta 2, NO-7089 Trondheim, Norway [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help with regsubsets
Hi, I'm new to R and this mailing list, so I will attempt to state my question as appropriately as possible. I am running R version 2.7 with Windows XP and have recently been exploring the use of the function regsubsets in the leaps package in order to perform all-subsets regression. So, I'm calling the function as: sub=regsubsets(X,Y,nbest=5,nvmax=maxnv,method=exhaustive,really.big=F) I'm dealing with 14 observations and 23 variables and I'm aware of the linear dependencies that arise in these situations. I also know that regsubsets performs a branch-and-bound algorithm and that at times it is necessary to reorder the variables. However, anytime I get the message: Reordering variables and trying again the R^2 for a model chosen by regsubsets does not match the R^2 I get from fitting the same model using the usual linear model function (lm). If I don't get the Reordering variables and trying again message, I don't have any problems with R^2 (i.e. regubsets and lm match). Just for example, suppose the best 1-variable model chosen by regsubsets gives me an R^2 of 0.665. Fitting that same model using lm gives me an R^2 of 0.6317. Does anyone have any insight on why this may be happening? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] dlm with constant terms
Date: Wed, 07 May 2008 13:03:14 -0400 From: Stoyanov, Tsvetan (MSCIBARRA) [EMAIL PROTECTED] Importance: normal Priority: normal Thread-topic: dlm with constant terms Thread-index: AciwZDz3Kl800OdmR4CQkEC8PUECZg== Hi, I am trying to figure how to use dlm with constant terms (possibly time-dependent) added to both equations y_t = c_t + F_t\theta_t + v_t \theta_t = d_t + G_t\theta_{t-1} + w_t, in the way that S-PLUS Finmetrics does? Is there any straightforward way to transform the above to the default setup? I think you can do it by extending the state vector and defining a new dlm with \theta^*_t = (1 1 \theta_t')' F^*_t = [c_t 0 F_t], G^*_t = [100 ] [010 ] [0 d_t G_t] W^*_t = [0 0 0 ] [0 0 0 ] [0 0 W_t] m^*_0 = (1 1 m_0) C^*_0 = [e 0 0 ] [0 e 0 ] [0 0 C_0] The 'e' on the diagonal of C^*_0 should be zero, but since the matrix must be nonsingular youcan put a very small number, such as e = 1e-8. Best, Giovanni Petris Thanks, Tsvetan NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. -- Giovanni Petris [EMAIL PROTECTED] Associate Professor Department of Mathematical Sciences University of Arkansas - Fayetteville, AR 72701 Ph: (479) 575-6324, 575-8630 (fax) http://definetti.uark.edu/~gpetris/ __ 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] Gravity (spatial interaction) models in R
There may already be tools for gravity model APPLICATION, which is simply an exercise in normalization. Perhaps if I describe the gory details, someone will recognize the problem by another name. A singly constrained gravity model is simply an exercise in normalizing the rows of a matrix (your F-Factors) to match a vector (your Productions). A doubly constrained model (Fratar or Furness) is simply an iterative exercise of normalizing Rows (Productions) and Columns (Attractions), stopping when the maximum error is within some predefined limit. I'm only a newbie, but from what I've seen on the list, this should be simple to do As to calibrating F-Factor functions: one often chooses a functional F-Factor form, then adjusts the coefficients, until the weighted trip length distribution of the resulting trip table matches the observed data. Robert Farley Metro www.Metro.net -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Roger Bivand Sent: Tuesday, May 06, 2008 06:37 To: [EMAIL PROTECTED] Subject: Re: [R] Gravity (spatial interaction) models in R Melanie Murphy mamurphy at turbonet.com writes: I was wondering if anyone has developed (or is developing) an implementation for gravity models (spatial interaction) in R. I conducted several searches on the CRAN website with no luck. Currently I am estimating parameters via linearization. There isn't anything (yet) in the Spatial task view on CRAN, and I'm not aware of the topic coming up on the R-sig-geo list either. The nearest sign of transport planning is perhaps the emme2 package for interfacing EMME/2 software. As you are aware, there are many almost equivalent ways of fitting gravity models, so many R functions are feasible. But no dedicated functions so far, I'm afraid - if I'm wrong, please let me know, and I'll update the task view. Roger Thank you in advance Melanie Murphy __ 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] Sweave, xtable and font size
Hi, I'm using Sweave with xtable to generate Latex tables. My problem is that some of the tables are too wide, and I would like to use the tiny font for these tables, but not for the others nor for the text. I can't work out how to accomplish that. The Latex code below does what I want it to, but I have to insert the \tiny{ and the closing } by hand. It originated from these commands in my .Rnw-file: yearmale, results=tex= yearmale - with(chol, table(year,male)) yearmale - rowpct(yearmale) yearmale, results=tex= print(xtable(yearmale,caption=My caption)) $ LATEX CODE: \begin{table}[ht] \begin{center} \tiny{ \begin{tabular}{rlll} \hline Kvinder Mænd Total \\ \hline 1998 1335 (75\%) 437 (25\%) 1772 (100\%) \\ 1999 1232 (74\%) 425 (26\%) 1657 (100\%) \\ 2000 1427 (74\%) 502 (26\%) 1929 (100\%) \\ 2001 1407 (74\%) 493 (26\%) 1900 (100\%) \\ 2002 1493 (71\%) 611 (29\%) 2104 (100\%) \\ 2003 1684 (75\%) 566 (25\%) 2250 (100\%) \\ 2004 1565 (73\%) 567 (27\%) 2132 (100\%) \\ 2005 1629 (74\%) 586 (26\%) 2215 (100\%) \\ 2006 1448 (72\%) 553 (28\%) 2001 (100\%) \\ 2007 1582 (73\%) 590 (27\%) 2172 (100\%) \\ Total 14802 (74\%) 5330 (26\%) 20132 (100\%) \\ \hline \end{tabular} } \caption{My caption} \end{center} \end{table} Can anybody help me? Thank you in advance. Best regards, Peter. __ 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] Sweave, xtable and font size
On 07/05/2008 7:34 PM, Peter Jepsen wrote: Hi, I'm using Sweave with xtable to generate Latex tables. My problem is that some of the tables are too wide, and I would like to use the tiny font for these tables, but not for the others nor for the text. I can't work out how to accomplish that. The Latex code below does what I want it to, but I have to insert the \tiny{ and the closing } by hand. It originated from these commands in my .Rnw-file: yearmale, results=tex= yearmale - with(chol, table(year,male)) yearmale - rowpct(yearmale) yearmale, results=tex= print(xtable(yearmale,caption=My caption)) $ See ?print.xtable. You can use print(xtable(yearmale,caption=My caption), size=\\tiny) Duncan Murdoch LATEX CODE: \begin{table}[ht] \begin{center} \tiny{ \begin{tabular}{rlll} \hline Kvinder Mænd Total \\ \hline 1998 1335 (75\%) 437 (25\%) 1772 (100\%) \\ 1999 1232 (74\%) 425 (26\%) 1657 (100\%) \\ 2000 1427 (74\%) 502 (26\%) 1929 (100\%) \\ 2001 1407 (74\%) 493 (26\%) 1900 (100\%) \\ 2002 1493 (71\%) 611 (29\%) 2104 (100\%) \\ 2003 1684 (75\%) 566 (25\%) 2250 (100\%) \\ 2004 1565 (73\%) 567 (27\%) 2132 (100\%) \\ 2005 1629 (74\%) 586 (26\%) 2215 (100\%) \\ 2006 1448 (72\%) 553 (28\%) 2001 (100\%) \\ 2007 1582 (73\%) 590 (27\%) 2172 (100\%) \\ Total 14802 (74\%) 5330 (26\%) 20132 (100\%) \\ \hline \end{tabular} } \caption{My caption} \end{center} \end{table} Can anybody help me? Thank you in advance. Best regards, Peter. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Estimating QAIC using glm with the quasibinomial family
R-users E-mail: r-help@r-project.org but I was specificly interested in calculating QAIC and QAICc from a glm fitted with the family=quasibinomial option. If you use family=quasibinomial(link = logit) in glm(), the program will be: function () { xx - c(1,2,3,4,5,6,7,8,9,10) yy - c(1,0,1,0,0,1,0,1,1,1) data1 - data.frame(x=xx, y=yy) out1 - glm(y~x, data=data1, family=quasibinomial(link = logit)) print(out1) aic0 - out1$aic print(aic0) print(aic0) dev1 - out1$deviance aic1 - dev1+ 2*2 print(aic1) print(aic1) c1 - 2.5 qaic1 - dev1/c1+ 2*2 print(qaic1) print(qaic1) } The result is: Call: glm(formula = y ~ x, family = quasibinomial(link = logit), data = data1) Coefficients: (Intercept)x -0.7300 0.2131 Degrees of Freedom: 9 Total (i.e. Null); 8 Residual Null Deviance: 13.46 Residual Deviance: 12.63AIC: NA [1] aic0 [1] NA [1] aic1 [1] 16.63054 [1] qaic1 [1] 9.052216 As you pointed out, glm() does not output the value of either AIC or QAIC. You are supposed to calculate those values. I guess that it is because AIC is not appropriate for this case, and the concept of QAIC has not been authorized yet. K. Takezawa [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] anova p value extraction
hello all, Quick question, how do I get the p value out of the anova? Thanks, Paul pb-aov(as.numeric(diff[5,16:33]) ~ grF) summary(pb) Df Sum SqMean Sq F value Pr(F) grF 3 2.7860e+10 9.2867e+09 4.2236 0.02534 * Residuals 14 3.0783e+10 2.1988e+09 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 str(summary(pb)) List of 1 $ :Classes 'anova' and 'data.frame': 2 obs. of 5 variables: ..$ Df : num [1:2] 3 14 ..$ Sum Sq : num [1:2] 2.79e+10 3.08e+10 ..$ Mean Sq: num [1:2] 9.29e+09 2.20e+09 ..$ F value: num [1:2] 4.22 NA ..$ Pr(F) : num [1:2] 0.0253 NA - attr(*, class)= chr [1:2] summary.aov listof attr(summary(pb), Pr(F)) NULL __ 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] SVD for a 500, 000* 500, 000 matrix (singular value decomposition)
Hi, I tried to run SVD on a 500,000* 500,000 matrix and i get a message that it can not allocate a vector of length 270 mb doe snayone know how to solve this problem? any ideas on other softwares where I can do this? I appreciate your help thanks -- View this message in context: http://www.nabble.com/SVD-for-a-500%2C000*-500%2C000-matrix-%28singular-value-decomposition%29-tp17115286p17115286.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] anova p value extraction
Yea the anova object seems to be odd. It's not S4 so that's why I tried originally the attr() funtion but summary(pb)$Pr(F) Error: unexpected '' in summary(pb)$Pr( summary(pb)$Pr NULL summary(pb)@Pr(F) Error: unexpected '' in summary(pb)@Pr( summary(pb)@Pr(F) Error: no slot of name Pr for this object of class summary.aov In addition: Warning message: trying to get slot Pr from an object (class summary.aov) that is not an S4 object Research Programmer Technician The Scripps Research Institute Mass Spectrometry Core Facility o The / o Scripps \ o Research / o Institute [EMAIL PROTECTED] wrote: Hi: it's probably the Pr( F) element so just access it by sum-summary(whatever). then sum$Pr(F) will probably work. But make sure that's it because usually the name is pval or pvalue etc so I'm surprised about the weird name. On Wed, May 7, 2008 at 8:47 PM, Paul Benton wrote: hello all, Quick question, how do I get the p value out of the anova? Thanks, Paul pb-aov(as.numeric(diff[5,16:33]) ~ grF) summary(pb) Df Sum SqMean Sq F value Pr(F) grF 3 2.7860e+10 9.2867e+09 4.2236 0.02534 * Residuals 14 3.0783e+10 2.1988e+09 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 str(summary(pb)) List of 1 $ :Classes 'anova' and 'data.frame': 2 obs. of 5 variables: ..$ Df : num [1:2] 3 14 ..$ Sum Sq : num [1:2] 2.79e+10 3.08e+10 ..$ Mean Sq: num [1:2] 9.29e+09 2.20e+09 ..$ F value: num [1:2] 4.22 NA ..$ Pr(F) : num [1:2] 0.0253 NA - attr(*, class)= chr [1:2] summary.aov listof attr(summary(pb), Pr(F)) NULL __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] anova p value extraction
Hi Paul, Perhaps # Data set set.seed(123) x=rnorm(100) y=x+2*rnorm(100) # ANOVA AOV=anova(lm (y ~ x)) p1=AOV$Pr(F)[1] p1 or # ANOVA 2 AOV1=aov(y ~ x) p2=unlist(summary(AOV1))[Pr(F)1] p2 HTH, Jorge On Wed, May 7, 2008 at 8:47 PM, Paul Benton [EMAIL PROTECTED] wrote: hello all, Quick question, how do I get the p value out of the anova? Thanks, Paul pb-aov(as.numeric(diff[5,16:33]) ~ grF) summary(pb) Df Sum SqMean Sq F value Pr(F) grF 3 2.7860e+10 9.2867e+09 4.2236 0.02534 * Residuals 14 3.0783e+10 2.1988e+09 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 str(summary(pb)) List of 1 $ :Classes 'anova' and 'data.frame': 2 obs. of 5 variables: ..$ Df : num [1:2] 3 14 ..$ Sum Sq : num [1:2] 2.79e+10 3.08e+10 ..$ Mean Sq: num [1:2] 9.29e+09 2.20e+09 ..$ F value: num [1:2] 4.22 NA ..$ Pr(F) : num [1:2] 0.0253 NA - attr(*, class)= chr [1:2] summary.aov listof attr(summary(pb), Pr(F)) NULL __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] anova p value extraction
What works, amazingly, is summary(pb)$Pr(F) [note the quotes] Abhijit On Wed, 07 May 2008 18:17:09 -0700 H. Paul Benton [EMAIL PROTECTED] wrote: Yea the anova object seems to be odd. It's not S4 so that's why I tried originally the attr() funtion but summary(pb)$Pr(F) Error: unexpected '' in summary(pb)$Pr( summary(pb)$Pr NULL summary(pb)@Pr(F) Error: unexpected '' in summary(pb)@Pr( summary(pb)@Pr(F) Error: no slot of name Pr for this object of class summary.aov In addition: Warning message: trying to get slot Pr from an object (class summary.aov) that is not an S4 object Research Programmer Technician The Scripps Research Institute Mass Spectrometry Core Facility o The / o Scripps \ o Research / o Institute [EMAIL PROTECTED] wrote: Hi: it's probably the Pr( F) element so just access it by sum-summary(whatever). then sum$Pr(F) will probably work. But make sure that's it because usually the name is pval or pvalue etc so I'm surprised about the weird name. On Wed, May 7, 2008 at 8:47 PM, Paul Benton wrote: hello all, Quick question, how do I get the p value out of the anova? Thanks, Paul pb-aov(as.numeric(diff[5,16:33]) ~ grF) summary(pb) Df Sum SqMean Sq F value Pr(F) grF 3 2.7860e+10 9.2867e+09 4.2236 0.02534 * Residuals 14 3.0783e+10 2.1988e+09 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 str(summary(pb)) List of 1 $ :Classes 'anova' and 'data.frame': 2 obs. of 5 variables: ..$ Df : num [1:2] 3 14 ..$ Sum Sq : num [1:2] 2.79e+10 3.08e+10 ..$ Mean Sq: num [1:2] 9.29e+09 2.20e+09 ..$ F value: num [1:2] 4.22 NA ..$ Pr(F) : num [1:2] 0.0253 NA - attr(*, class)= chr [1:2] summary.aov listof attr(summary(pb), Pr(F)) NULL __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Abhijit Dasgupta __ 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] anova p value extraction
yep That worked Jorge. Thanks! summary(pb)$Pr(F)1 NULL summ-summary(pb) class(unlist(summ)) [1] numeric unlist(summ)[Pr(F)1] Pr(F)1 0.02533637 names(summ) NULL Jorge Ivan Velez wrote: Hi Paul, Perhaps # Data set set.seed(123) x=rnorm(100) y=x+2*rnorm(100) # ANOVA AOV=anova(lm (y ~ x)) p1=AOV$Pr(F)[1] p1 or # ANOVA 2 AOV1=aov(y ~ x) p2=unlist(summary(AOV1))[Pr(F)1] p2 HTH, Jorge On Wed, May 7, 2008 at 8:47 PM, Paul Benton [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: hello all, Quick question, how do I get the p value out of the anova? Thanks, Paul pb-aov(as.numeric(diff[5,16:33]) ~ grF) summary(pb) Df Sum SqMean Sq F value Pr(F) grF 3 2.7860e+10 9.2867e+09 4.2236 0.02534 * Residuals 14 3.0783e+10 2.1988e+09 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 str(summary(pb)) List of 1 $ :Classes 'anova' and 'data.frame': 2 obs. of 5 variables: ..$ Df : num [1:2] 3 14 ..$ Sum Sq : num [1:2] 2.79e+10 3.08e+10 ..$ Mean Sq: num [1:2] 9.29e+09 2.20e+09 ..$ F value: num [1:2] 4.22 NA ..$ Pr(F) : num [1:2] 0.0253 NA - attr(*, class)= chr [1:2] summary.aov listof attr(summary(pb), Pr(F)) NULL __ R-help@r-project.org mailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] use of sequence on ridge regression
Sorry to bother with this topic, but I'm still not clear about the meaning of the value set that is used on lambda values. Is there a correct way of doing that? My doubt is how to choose those 3 values that appear in the example. Thanks. On Wed, May 7, 2008 at 9:29 AM, Prof Brian Ripley [EMAIL PROTECTED] wrote: On Wed, 7 May 2008, Rodrigo Briceño wrote: Nice to meet you Brian. The question is about the numbers that appears after lambda (0,0, 0.1, 0.0001). I know that seq is a set of values used for testing which value fits best. But I'm not sure if I need to put whatever I think or what. I tried also with a set of 5 values and I get an error. Is there a maximum allowed? So you mean the set of values of lambda? It is just a set to be use for a plot and for searching in the select() methods. There is an R function called sequence(), and it is not the same as seq(). plot(lm.ridge(hipcenter ~ .,seatpos, lambda = seq(0,0.1,0.001))) select(lm.ridge(hipcenter ~ ., seatpos,lambda = seq(0,0.1,0.001))) __ Rodrigo Briceño Project Manager Sanigest Internacional +506 22-91-12-00 ext. 113 Oficina Costa Rica +506 22-32-08-30 Fax +506 88-86-11-77 Celular [EMAIL PROTECTED] www.sanigest.com MSN: [EMAIL PROTECTED] SKYPE: rbriceno1087 _ This communication contains legal information which is privileged and confidential. It is for the exclusive use of the address and distribution, dissemination, copying or use by others is strictly prohibited. If you have received this communication by error, please delete the original message and e-mail us. Esta comunicación contiene información legal privilegiada y confidencial para el uso exclusivo del destinatario. La distribución, diseminación, copia u otro uso por terceras personas es estrictamente prohibida. Si usted ha recibido esta comunicación por error, le rogamos borrar el mensaje original y comunicárnoslo a esta misma dirección. Prof Brian Ripley wrote: What do you mean by 'the sequence option'? The authot of lm.ridge On Wed, 7 May 2008, Rodrigo Briceño wrote: Dear R users. I have a doubt about the use of the sequence option on Ridge regression. I'm trying to understand the use of this option when variables are highly linear correlated. I'm running a model where the variables HtShoes and Ht have high VIF values. My program is written below, but I'm not sure about the correct way of using the sequence option: library (faraway) data (seatpos) attach (seatpos) spos.mod - lm(hipcenter ~ .,seatpos) summary (spos.mod) library(MASS) lm.ridge(hipcenter ~ .,seatpos) plot(lm.ridge(hipcenter ~ .,seatpos, lambda = seq(0,0.1,0.001))) select(lm.ridge(hipcenter ~ ., seatpos,lambda = seq(0,0.1,0.001))) Any advice will be appreaciated. Rodrigo B. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cross-correlation lag.plot?
http://www.stat.pitt.edu/stoffer/tsa2/Examples.htm tom soyer wrote: Hi, Does anyone know if R has a function that is similar to lag.plot but instead of auto-correlation, it plots cross-correlation with lags? Thanks, -- Tom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - The power of accurate observation is commonly called cynicism by those who have not got it. George Bernard Shaw -- View this message in context: http://www.nabble.com/cross-correlation-lag.plot--tp17114046p17117624.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] categorical data analysis
David Winsemius [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: raymond chiruka [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: i am trying to carry out a categorical data analysis but my problem is that when in i use the chi squared test some of my expected values are less than 5. is there a test that can handle this situation. the data is not a 2*2 table. its more from the social sciences where you have from strongly agree to strongly disagree. i know i can collapse vthe tables but there is a loss of information . is the a test vthat i can for this kind of data. thanks in advancde. In addition to Snow's suggestion of fisher.test, you may want to look more closely at: ?chisq.test snip Another possibility for the analysis of ordered catergorical response might be proportional odds regression. The MASS package has polr: library(MASS) ?polr polr(formula, data, weights, start, ..., subset, na.action, contrasts = NULL, Hess = FALSE, model = TRUE, method = c(logistic, probit, cloglog, cauchit)) Arguments formula: a formula expression as for regression models, of the form response ~ predictors. The response should be a factor (preferably an ordered factor), which will be interpreted as an ordinal response, with levels ordered as in the factor. - My copy of VenablesRipley's MASS is an older version and neither the index nor the TOC tells me where to find worked examples. Harrell's Regression Modeling Strategies has a case study illustrating the use of his lrm function. So you might also look at: library(Design) ?lrm -- David Winsemius __ 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] algorithmic or automatic differentiation
Erin Hodgess [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Is there a package for automatic differentiation, please? Have you looked at Goedman, Grothendieck, Hojsgaard, and Pinkus' Ryacas? From the Ryacas documentation: Analytical derivatives of functions can be evaluated with the D() and deriv() functions: yacas(D(x) Sin(x)) expression(cos(x)) -- David Winsemius __ 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] algorithmic or automatic differentiation
No, computer algebra systems such as yacas do symbolic differentiation. Automatic differentiation is a numerical technique that can be used to find derivatives of functions that can be implemented as computer programs, through successive uses of the chain rule on the computer code itself. It would be cool if R could either do AD or interface to an AD package. R can be used with ADmodelbuilder (see http://otter-rsch.ca/admbre/examples/glmmadmb/glmmADMB.html) , a proprietry program, but an open source solution would be nice. Cheers, Simon. On Thu, 2008-05-08 at 03:09 +, David Winsemius wrote: Erin Hodgess [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Is there a package for automatic differentiation, please? Have you looked at Goedman, Grothendieck, Hojsgaard, and Pinkus' Ryacas? From the Ryacas documentation: Analytical derivatives of functions can be evaluated with the D() and deriv() functions: yacas(D(x) Sin(x)) expression(cos(x)) -- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320 Goddard Building (8) T: +61 7 3365 2506 http://www.uq.edu.au/~uqsblomb email: S.Blomberg1_at_uq.edu.au Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. __ 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] Replicating Rows
Hi, I have a data matrix in which there are 1000 rows by 30 columns. The first column of each row is a numeric indicating the number of trips taken to a particular location with location attributes in the following column entries for that row. I want to repeat each row based on the number of trips taken (as indicated by the number in the first column)...i.e., if 1,1 indicates 4 trips, I want to replicate row 1 four times, and do this for each entry of column 1. I have played with rep command with little luck. Can anyone help? This is probably very simple. Thank you, mw Marion Wittmann, Ph.D. candidate Environmental Science and Management University of California Santa Barbara, CA 93106-5131 __ 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] algorithmic or automatic differentiation
Thanks to all! Sincerely, Erin On Wed, May 7, 2008 at 10:35 PM, Simon Blomberg [EMAIL PROTECTED] wrote: No, computer algebra systems such as yacas do symbolic differentiation. Automatic differentiation is a numerical technique that can be used to find derivatives of functions that can be implemented as computer programs, through successive uses of the chain rule on the computer code itself. It would be cool if R could either do AD or interface to an AD package. R can be used with ADmodelbuilder (see http://otter-rsch.ca/admbre/examples/glmmadmb/glmmADMB.html) , a proprietry program, but an open source solution would be nice. Cheers, Simon. On Thu, 2008-05-08 at 03:09 +, David Winsemius wrote: Erin Hodgess [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Is there a package for automatic differentiation, please? Have you looked at Goedman, Grothendieck, Hojsgaard, and Pinkus' Ryacas? From the Ryacas documentation: Analytical derivatives of functions can be evaluated with the D() and deriv() functions: yacas(D(x) Sin(x)) expression(cos(x)) -- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320 Goddard Building (8) T: +61 7 3365 2506 http://www.uq.edu.au/~uqsblomb email: S.Blomberg1_at_uq.edu.au Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. __ 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. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ 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] Replicating Rows
Hi Marion, Try this: set.seed(123) mydf=data.frame(trips=rpois(10,5), matrix(rnorm(10*5),ncol=5)) mydf sapply(mydf[,-1],rep,mydf[,1]) HTH, Jorge On Wed, May 7, 2008 at 11:41 PM, [EMAIL PROTECTED] wrote: Hi, I have a data matrix in which there are 1000 rows by 30 columns. The first column of each row is a numeric indicating the number of trips taken to a particular location with location attributes in the following column entries for that row. I want to repeat each row based on the number of trips taken (as indicated by the number in the first column)...i.e., if 1,1 indicates 4 trips, I want to replicate row 1 four times, and do this for each entry of column 1. I have played with rep command with little luck. Can anyone help? This is probably very simple. Thank you, mw Marion Wittmann, Ph.D. candidate Environmental Science and Management University of California Santa Barbara, CA 93106-5131 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] use of sequence on ridge regression
On Wed, 7 May 2008, Rodrigo Briceño wrote: Sorry to bother with this topic, but I'm still not clear about the meaning of the value set that is used on lambda values. Is there a correct way of doing that? My doubt is how to choose those 3 values that appear in the example. I think you have not yet read the help for seq(): try printing out seq(0,0.1,0.001). There are not '3 values' here, but 3 arguments to a function. 'lambda' values start at 0 (no shrinkage), and how large you want them to be is problem-specific. How many you ask for (101 here) is also problem-specific, but around 100 values is often used. Thanks. On Wed, May 7, 2008 at 9:29 AM, Prof Brian Ripley [EMAIL PROTECTED] wrote: On Wed, 7 May 2008, Rodrigo Briceño wrote: Nice to meet you Brian. The question is about the numbers that appears after lambda (0,0, 0.1, 0.0001). I know that seq is a set of values used for testing which value fits best. But I'm not sure if I need to put whatever I think or what. I tried also with a set of 5 values and I get an error. Is there a maximum allowed? So you mean the set of values of lambda? It is just a set to be use for a plot and for searching in the select() methods. There is an R function called sequence(), and it is not the same as seq(). plot(lm.ridge(hipcenter ~ .,seatpos, lambda = seq(0,0.1,0.001))) select(lm.ridge(hipcenter ~ ., seatpos,lambda = seq(0,0.1,0.001))) __ Rodrigo Briceño Project Manager Sanigest Internacional +506 22-91-12-00 ext. 113 Oficina Costa Rica +506 22-32-08-30 Fax +506 88-86-11-77 Celular [EMAIL PROTECTED] www.sanigest.com MSN: [EMAIL PROTECTED] SKYPE: rbriceno1087 _ This communication contains legal information which is privileged and confidential. It is for the exclusive use of the address and distribution, dissemination, copying or use by others is strictly prohibited. If you have received this communication by error, please delete the original message and e-mail us. Esta comunicación contiene información legal privilegiada y confidencial para el uso exclusivo del destinatario. La distribución, diseminación, copia u otro uso por terceras personas es estrictamente prohibida. Si usted ha recibido esta comunicación por error, le rogamos borrar el mensaje original y comunicárnoslo a esta misma dirección. Prof Brian Ripley wrote: What do you mean by 'the sequence option'? The authot of lm.ridge On Wed, 7 May 2008, Rodrigo Briceño wrote: Dear R users. I have a doubt about the use of the sequence option on Ridge regression. I'm trying to understand the use of this option when variables are highly linear correlated. I'm running a model where the variables HtShoes and Ht have high VIF values. My program is written below, but I'm not sure about the correct way of using the sequence option: library (faraway) data (seatpos) attach (seatpos) spos.mod - lm(hipcenter ~ .,seatpos) summary (spos.mod) library(MASS) lm.ridge(hipcenter ~ .,seatpos) plot(lm.ridge(hipcenter ~ .,seatpos, lambda = seq(0,0.1,0.001))) select(lm.ridge(hipcenter ~ ., seatpos,lambda = seq(0,0.1,0.001))) Any advice will be appreaciated. Rodrigo B. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented,