Re: [R] Aggregation of data frame with calculations of proportions
Dear Jim, On 26/06/07, jim holtman [EMAIL PROTECTED] wrote: I think something like this will do it for you. set.seed(1) n - 10 x - data.frame(a=sample(1:100,n), b=sample(1:100,n),d=sample(1:100,n)) x$a[c(1,5)] - NA x$b[c(7,6,4)] - NA x$d[c(5,8)] - NA x$total - rowSums(x, na.rm=TRUE) x$type - sample(1:3, n, replace=TRUE) by(x, list(x$type), function(z){ apply(z[,1:3], 2, calc.prevalence, total=z$total) }) [...SNIP...] -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? It works perfectly. The problem now is how to send over that beer I owe you! Many thanks, Best wishes, -- Dr. Mark Wardle Clinical research fellow and specialist registrar, Neurology Cardiff, UK __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Is Landau-H available
Does anybody knows whether Landau-H index is available in ? I did not found anything about with r Regards Knut __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A really simple data manipulation example
For merging, selecting and aggregating, R is not too bad: I believe the following code is more or less equivalent to your Vilno example, isn't? # to input data, replace the following two lline by 'read.table' labresults - data.frame(patient.id=gl(10,5), visit.num=gl(5,10), sodium=rnorm(50)) demo - data.frame(patient.id=gl(10,1), gender=gl(2,5,labels=c('F','M'))) data - merge(labresults, demo) data - subset(data, visit.num!=2) with(data, aggregate(sodium, list(gender=gender), mean) ) If the data sets are very large, then doing merges/selection/aggregation outside of R can be a good idea. Christophe On 6/27/07, Robert Wilkins [EMAIL PROTECTED] wrote: In response to those who asked for a better explanation of what the Vilno software does, here's a simple example that gives some idea of what it does. LABRESULTS is a dataset with multiple rows per patient , with lab sodium measurements. It has columns: PATIENT_ID, VISIT_NUM, and SODIUM. DEMO is a dataset with one row per patient, with demographic data. It has columns: PATIENT_ID, GENDER. Here's a simple example, the following paragraph of code is a data processing function (dpf) : inlist LABRESULTS DEMO ; mergeby PATIENT_ID ; if (SODIUM == -9) SODIUM = NULL ; if (VISIT_NUM != 2) deleterow ; select AVERAGE_SODIUM = avg(SODIUM) by GENDER ; sendoff(RESULTS_DATASET) GENDER AVERAGE_SODIUM ; turnoff; // just means end-of-paragraph , version 1.0 won't need this. Can you guess what it does? The lab result rows are merged with the demographic rows, just to get the gender information merged in. Obviously, they are merged by patient. The code -9 is used to denote missing, so convert that to NULL. I'm about to take a statistic for visit 2, so rows with visit 0 or 1 must be deleted. I'm assuming, for visit 2, each patient has at most one row. Now, for each sex group, take the average sodium level. After the select statement, I have just two rows, for male and female, with the average sodium level in the AVERAGE_SODIUM column. Now the sendoff statement just stores the current data table into a datafile, called RESULTS_DATASET. So you have a sequence of data tables, each calculation reading in the current table , and leaving a new data table for the next calculation. So you have input datasets, a bunch of intermediate calculations, and one or more output datasets. Pretty simple idea. * Some caveats: LABRESULTS and DEMO are binary datasets. The asciitobinary and binarytoascii statements are used to convert between binary datasets and comma-separated ascii data files. (You can use any delimiter: comma, vertical bar , etc). An asciitobinary statement is typically just two lines of code. The dpf begins with the inlist statement , and , for the moment , needs turnoff ; as the last line. Version 1.0 won't require the use of turnoff;, but version 0.85 does. It only means this paragraph of code ends here ( a program can , of course , contain many paragraphs: data processing functions, print statements, asciitobinary statements, etc.). If you've worked with lab data, you know lab data does not look so simplistic. I need a simple example. Vilno has a lot of functionality, many-to-many joins, adding columns, firstrow() and lastrow() flags, and so forth. A fair amount of complex data manipulations have already been tested with test programs ( in the tarball ). Of course a simple example cannot show you that, it's just a small taste. * If you've never used SPSS or SAS before, you won't care, but this programming language falls in the same family as the SPSS and SAS programming languages. All three programming languages have a fair amount in common, but are quite different from the S programming language. The vilno data processing function can replace the SAS datastep. (It can also replace PROC TRANSPOSE and much of PROC MEANS, except standard deviation calculations still need to be included in the select statement). I hope that helps. http://code.google.com/p/vilno __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Christophe Pallier (http://www.pallier.org) [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Looking for parallel functionality between Matlab and R
El-ad David Amir wrote: I'm slowly moving my statistical analysis from Matlab to R, and find myself missing two features: a) How do I mimic Matlab's 'hold on'? (I want to show several plots together, when I type two plots one after the other the second overwrites the first) b) How do I mimic Matlab's 'axis'? (after drawing my plots I want to zoom on specific parts- for example, x=0:5, y=0:20). I think what you want for a) is par(ask=TRUE). There have been a few discussions of zooming on the help list - see: http://stats.math.uni-augsburg.de/iPlots/index.shtml for one solution. Jim __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Looking for parallel functionality between Matlab and R
This zooming function on the R-Wiki page was very neat: http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:interactive_zooming Also, to answer question (a), maybe these examples might help? ## add elements to plot plot(1:10,1:10) lines(1:10,(1:10)/2) points(1:10,(1:10)/1.5) ## add second y-axis par(mar=c(5,4,2,4)+0.1) plot(1:10,1:10) par(new=TRUE) plot(-20:20,20:-20,col=4, type=l,axes=FALSE, xlab=,ylab=, xaxs=i, xlim=par(usr)[1:2]) axis(4,col=4,col.axis=4) mtext(second y-axis label,4,outer=TRUE,padj=-2,col=4) --- Jim Lemon [EMAIL PROTECTED] wrote: El-ad David Amir wrote: I'm slowly moving my statistical analysis from Matlab to R, and find myself missing two features: a) How do I mimic Matlab's 'hold on'? (I want to show several plots together, when I type two plots one after the other the second overwrites the first) b) How do I mimic Matlab's 'axis'? (after drawing my plots I want to zoom on specific parts- for example, x=0:5, y=0:20). I think what you want for a) is par(ask=TRUE). There have been a few discussions of zooming on the help list - see: http://stats.math.uni-augsburg.de/iPlots/index.shtml for one solution. Jim __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Luggage? GPS? Comic books? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Strange RODBC problem
On 6/26/07, Richard M. Heiberger [EMAIL PROTECTED] wrote: I am using RODBC to collect data from an ODBC connection to an MS Access Database. Everything seems to be working well except datetimes between March 12, 2006 02:00 and 02:59 get moved one hour forward. This does not seem to be happening with Excel connecting to the same connection. March 12 seems a bit early for Daylight savings time. What am I doing wrong? In 2007, the US moved daylight savings to March 11 instead of the more traditional first weekend in April. It continues to November 4, a week later than before. Google daylight savings 2007 for lots of background. Some MS programs did not make the switch until April 1, therefore my calendars doubled up continuing appointments. From your experience, it looks like some programs are retroactively misapplying the change to 2006. Thanks, that seems to be the problem. Now I need to figure out how to fix it, but I know where to look. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Another loop avoidance question.
Hi I want to sum over one of the dimensions of a n x k1 x k2 array in which each column is the product of the corresponding columns from two matrices with dimensions n x k1 and n x k2. I can see two approaches: a loop on k1 and a loop on k2. But I cannot figure a solution that avoids the loop? Is it possible? (I don't refer to apply or lapply etc either as they are just hidden loops so, correct me if I'm wrong, I can't see they hold any real advantage here). The following does exactly what I want (except for the loops). My aim is to find the solution which minimises processing time. cheers Dave ## Basic paramters k1=3 k2=2 n=10 m1 = matrix (1:(n*k1), nrow=n, ncol=k1) m2 = matrix (1:(n*k2), nrow=n, ncol=k2) ## Approach 1: loop on k1 output1 = matrix(0,nrow=n,ncol=k2) pt1 = proc.time(for (i in 1:k1) output1 = output1 + m1[,i]*m2) ## Approach 2: loop on k2 output2 = matrix(0,nrow=n,ncol=k2) pt2 = proc.time(for (i in 1:k2) output2[,i] = rowSums( m1*m2[,i] )) ## Same result sum(output1-output2) -- David Pleydell Laboratoire de Biologie Environnementale USC INRA-EA 3184 Université de Franche-Comté Place Leclerc F 25030 Besançon France (0033) 0381665763 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Aggregation of data frame with calculations of proportions
I can drink a virtual beer in a bar in Second Life and put it on your tab. On 6/27/07, Mark Wardle [EMAIL PROTECTED] wrote: Dear Jim, On 26/06/07, jim holtman [EMAIL PROTECTED] wrote: I think something like this will do it for you. set.seed(1) n - 10 x - data.frame(a=sample(1:100,n), b=sample(1:100,n),d=sample(1:100,n)) x$a[c(1,5)] - NA x$b[c(7,6,4)] - NA x$d[c(5,8)] - NA x$total - rowSums(x, na.rm=TRUE) x$type - sample(1:3, n, replace=TRUE) by(x, list(x$type), function(z){ apply(z[,1:3], 2, calc.prevalence, total=z$total) }) [...SNIP...] -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? It works perfectly. The problem now is how to send over that beer I owe you! Many thanks, Best wishes, -- Dr. Mark Wardle Clinical research fellow and specialist registrar, Neurology Cardiff, UK -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Import from excel
Hello, I have imported data from Excel using the command cours=read.delim(w:/apprentissage/cours_2.txt) after transforming my initial file with tab delimiters It seemed to work It is 2-dimensionnal. When I type cours[5,5], I get this type of message : [1] 0,9760942761824 Levels: 0,495628477 0,893728761 0,89640592 0,903398558 ... 3,864414217 And when I want to multiply it, for example by 2 (cours[5,5]*2), I get : Warning message:* ceci n'est pas pertinent pour des variables facteurs in: Ops.factor(cours[5, 5], 2) i.e. approximately this is not relevant for factor variables. What can I do if I want to manipulate my variables ? Thank you very much _ stallées directement dans votre Messenger ! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] cmdscale(eurodist)
Dear all, I have a question regarding the 'y - -loc[,2]' in ?cmdscale. Although I see that the plot is more sensible when using the '-loc' instead of just 'y - loc[,2]', I don't understand if there is a statistical reason to do '-loc[,2]'. So is this just to make the graph look better, or should I always use -loc for the y-axis of a similar plot for a completely different data set. Kind regards, Paul Lemmens __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Import from excel
Bruce Willy wrote: Hello, I have imported data from Excel using the command cours=read.delim(w:/apprentissage/cours_2.txt) after transforming my initial file with tab delimiters It seemed to work It is 2-dimensionnal. When I type cours[5,5], I get this type of message : [1] 0,9760942761824 Levels: 0,495628477 0,893728761 0,89640592 0,903398558 ... 3,864414217 And when I want to multiply it, for example by 2 (cours[5,5]*2), I get : Warning message:* ceci n'est pas pertinent pour des variables facteurs in: Ops.factor(cours[5, 5], 2) i.e. approximately this is not relevant for factor variables. What can I do if I want to manipulate my variables ? Thank you very much You might try the following: cours - read.delim(w:/apprentissage/cours_2.txt, dec=,) See the dec argument on the help page for read.delim(). _ stallées directement dans votre Messenger ! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Import from excel
Thank you, but it still doesn't work completely Thanks to you and the dec=, option, I can now do cours[5,5]*5 and get the exact value But I still cannot do matrix operations like cours[2,]%*%cours[5,] It says the arguments are neither matrix nor vectors. :( Date: Wed, 27 Jun 2007 09:30:32 -0400 From: [EMAIL PROTECTED] Subject: Re: [R] Import from excel To: [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Bruce Willy wrote: Hello,I have imported data from Excel using the command cours=read.delim(w:/apprentissage/cours_2.txt) after transforming my initial file with tab delimitersIt seemed to work It is 2-dimensionnal. When I type cours[5,5], I get this type of message : [1] 0,9760942761824 Levels: 0,495628477 0,893728761 0,89640592 0,903398558 ... 3,864414217 And when I want to multiply it, for example by 2 (cours[5,5]*2), I get : Warning message:* ceci n'est pas pertinent pour des variables facteurs in: Ops.factor(cours[5, 5], 2) i.e. approximately this is not relevant for factor variables.What can I do if I want to manipulate my variables ?Thank you very much You might try the following: cours - read.delim(w:/apprentissage/cours_2.txt, dec=,) See the dec argument on the help page for read.delim(). _ stallées directement dans votre Messenger ![[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 _ stallées directement dans votre Messenger ! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Import from excel
Hi [EMAIL PROTECTED] napsal dne 27.06.2007 15:43:53: Thank you, but it still doesn't work completely Thanks to you and the dec=, option, I can now do cours[5,5]*5 and get the exact value But I still cannot do matrix operations like cours[2,]%*%cours[5,] As only you have cours we can only guess. You read it into data.frame which can have columns of different type. So my bet is, that you have one or more columns which is not numeric. See how your cours looks like by str(cours) Regards Petr BTW. Maybe is time to look at some docummentation to R, especially R intro. It says the arguments are neither matrix nor vectors. :( Date: Wed, 27 Jun 2007 09:30:32 -0400 From: [EMAIL PROTECTED] Subject: Re: [R] Import from excel To: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] math.ethz.ch Bruce Willy wrote: Hello,I have imported data from Excel using the command cours=read.delim(w:/apprentissage/cours_2.txt) after transforming my initial file with tab delimitersIt seemed to workIt is 2-dimensionnal. When I type cours[5,5], I get this type of message : [1] 0,9760942761824 Levels: 0,495628477 0,893728761 0,89640592 0,903398558 ... 3,864414217 And when I want to multiply it, for example by 2 (cours[5,5]*2), I get : Warning message:* ceci n'est pas pertinent pour des variables facteurs in: Ops.factor(cours[5, 5], 2) i.e. approximately this is not relevant for factor variables.What can I do if I want to manipulate my variables ?Thank you very much You might try the following: cours - read.delim(w:/apprentissage/cours_2.txt, dec=,) See the dec argument on the help page for read.delim(). _ stallées directement dans votre Messenger ![[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 _ stallées directement dans votre Messenger ! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Import from excel
Thank you, it works now I'm sorry, I have worked all year with R but with simulated data (except one time actually) Subject: RE: [R] Import from excel Date: Wed, 27 Jun 2007 10:01:51 -0400 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] cours is a dataframe not a matrix. Try: cours[2,]*cours[5,] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bruce Willy Sent: Wednesday, June 27, 2007 9:44 AM To: Chuck Cleland Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Import from excel Thank you, but it still doesn't work completely Thanks to you and the dec=, option, I can now do cours[5,5]*5 and get the exact value But I still cannot do matrix operations like cours[2,]%*%cours[5,] It says the arguments are neither matrix nor vectors. :( Date: Wed, 27 Jun 2007 09:30:32 -0400 From: [EMAIL PROTECTED] Subject: Re: [R] Import from excel To: [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Bruce Willy wrote: Hello,I have imported data from Excel using the command cours=read.delim(w:/apprentissage/cours_2.txt) after transforming my initial file with tab delimitersIt seemed to workIt is 2-dimensionnal. When I type cours[5,5], I get this type of message : [1] 0,9760942761824 Levels: 0,495628477 0,893728761 0,89640592 0,903398558 ... 3,864414217 And when I want to multiply it, for example by 2 (cours[5,5]*2), I get : Warning message:* ceci n'est pas pertinent pour des variables facteurs in: Ops.factor(cours[5, 5], 2) i.e. approximately this is not relevant for factor variables.What can I do if I want to manipulate my variables ?Thank you very much You might try the following: cours - read.delim(w:/apprentissage/cours_2.txt, dec=,) See the dec argument on the help page for read.delim(). _ stallées directement dans votre Messenger ![[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 _ stallées directement dans votre Messenger ! [[alternative HTML version deleted]] _ Le blog Messenger de Michel, candidat de la Nouvelle Star : analyse, news, coulisses A découvrir ! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lme correlation structures
Hi all, I've been using SAS proc mixed to fit linear mixed models and would like to be able to fit the same models in R. Two things in particular: 1) I have longitudinal data and wish to allow for different repeated measures covariance parameter estimates for different groups (men and women), each covariance matrix having the same structure. In proc mixed this would be done by specifying group= in the REPEATED statement. Is this simple to do in R? (I've tried form=~time|indv/sex for example but this doesn't seem to do the job). 2) I've read that other correlation structures can be specified. Does anyone have any examples of how toeplitz or (first-order) ante-dependence structures can be specified? Many thanks, Gareth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lme correlation structures
Please read ?lme carefully -- the info you seek is there. In particular, the weights argument for changing variance weighting by covariates and the correlation argument for specifying correlation structures. Pinheiro and Bates's MIXED EFFECT MODELS IN S... is the canonical reference (which you should get if you want to use R as you said) that exposits the ideas at greater length. Bert Gunter Genentech Nonclinical Statistics -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gareth Hughes Sent: Wednesday, June 27, 2007 7:50 AM To: r-help@stat.math.ethz.ch Subject: [R] lme correlation structures Hi all, I've been using SAS proc mixed to fit linear mixed models and would like to be able to fit the same models in R. Two things in particular: 1) I have longitudinal data and wish to allow for different repeated measures covariance parameter estimates for different groups (men and women), each covariance matrix having the same structure. In proc mixed this would be done by specifying group= in the REPEATED statement. Is this simple to do in R? (I've tried form=~time|indv/sex for example but this doesn't seem to do the job). 2) I've read that other correlation structures can be specified. Does anyone have any examples of how toeplitz or (first-order) ante-dependence structures can be specified? Many thanks, Gareth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] New package tradeCosts
We would like to announce the availability of the 'tradeCosts' package in R for analysing transaction costs of trading. Version 0.1-0 is now available on CRAN. To take a look, you can: install.packages(tradeCosts) ... vignette(tradeCosts) and play around. This is the first and very basic version of a package that we hope to expand over the next few months. The cost analysis this package performs is currently very basic. We are releasing this version with the goal of getting feedback from potential users on what functionality they would like to see in future releases of the tradecosts package. Aaron Schwartz Luyi Zhao ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] moving-window (neighborhood) analysis
Hello all I was wondering what would be the best way to do a moving-window analysis of a matrix? By moving-window I mean that kind of analysis common in GIS, where each pixel (matrix element) of the resulting map is a function of it neighbors, and the neighborhood is a square matrix. I was hoping there was some function in R that could do that, where I could define the size of the neighborhood, and then apply some function to the values, some function I don't have in GIS packages (like circular statistics). thanks all. Carlos -- +---+ Carlos Henrique Grohmann - Guano Visiting Researcher at Kingston University London - UK Geologist M.Sc - Doctorate Student at IGc-USP - Brazil Linux User #89721 - carlos dot grohmann at gmail dot com +---+ _ Good morning, doctors. I have taken the liberty of removing Windows 95 from my hard drive. --The winning entry in a What were HAL's first words contest judged by 2001: A SPACE ODYSSEY creator Arthur C. Clarke __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to use chi-square to test correlation question
Hi There, There are 300 boy students and 100 girl students in a class. One interesting question is whether boy is smarter than girl or not. first given the exam with a difficulty level 1, the number of the student who got A is below 31 for boy, 10 for girl. Then we increase the difficulty level of the exam to level 2, the number of the student who got A is below 32 for boy, 10 for girl. We did this 10 times, we got the following table score gender level1 level2 levle3 level4 level5 level6 level7 level 8 level9 level10 boy 31 32 33 34 35 36 37 38 39 40 girl 10 10 10 10 10 10 10 10 10 10 My question is how to use chi-square test to test if score is independent of gender. That is whether boys is significantly smarter than girls. I used a chisquare test to do this. The null hypothesis is score is not correlated with gender. and we can also say the null hypothesis is boys are the same smart as girls. the alternative hypothesis is that boys are significantly smarter than girls. boyscore=c(31,32,33,34,35,36,37,38,39,40) girlscore=c(10,10,10,10,10,10,10,10,10,10) ratioscore=boyscore/girlscore; expratio=300/100; #300 boy students and 100 girl students chisq=sum((expratio-ratioscore)^2/expratio) df=9 pvalue=1-pchisq(chisq,df) Since the pvalue (0.9984578) is greater than significance level (0.05), we cannot reject the null hypothesis. Therefore the conclusion is that boys are not significantly smarter than girls. or we can say the conclusion is that score is not correlated with gender. Am I right? Thank you very much. Van __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] moving-window (neighborhood) analysis
See the Spatial section under CRAN's Task views Bert Gunter Genentech Nonclinical Statistics -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Carlos Guâno Grohmann Sent: Wednesday, June 27, 2007 8:27 AM To: r-help@stat.math.ethz.ch Subject: [R] moving-window (neighborhood) analysis Hello all I was wondering what would be the best way to do a moving-window analysis of a matrix? By moving-window I mean that kind of analysis common in GIS, where each pixel (matrix element) of the resulting map is a function of it neighbors, and the neighborhood is a square matrix. I was hoping there was some function in R that could do that, where I could define the size of the neighborhood, and then apply some function to the values, some function I don't have in GIS packages (like circular statistics). thanks all. Carlos -- +---+ Carlos Henrique Grohmann - Guano Visiting Researcher at Kingston University London - UK Geologist M.Sc - Doctorate Student at IGc-USP - Brazil Linux User #89721 - carlos dot grohmann at gmail dot com +---+ _ Good morning, doctors. I have taken the liberty of removing Windows 95 from my hard drive. --The winning entry in a What were HAL's first words contest judged by 2001: A SPACE ODYSSEY creator Arthur C. Clarke __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] xyplot with par
All, Is there are a simple way to plot multiple xyplots on the same page in the code below (it currently overwrites the first plot w/ the second). I searched the archives and saw a similar question but the answer didn't seem to work. thanks dave x1 = rnorm(10) x2 = rnorm (10) y1 = rnorm(10) y2 = rnorm (10) op = par(mfrow = c(2,1)) xyplot(y1 ~ x1) xyplot(y2 ~ x2) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] CORRECTION: Re: BioC2007, August 6-7 ** early registration ends July 1 **
BioC2007: Where Software and Biology Connect August 6-7 in Seattle, WA, USA The BioC2007 developer-focused meeting is on August 8, the day *after* the main conference. In addition, I neglected to mention the poster session on Monday evening. Best, Martin Morgan -- Bioconductor / Computational Biology http://bioconductor.org Martin Morgan [EMAIL PROTECTED] writes: BioC2007: Where Software and Biology Connect August 6-7 in Seattle, WA, USA ** Early registration ends July 1 ** This conference highlights developments in and beyond Bioconductor. A major goal is to discuss the use and design of software for analyzing high throughput biological data. Format: * Scientific talks on both days from 8:30-12:00 * Expanded hands-on lab sessions on both afternoons 1:00-5:30 * Technology overviews and social hour in the evening Get more information and register for the conference at https://secure.bioconductor.org/BioC2007/ A developer focused meeting is on August 5th. For (preliminary) details, please visit: http://wiki.fhcrc.org/bioc/Seattle_Dev_Meeting_2007 See you in August! Martin Morgan -- Bioconductor / Computational Biology http://bioconductor.org __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Martin Morgan Bioconductor / Computational Biology http://bioconductor.org __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] xyplot with par
On 6/27/07, Afshartous, David [EMAIL PROTECTED] wrote: All, Is there are a simple way to plot multiple xyplots on the same page in the code below (it currently overwrites the first plot w/ the second). I searched the archives and saw a similar question but the answer didn't seem to work. thanks dave x1 = rnorm(10) x2 = rnorm (10) y1 = rnorm(10) y2 = rnorm (10) op = par(mfrow = c(2,1)) xyplot(y1 ~ x1) xyplot(y2 ~ x2) See help(print.trellis), which has examples. -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Solving a system of nonlinear equations
Hi All, Here is a modification of nlsolve() that I had submitted before. The new version of nlsolve() has the option to generate multiple random starting values in order to improve the chances of locating the zeros of the nonlinear system. The last test example in the attached file, the Freudenstein-Roth function, shows the usefulness of the multiple random starts. Hope this is useful, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html ## nlsolve - function(par, fn, method=BFGS, nstarts = 1, ...) { ### # A solver for finding a zero of a system of non-linear equations # Actually minimizes the squared-norm of the set of functions by calling optim() # Uses the BFGS algorithm within optim() # All the control parameters can be passed as in the call to optim() # Uses a random multiple start approach to locate the zeros of the system # # Author: Ravi Varadhan, Center on Aging and Health, Johns Hopkins University, [EMAIL PROTECTED] # # June 21, 2007 # func - function(x, ...) sum(fn(x, ...)^2) ans - optim(par, fn=func, method=method, ...) err - sqrt(ans$val/length(par)) istart - 1 while (err 0.01 istart nstarts) { par - par * ( 1 + runif(length(par), -1, 1) ) # generating random starting values ans - try (optim(par, fn=func, method=method, ...)) if (class(ans) != try-error) err - sqrt(ans$val/length(par)) istart - istart + 1 } if (err 0.01) cat( \n Caution: Zero of the function has not been located!!! \n Increase nstart \n \n) ans } # ## # # Some examples illustrating the use of nlsolve() # expo1 - function(p) { # From La Cruz and Raydan, Optim Methods and Software 2003, 18 (583-599) n - length(p) f - rep(NA, n) f[1] - exp(p[1] - 1) - 1 f[2:n] - (2:n) * (exp(p[2:n] - 1) - p[2:n]) f } n - 50 p0 - runif(n) nlsolve(par=p0, fn=expo1) expo3 - function(p) { # From La Cruz and Raydan, Optim Methods and Software 2003, 18 (583-599) n - length(p) f - rep(NA, n) onm1 - 1:(n-1) f[onm1] - onm1/10 * (1 - p[onm1]^2 - exp(-p[onm1]^2)) f[n] - n/10 * (1 - exp(-p[n]^2)) f } n - 15 p0 - (1:n)/(4*n^2) nlsolve(par=p0, fn=expo3) func1 - function(x) { f - rep(0,3) f[1] - 1/3*cos(x[2]*x[3]) - x[1] + 1/6 f[2] - 1/9 * sqrt(x[1]^2 + sin(x[3])+ 1.06) - x[2] - 0.1 f[3] - -1/20*exp(-x[1]*x[2]) - x[3] - (10*pi - 3)/60 f } p0 - runif(3) nlsolve(par=p0, fn=func1) # This example illustrates the use of multiple random starts to obtain the global minimum of zero (i.e. the roots of the system) # froth - function(p){ # Freudenstein and Roth function (Broyden, Mathematics of Computation 1965, p. 577-593) f - rep(NA,length(p)) f[1] - -13 + p[1] + (p[2]*(5 - p[2]) - 2) * p[2] f[2] - -29 + p[1] + (p[2]*(1 + p[2]) - 14) * p[2] f } p0 - c(3,2) # this gives the zero of the system nlsolve(par=p0, fn=froth) p0 - c(1,1) # this gives the local minimum that is not the zero of the system nlsolve(par=p0, fn=froth) nlsolve(par=p0, fn=froth, nstart=100) p0 - rpois(2,10) nlsolve(par=p0, fn=froth) nlsolve(par=p0, fn=froth, nstart=10) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] no applicable method
I'm getting started in R, and I'm trying to use one of the gradient boosting packages, mboost. I'm already installed the package with install.packages(mboost) and loaded it with library(mboost). My problem is that when I attempt to call glmboost, I get a message that Error in glmboost() : no applicable method for glmboost . Does anybody have an idea of what kind of problem this is indicative of? Kyle Ellrott __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] stepAIC on lm() where response is a matrix..
dear R users, I have fit the lm() on a mtrix of responses. i.e M1 = lm(cbind(R1,R2)~ X+Y+0). When i use summary(M1), it shows details for R1 and R2 separately. Now i want to use stepAIC on these models. But when i use stepAIC(M1) an error message comes saying that dropterm.mlm is not implemented. What is the way out to use stepAIC in such cases. regards, The fish are biting. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to use chi-square to test correlation question
someone else might have another viewpoint but I think your categories needs to be score categories ( 60-65, 65-70 etc ) and the data needs to be the number of girls and boys that fall into a category. I've never seen this below a certain value Methodology but maybe it's popular and I just don't know about it. I'm unsure if you can assign success and failure in a chi square framework by below a certain value. I don't think so. And I think That you also have seperate multiple experiments ( each level seems like a new experiment to me ) so your alpha level is going to be messed up also. I'd be interested in hearing other viewpoints but I'm fairly certain that your approach needs modifications. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, June 27, 2007 11:51 AM To: [EMAIL PROTECTED] Subject: [R] how to use chi-square to test correlation question Hi There, There are 300 boy students and 100 girl students in a class. One interesting question is whether boy is smarter than girl or not. first given the exam with a difficulty level 1, the number of the student who got A is below 31 for boy, 10 for girl. Then we increase the difficulty level of the exam to level 2, the number of the student who got A is below 32 for boy, 10 for girl. We did this 10 times, we got the following table score gender level1 level2 levle3 level4 level5 level6 level7 level 8 level9 level10 boy 31 32 33 34 35 36 37 38 39 40 girl 10 10 10 10 10 10 10 10 10 10 My question is how to use chi-square test to test if score is independent of gender. That is whether boys is significantly smarter than girls. I used a chisquare test to do this. The null hypothesis is score is not correlated with gender. and we can also say the null hypothesis is boys are the same smart as girls. the alternative hypothesis is that boys are significantly smarter than girls. boyscore=c(31,32,33,34,35,36,37,38,39,40) girlscore=c(10,10,10,10,10,10,10,10,10,10) ratioscore=boyscore/girlscore; expratio=300/100; #300 boy students and 100 girl students chisq=sum((expratio-ratioscore)^2/expratio) df=9 pvalue=1-pchisq(chisq,df) Since the pvalue (0.9984578) is greater than significance level (0.05), we cannot reject the null hypothesis. Therefore the conclusion is that boys are not significantly smarter than girls. or we can say the conclusion is that score is not correlated with gender. Am I right? Thank you very much. Van __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Matlab end operator
Dear list members, I use both R and Matlab and find that each has its own strengths. Matlab definitely has the edge when it comes to the interactivity of its graphs. In addition I find the little operator end extremely useful in indexing arrays. (as in x(1:end,) ) The notation is MUCH more cumbersome in R using nrow() and ncol() recursively (as in x[1:nrow(x), ] ). Is there a package that might contain an implementation of the end operator ? Thanks ! Markus __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Timer
Hello, This might be a very basic question but I was not sure how to go about it. I just wanted to calcluate the time it takes to run my program. Basically I was to put a timer at the start and the end of the program in order to see how much time it takes to give the output (similar to tic-tac in MATLAB) . Any help will be appreciated. Thanks, Suman [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Timer
see ?system.time -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O On 27/06/07, suman Duvvuru [EMAIL PROTECTED] wrote: Hello, This might be a very basic question but I was not sure how to go about it. I just wanted to calcluate the time it takes to run my program. Basically I was to put a timer at the start and the end of the program in order to see how much time it takes to give the output (similar to tic-tac in MATLAB) . Any help will be appreciated. Thanks, Suman [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Strange RODBC problem
On 6/26/07, Richard M. Heiberger [EMAIL PROTECTED] wrote: I am using RODBC to collect data from an ODBC connection to an MS Access Database. Everything seems to be working well except datetimes between March 12, 2006 02:00 and 02:59 get moved one hour forward. This does not seem to be happening with Excel connecting to the same connection. March 12 seems a bit early for Daylight savings time. What am I doing wrong? In 2007, the US moved daylight savings to March 11 instead of the more traditional first weekend in April. It continues to November 4, a week later than before. Google daylight savings 2007 for lots of background. Some MS programs did not make the switch until April 1, therefore my calendars doubled up continuing appointments. From your experience, it looks like some programs are retroactively misapplying the change to 2006. This appears to be a strange interaction between R and Windows. If I have windows set to automatically adjust clock for Daylight Savings changes then in R I get the following as.POSIXct(2006-03-12 01:05:00 EST5EDT,tz=EST) [1] 2006-03-12 01:05:00 EST as.POSIXct(2006-03-12 03:05:00 EST5EDT,tz=EST) [1] 2006-03-12 02:05:00 EST If I uncheck the automatically adjust clock for Daylight Savings checkbox I get as.POSIXct(2006-03-12 01:05:00 EST5EDT,tz=EST) [1] 2006-03-12 01:05:00 EST as.POSIXct(2006-03-12 03:05:00 EST5EDT,tz=EST) [1] 2006-03-12 03:05:00 EST All of which makes my head hurt. At least now I can read the query with as.is=TRUE and set the tz explicitly. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re : Help please for graphics!
To whom it may concern, I want to plot two or more graphs in the same window by the means of the plot command. I have tried the option add=TRUE but this last does not work! Have you an hit for me please? Thank you very much for your attention. Bernard Colin [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matlab end operator
Hello Markus, On 6/27/07, Markus Loecher [EMAIL PROTECTED] wrote: Dear list members, I use both R and Matlab and find that each has its own strengths. Matlab definitely has the edge when it comes to the interactivity of its graphs. I also use both. R definitely has the edge when it comes to do perform statistical data analyses :) (and also when you consider the price...) In addition I find the little operator end extremely useful in indexing arrays. (as in x(1:end,) ) You mean 'x(1:end,1:end)' or 'x(:,:)' (':' is equivalent to 1:end) When I go from R to Matlab, I tend to forget to type the ':' (a[,2] in R is a(:,2) in Matlab.) The interest of 'end' is clearer when the starting index is larger than 1 as in, e.g., 'x(2:end)' Yet note that in R, you can use negative indexes: x[-1] is the R equivalent of Matlab's x(2:end) x[-(1:(n-1))] is equivalent to x(n:end) I agree that R syntax may be a bit less elegant in this particular situation (but try to write the equivalent of a[-2,] in Matlab) Personally, I would stick to x[n:length(x)] (or a[n:nrow(a),] for a matrix). Anyway this kind of code would probably appear inside a loop and I would put the numbers of rows or columns in variables if there are needed more than once. Best, -- Christophe Pallier [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re : Help please for graphics!
par(mfrow=c(2,1)) plot(...plot1...) plot(plot2...) On 6/2/07, Bernard Colin [EMAIL PROTECTED] wrote: To whom it may concern, I want to plot two or more graphs in the same window by the means of the plot command. I have tried the option add=TRUE but this last does not work! Have you an hit for me please? Thank you very much for your attention. Bernard Colin [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 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? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] read.xls problem
Hi to all, I have a strange problem There was a Excel file with 5 sheets I deleted sheet 2 and 4. as all the times before I tried to read the sheets with data1- read.xls(excelfile_2,sheet=1, as.is = TRUE ,verbose=FALSE, perl=C:/perl/bin/perl.exe) data2- read.xls(excelfile_2,sheet=2, as.is = TRUE ,verbose=FALSE, perl=C:/perl/bin/perl.exe) data3- read.xls(excelfile_2,sheet=3, as.is = TRUE ,verbose=FALSE, perl=C:/perl/bin/perl.exe) but only the folloing code reads the sheets well data1- read.xls(excelfile_2,sheet=1, as.is = TRUE ,verbose=FALSE, perl=C:/perl/bin/perl.exe) data3- read.xls(excelfile_2,sheet=3, as.is = TRUE ,verbose=FALSE, perl=C:/perl/bin/perl.exe) data5- read.xls(excelfile_2,sheet=5, as.is = TRUE ,verbose=FALSE, perl=C:/perl/bin/perl.exe) Does anybody know whether this is normal? I never had this problem before. And if it is normal I wonder about how to find the sheet numbers Regards Knut __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Condensed PCA Results
Hello all, I'm currently using R to do PCA Analysis, and was wondering if anyone knew the specific R Code that could limit the output of the PCA Analysis so that you only get the Principal Component features as your output and none of the extraneous words or numbers that you don't want. If that was unclear, let me use linear regression as an example: lm(y~x) is the normal command for linear regression, but it produces other text and string aside from the regression coefficients. lm(y~x)$coefficients gives you just the regression coefficients when you carry out the command. When I carry out PCA on R, typically I get: Standard deviations: [1] 83.732400 14.212402 6.489426 2.4827900 Rotation: PC1 PC2 PC3 PC4 Murder 0.04170432 -0.04482166 0.07989066 -0.99492173 Assault 0.99522128 -0.05876003 -0.06756974 0.03893830 UrbanPop 0.04633575 0.97685748 -0.20054629 -0.05816914 Rape 0.07515550 0.20071807 0.97408059 0.07232502 I want to get only: PC1 PC2 PC3 PC4 Murder 0.04170432 -0.04482166 0.07989066 -0.99492173 Assault 0.99522128 -0.05876003 -0.06756974 0.03893830 UrbanPop 0.04633575 0.97685748 -0.20054629 -0.05816914 Rape 0.07515550 0.20071807 0.97408059 0.07232502 I want to be able to do this because I am actually carrying out PCA in RExcel. I am able to do the PCA analysis using the prcomp(data) and GetArray commands, but doing that puts all of the aforementinoed output in a single row of cells instead of assigning each word and number its own individual cell. I figured this dealt more with R code than Excel, so I decided to post it here. Can anyone help me out? Is there a command that can carry out what I've mentioned? Wayne __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Condensed PCA Results
if x is your matrix, then prcomp(x)$rotation gets you what you want Katharina Wayne Aldo Gavioli schrieb: Hello all, I'm currently using R to do PCA Analysis, and was wondering if anyone knew the specific R Code that could limit the output of the PCA Analysis so that you only get the Principal Component features as your output and none of the extraneous words or numbers that you don't want. If that was unclear, let me use linear regression as an example: lm(y~x) is the normal command for linear regression, but it produces other text and string aside from the regression coefficients. lm(y~x)$coefficients gives you just the regression coefficients when you carry out the command. When I carry out PCA on R, typically I get: Standard deviations: [1] 83.732400 14.212402 6.489426 2.4827900 Rotation: PC1 PC2 PC3 PC4 Murder 0.04170432 -0.04482166 0.07989066 -0.99492173 Assault 0.99522128 -0.05876003 -0.06756974 0.03893830 UrbanPop 0.04633575 0.97685748 -0.20054629 -0.05816914 Rape 0.07515550 0.20071807 0.97408059 0.07232502 I want to get only: PC1 PC2 PC3 PC4 Murder 0.04170432 -0.04482166 0.07989066 -0.99492173 Assault 0.99522128 -0.05876003 -0.06756974 0.03893830 UrbanPop 0.04633575 0.97685748 -0.20054629 -0.05816914 Rape 0.07515550 0.20071807 0.97408059 0.07232502 I want to be able to do this because I am actually carrying out PCA in RExcel. I am able to do the PCA analysis using the prcomp(data) and GetArray commands, but doing that puts all of the aforementinoed output in a single row of cells instead of assigning each word and number its own individual cell. I figured this dealt more with R code than Excel, so I decided to post it here. Can anyone help me out? Is there a command that can carry out what I've mentioned? Wayne __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] skeleton for C code?
Dear R experts---I would like to write a replacement for the read.csv function that is less general, but also more efficient. could someone please provide me with a skeleton function that shows me how to read the arguments and return a data frame for a call to a C function that handles returned.data.frame = my.read.csv(file, header = TRUE, sep = ,, quote=\, dec=., fill = TRUE, comment.char=, ...) this may be very difficult, of course, in which case writing such a function would not be worth it. I guess I would be happy just to learn how to return a basic data frame that holds data vectors that are either strings or numbers---nothing more complex. help appreciated. /iaw __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] running saved scripts
Hi All, I have a rather naive question. I need to run some simple calculations such as read.table, resid, and quantile on a data file. How can I save these commands in a text file and ask R to run this text file? Thanks. Jiong Zhang The email message (and any attachments) is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message (and any attachments). Thank You. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] running saved scripts
put into a file called abc.R or whatever, source(abc.R) check ?source On 6/27/07, Jiong Zhang, PhD [EMAIL PROTECTED] wrote: Hi All, I have a rather naive question. I need to run some simple calculations such as read.table, resid, and quantile on a data file. How can I save these commands in a text file and ask R to run this text file? Thanks. Jiong Zhang The email message (and any attachments) is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message (and any attachments). Thank You. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Weiwei Shi, Ph.D Research Scientist GeneGO, Inc. Did you always know? No, I did not. But I believed... ---Matrix III __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] running saved scripts
Jiong Zhang, PhD schrieb: Hi All, I have a rather naive question. I need to run some simple calculations such as read.table, resid, and quantile on a data file. How can I save these commands in a text file and ask R to run this text file? Thanks. There is a very comfortable editor including run functions (run all, run marked, run until window end and run line by line) available: http://www.sciviews.org/Tinn-R/ And you can use the R-Editor (in the Menu: File- new script) There you can run the marked code or line by line with STGR R Knut __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] SEM model fit
I wonder if someone could explain why, when I perform confirmatory factor-analysis model using polychoric correlations why I do not get an estimated confidence interval for the RMSEA. My experience with these type models is that I would obtain a confidence interval estimate. I did not get any warning messages with the output. RESULTS: Model Chisquare = 1374 Df = 185 Pr(Chisq) = 0 Chisquare (null model) = 12284 Df = 210 Goodness-of-fit index = 0.903 Adjusted goodness-of-fit index = 0.88 RMSEA index = 0.0711 90% CI: (NA, NA) Bentler-Bonnett NFI = 0.888 Tucker-Lewis NNFI = 0.888 Bentler CFI = 0.902 SRMR = 0.0682 BIC = 51.4 SYNTAX rm(sem.enf.rq) mdl.rq - specify.model() enf - law2, NA, 1 enf - law3, lam2, 1 enf - law4, lam3, 1 enf - enf, psi1, 0.6 law2 - law2, theta1, 0.3 law3 - law3, theta2, 0.3 law4 - law4, theta3, 0.5 gender- enf, a1, 0.2 incomex - enf, a2, 0.2 oftdrnkr - enf, a3, 0.2 attn - nvatt, NA, 1 attn - crimatt, lam4, 1.3 attn - asltatt, lam5, 1.2 attn - attn, psi2, 0.5 nvatt - nvatt,theta4, 0.5 crimatt - crimatt, theta5, 0.1 asltatt - asltatt, theta6, 0.2 gender- attn, a4, 0.2 acon - acon1,NA, 1 acon - acon2,lam4, 1.5 acon - acon,psi2, 0.1 mcon - mvcon1, NA, 1 mcon - mvcon2, lam5, 1 mcon - mcon,psi3, 0.3 ocon - oicon1, NA, 1 ocon - oicon2, lam6, 1 ocon - ocon,psi4, 0.2 con- acon, NA, 1 con- mcon, lam7, 0.8 con- ocon, lam8, 0.9 con - con, psi5, 0.3 acon1 - acon1, theta7, 0.4 acon2 - acon2, theta8, 0.2 mvcon1- mvcon1, theta9, 0.2 mvcon2- mvcon2, theta10, 0.3 oicon1- oicon1, theta11, 0.2 oicon2- oicon2, theta12, 0.3 gender- con, a5, 0.1 incomex - con, a6, -0.1 oftdrnkr - con, a7, -0.2 attn - con, gam1, 0.2 sev - aophys, NA,1 sev - mvphys, NA,1 sev - oiphys, NA,1 sev - sev, psi6, 0.5 aophys- aophys, theta13,0.5 mvphys- mvphys, theta14,0.5 oiphys- oiphys, theta14,0.5 con - sev, gam3, 0.8 prev - mvpct,NA,1 prev - oipct,NA,1 prev - alcpct, NA,1 prev - prev,psi8, 0.4 mvpct - mvpct, theta15,0.5 oipct - oipct, theta15,0.5 alcpct- alcpct, theta15,0.5 con - prev, gam5, 0.8 prev - enf, gam6, 0.4 sem.enf.rq - sem(ram = mdl.rq, S = hcor(dx), N = nrow(dx), obs.v = names(dx), raw = F, fixed = names(dx)[4:6], par.size = 's', maxiter = 1e3, analytic = F, gradtol = 1e-10) ##set raw to False summary(obj = sem.enf.rq, dig = 3, conf = 0.9) Respectfully, Frank Lawrence __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] exaustive subgrouping or combination
Dear Colleagues, I am looking for a package or previous implemented R to subgroup and exaustively divide a vector of squence into 2 groups. For example: 1, 2, 3, 4 I want to have a group of 1, (2,3,4) (1,2), (3,4) (1,3), (2,4) (1,4), (2,3) (1,2,3), 4 (2,3), (1,4) ... Can someone help me as how to implement this? I get some imaginary problem when the sequence becomes large. Thanks much in advance. -- Waverley @ Palo Alto [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] running Rcmdr
Yes, of course, i know it, and i have installed all packages i need, but this is not what i am searching. I want to do that only with a command line without have to type only first R and after library(Rcmdr); i only want to type something like R library(Rcmdr) but i know it´s doesn´t work and i´m looking for something like that. I hope you have already understood my question. Thank you Felipe Carrillo escribió: If you have already installed Rcmdr from the internet (Cran site) then when you open R window if you type library(Rcmdr) you should see the R commander window and use it just like you would use R command window. */Manuel [EMAIL PROTECTED]/* wrote: Thanks for your answer, but i think i dont do correctly my question. I need the command line to run Rmdr, like that: R Rcmdr or R loadRcmdr.R where loadRcmdr has library(Rcmdr). or something like that. I tried the last example, but when Rcmdr is executed, later it is closed. About RProfile.site, i dont know what i have to change. If you think its useful to me, please explain me. Thanks. Felipe Carrillo escribió: First, you need to install the Rcmdr packages and then in the R Command window or Tinn-R window type library(Rcmdr) without the quotation marks. In addition, if you want Rcmdr to start automatically everytime you start R, go to the following path C:\Program Files\R\R-2.5.0\etc\RProfile.site if you installed R in program files, otherwise follow your own path and type the same command library(Rcmdr) and the R commander window should pop up everytime you start R */Manuel /* wrote: Hi to all, i want to know how can run Rcmdr automatically , or how to load a library in the call of R greetings __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center. http://us.rd.yahoo.com/evt=48246/*http://autos.yahoo.com/green_center/;_ylc=X3oDMTE5cDF2bXZzBF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDZ3JlZW4tY2VudGVy __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error message survreg.fit
Dear All, I am doing a parametric survival analysis with: fit - survreg(Surv(xyz$start, xyz$stop, xyz$event, type=interval) ~ 1, dist='loglogistic') At this point I do not want to look into covariates, hence the '~1' as model formulation. As event types I have exact, interval, and right censored lifetime data. Everything works fine. For reasons that are not important here now, I wanted to look for the effects of 'randomly' re-allocating event types to the lifetime data. However, when I did this (keeping everything else the same), R returned this error message: Error in survreg.fit(X, Y, weights, offset, init = init, controlvals = control, : NA/NaN/Inf in foreign function call (arg 9) I am puzzled by this error message and can't find anything in the archives etc. Your input would be greatly appreciated. Best regards, Michael Michael Drescher Ontario Forest Research Institute Ontario Ministry of Natural Resources 1235 Queen St East Sault Ste Marie, ON, P6A 2E3 Tel: (705) 946-7406 Fax: (705) 946-2030 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matlab end operator
Hi Markus, Christophe I also use both matlab and R. I agree with Christophe: you can define the 'end' functionality by nrow or length also have a look at the following link that may be useful. http://mathesaurus.sourceforge.net/octave-r.html good luck AA. - Original Message - From: Christophe Pallier [EMAIL PROTECTED] To: Markus Loecher [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Sent: Wednesday, June 27, 2007 2:43 PM Subject: Re: [R] Matlab end operator Hello Markus, On 6/27/07, Markus Loecher [EMAIL PROTECTED] wrote: Dear list members, I use both R and Matlab and find that each has its own strengths. Matlab definitely has the edge when it comes to the interactivity of its graphs. I also use both. R definitely has the edge when it comes to do perform statistical data analyses :) (and also when you consider the price...) In addition I find the little operator end extremely useful in indexing arrays. (as in x(1:end,) ) You mean 'x(1:end,1:end)' or 'x(:,:)' (':' is equivalent to 1:end) When I go from R to Matlab, I tend to forget to type the ':' (a[,2] in R is a(:,2) in Matlab.) The interest of 'end' is clearer when the starting index is larger than 1 as in, e.g., 'x(2:end)' Yet note that in R, you can use negative indexes: x[-1] is the R equivalent of Matlab's x(2:end) x[-(1:(n-1))] is equivalent to x(n:end) I agree that R syntax may be a bit less elegant in this particular situation (but try to write the equivalent of a[-2,] in Matlab) Personally, I would stick to x[n:length(x)] (or a[n:nrow(a),] for a matrix). Anyway this kind of code would probably appear inside a loop and I would put the numbers of rows or columns in variables if there are needed more than once. Best, -- Christophe Pallier [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] running Rcmdr
Either one of these works under Linux. 'r' is our own littler (see Google for it), Rscript comes with R 2.5.0 or greater $ r -e 'suppressMessages(library(Rcmdr)); while (TRUE) Sys.sleep(1)' $ Rscript -e 'suppressMessages(library(Rcmdr)); while (TRUE) Sys.sleep(1)' Hth, Dirk -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] running Rcmdr
I am very much a novice R user, and this is my first post to the List, but given that disclaimer, perhaps you could put library(Rcmdr) as a line in your Rprofile.site file? I think this contains commands that are run every time R is opened. [At least, I noticed after I installed my Tinn-R and got it to communicate with R, that certain R packages necessary for use of Tinn-R now get run every time I open Tinn-R (and R opens with it.)] That way, typing R on the command line (might!) run Rcmdr too. --Chris Christopher W. Ryan, MD SUNY Upstate Medical University Clinical Campus at Binghamton 40 Arch Street, Johnson City, NY 13790 cryanatbinghamtondotedu PGP public keys available at http://home.stny.rr.com/ryancw/ If you want to build a ship, don't drum up the men to gather wood, divide the work and give orders. Instead, teach them to yearn for the vast and endless sea. [Antoine de St. Exupery] Manuel wrote: Yes, of course, i know it, and i have installed all packages i need, but this is not what i am searching. I want to do that only with a command line without have to type only first R and after library(Rcmdr); i only want to type something like R library(Rcmdr) but i know it´s doesn´t work and i´m looking for something like that. I hope you have already understood my question. Thank you Felipe Carrillo escribió: If you have already installed Rcmdr from the internet (Cran site) then when you open R window if you type library(Rcmdr) you should see the R commander window and use it just like you would use R command window. */Manuel [EMAIL PROTECTED]/* wrote: Thanks for your answer, but i think i dont do correctly my question. I need the command line to run Rmdr, like that: R Rcmdr or R loadRcmdr.R where loadRcmdr has library(Rcmdr). or something like that. I tried the last example, but when Rcmdr is executed, later it is closed. About RProfile.site, i dont know what i have to change. If you think its useful to me, please explain me. Thanks. Felipe Carrillo escribió: First, you need to install the Rcmdr packages and then in the R Command window or Tinn-R window type library(Rcmdr) without the quotation marks. In addition, if you want Rcmdr to start automatically everytime you start R, go to the following path C:\Program Files\R\R-2.5.0\etc\RProfile.site if you installed R in program files, otherwise follow your own path and type the same command library(Rcmdr) and the R commander window should pop up everytime you start R */Manuel /* wrote: Hi to all, i want to know how can run Rcmdr automatically , or how to load a library in the call of R greetings __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center. http://us.rd.yahoo.com/evt=48246/*http://autos.yahoo.com/green_center/;_ylc=X3oDMTE5cDF2bXZzBF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDZ3JlZW4tY2VudGVy __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Correlation ratio
Hi, I wanted to know how to compute the correlation ratio (eta) between two variables using R. Is there any function to compute the correlation ratio. Any help will be very much appreciated. Thanks, Suman [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] exaustive subgrouping or combination
Do you realize that for n items, there are 2^(n-1) such groups -- since you essentially want all possible subsets divided by 2: all possible subsets and their complements repeats each split twice, backwards and forwards. So this will quickly become ummm... rather large. If you really want to do this, one lazy but inefficient way I can think of is to use expand.grid() to generate your subsets. Here's a toy example that shows you how with n = 4. ## generate a list with four components each of which ## is c(TRUE,FALSE) -- note that a data.frame is a list z - data.frame(matrix(rep(c(TRUE,FALSE),4),nrow=2) ## Now use expand.grid to get all 2^4 possible 4 vectors as rows ix - do.call(expand.grid,z) ## This is essentially what you want. apply(ix[1:8,],1,function(x)(1:4)[x]) ## gives you the list of first splits, while apply(ix[16:9],... gives the complements (note reversal of order). Bert Gunter Genentech Nonclinical Statistics -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Waverley Sent: Wednesday, June 27, 2007 1:57 PM To: r-help@stat.math.ethz.ch Subject: [R] exaustive subgrouping or combination Dear Colleagues, I am looking for a package or previous implemented R to subgroup and exaustively divide a vector of squence into 2 groups. For example: 1, 2, 3, 4 I want to have a group of 1, (2,3,4) (1,2), (3,4) (1,3), (2,4) (1,4), (2,3) (1,2,3), 4 (2,3), (1,4) ... Can someone help me as how to implement this? I get some imaginary problem when the sequence becomes large. Thanks much in advance. -- Waverley @ Palo Alto [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Loading problem with XML_1.9
Hello all, I have loading problem with XML_1.9 under 64 bit R2.3.1, which I got from http://R.research.att.com/. XML_1.9 works fine under 32 bit R2.5.0. I thought that could be installation problem, and I tried install.packages or biocLite, every time the package installed fine, except some warning messages below: ld64 warning: in /usr/lib/libxml2.dylib, file does not contain requested architecture ld64 warning: in /usr/lib/libz.dylib, file does not contain requested architecture ld64 warning: in /usr/lib/libiconv.dylib, file does not contain requested architecture ld64 warning: in /usr/lib/libz.dylib, file does not contain requested architecture ld64 warning: in /usr/lib/libxml2.dylib, file does not contain requested architecture Here is the error messages I got, when XML is loaded: library(XML) Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library '/usr/local/lib64/R/library/XML/libs/XML.so': dlopen(/usr/local/lib64/R/library/XML/libs/XML.so, 6): Symbol not found: _xmlMemDisplay Referenced from: /usr/local/lib64/R/library/XML/libs/XML.so Expected in: flat namespace Error: .onLoad failed in 'loadNamespace' for 'XML' Error: package/namespace load failed for 'XML' I understand that it has been pointed out that Sys.getenv(PATH) needs to be revised in the file XML/R/zzz.R, but I canât even find that file under XML/R/ directory. Does anybody have any idea what might be the problem, and how to solve it? Thanks a lot! BTW, the reason I need to use R64 is that I have memory limitation issue with R 32 bit version when I load some very large XML trees. Session information sessionInfo() Version 2.3.1 Patched (2006-06-27 r38447) powerpc64-apple-darwin8.7.0 attached base packages: [1] methods stats graphics grDevices utils datasets [7] base Weijun __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Gaussian elimination - singular matrix
Hello, I hope it is not a too stupid question. I have a singular matrix A (so not invertible). I want to find a nontrivial nonnegative solution to AX=0 (kernel of A) It is a special matrix A (so maybe this nonnegative solution is unique) The authors of the article suggest a Gaussian elimination method Do you know if R can do that automatically ? I have seen that solve has an option LAPACK but it does not seem to work with me :( Thank you very much _ Le blog Messenger de Michel, candidat de la Nouvelle Star : analyse, news, coulisses A découvrir ! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Gaussian elimination - singular matrix
I am sorry, there is just a mistake : the solution cannot be unique (because it is a vectorial space) (but then I might normalize it) can R find one anyway ? This is equivalent to finding an eigenvector in fact From: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date: Wed, 27 Jun 2007 22:51:41 + Subject: [R] Gaussian elimination - singular matrix Hello, I hope it is not a too stupid question. I have a singular matrix A (so not invertible). I want to find a nontrivial nonnegative solution to AX=0 (kernel of A) It is a special matrix A (so maybe this nonnegative solution is unique) The authors of the article suggest a Gaussian elimination method Do you know if R can do that automatically ? I have seen that solve has an option LAPACK but it does not seem to work with me :( Thank you very much _ Le blog Messenger de Michel, candidat de la Nouvelle Star : analyse, news, coulisses A découvrir ! [[alternative HTML version deleted]] _ Le blog Messenger de Michel, candidat de la Nouvelle Star : analyse, news, coulisses A découvrir ! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to discard data out of polr object
Hi, I would like to discard in-sample data that are stored in the polr object out after estimation. All I need are only the coefficients for estimation. I'm wondering if there is anyway to do this? Thank you. - adschai __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Correlation ratio
On Wed, 27 Jun 2007, suman Duvvuru wrote: Hi, I wanted to know how to compute the correlation ratio (eta) between two variables using R. Is there any function to compute the correlation ratio. Any help will be very much appreciated. help.search(correlation) ?cancor ?lm --- Jeff NewmillerThe . . Go Live... DCN:[EMAIL PROTECTED]Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] levelplot in lattice
Hi, I'm new to lattice. So please kindly be patient with me. I'm trying to arrange groups of levelplots into 3 rows as follows: Row1: Probabilities as functions of x and y, and conditioned on an event factor vector factor(a,b,c) Row2: Number of days as functions of x and y, and conditioned on, again the same event factor(a,b,c) Row2: Costs as functions of x and y, and conditioned on, again the same event factor(a,b,c) I tried the following: windows(); par(mfrow=c(3,1)); levelplot(z ~ x*y|events, probDat); levelplot(z ~ x*y|events, daysDat); levelplot(z ~ x*y|events, costDat); It does not do what I want. It replace the previous plot every time I call a new levelplot. I can't put them into the same matrix and plot them all at once because the scale of each data type is very different, i.e.g probability=c(0,1), days=c(0,10), etc. I'm wondering if you could suggest a way to solve this problem. Also, if I would like to put in mathematical notation on the top strip of the plot instead of using text in my events factor vector, what can I do? Thank you so much in advance. - adschai __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] exaustive subgrouping or combination
On Wed, 27 Jun 2007, Waverley wrote: Dear Colleagues, I am looking for a package or previous implemented R to subgroup and exaustively divide a vector of squence into 2 groups. For example: 1, 2, 3, 4 I want to have a group of 1, (2,3,4) (1,2), (3,4) (1,3), (2,4) (1,4), (2,3) (1,2,3), 4 (2,3), (1,4) ... Can someone help me as how to implement this? help.search(combinations) ?combn Have you read the posting guide mentioned at the bottom of each message on the list? I get some imaginary problem when the sequence becomes large. Thanks much in advance. -- Waverley @ Palo Alto [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. --- Jeff NewmillerThe . . Go Live... DCN:[EMAIL PROTECTED]Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...2k __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] levelplot in lattice
On 6/27/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I'm new to lattice. So please kindly be patient with me. I'm trying to arrange groups of levelplots into 3 rows as follows: Row1: Probabilities as functions of x and y, and conditioned on an event factor vector factor(a,b,c) Row2: Number of days as functions of x and y, and conditioned on, again the same event factor(a,b,c) Row2: Costs as functions of x and y, and conditioned on, again the same event factor(a,b,c) I tried the following: windows(); par(mfrow=c(3,1)); levelplot(z ~ x*y|events, probDat); levelplot(z ~ x*y|events, daysDat); levelplot(z ~ x*y|events, costDat); It does not do what I want. It replace the previous plot every time I call a new levelplot. I can't put them into the same matrix and plot them all at once because the scale of each data type is very different, i.e.g probability=c(0,1), days=c(0,10), etc. I'm wondering if you could suggest a way to solve this problem. It all depends on the details. Please give a small reproducible example. Also, if I would like to put in mathematical notation on the top strip of the plot instead of using text in my events factor vector, what can I do? Use expressions (see ?plotmath). Again, please give details. -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Gaussian elimination - singular matrix
All the nontrivial solutions to AX = 0 are the eigenvectors of A corresponding to eigenvalue 0 (try eigen function). The non-negative solution may or may not exist. For example, if A is a 2x2 matrix Aij = 1 for 1 =i,j =2 then the only non-trivial solution to AX = 0 is X = a*(1,-1), where a is any nonzero scalar. So in this case there is no non-negative solution. Let X1, X2,...,Xk be all the k independent eigenvectors corresponding to eigenvalue 0, i.e. AXi = 0 for i = 1,2,...,k. Any linear combination of them, X = X1,...,Xk, i.e. a1*X1 + ... + ak*Xk is also a solution of AX = 0. Let B be a matrix whose COLUMNS are the vectors X1,...,Xk (B = (X1,...,Xk). Then finding a1,...,ak for which all elements of X are non-negative is equivalent to finding a vector a = (a1,...,ak) such that B*a = 0. Of course a = (0,...,0) is a solution. The question whether there exists another one. Try to solve the following Linear Programming problem: max a1 subject to B*a = 0 (you can start with a = (0,...,0) which is a feasible solution). If you get a non-zero solution fine. If not try to solve min a1 subject to B*a = 0 if you still get 0 try this with max a2, then min a2, max a3, min a3, etc. If all the 2k problems have only 0 solution then there are no nontrivial nonnegative solutions. Otherwise you will find it. Instead of 2k LP (Linear Programming) problems you can look at one QP (Quadratic Programming) problem: max a1^2 + a2^2 + ... + ak^2 subject to B*a = 0 If there is a nonzero solution a = (a1,...,ak) then X = a1X1 +...+ak*Xk is what you are looking for. Otherwise there is no nontrivial nonnegative solution. --- Bruce Willy [EMAIL PROTECTED] wrote: I am sorry, there is just a mistake : the solution cannot be unique (because it is a vectorial space) (but then I might normalize it) can R find one anyway ? This is equivalent to finding an eigenvector in fact From: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date: Wed, 27 Jun 2007 22:51:41 + Subject: [R] Gaussian elimination - singular matrix Hello, I hope it is not a too stupid question. I have a singular matrix A (so not invertible). I want to find a nontrivial nonnegative solution to AX=0 (kernel of A) It is a special matrix A (so maybe this nonnegative solution is unique) The authors of the article suggest a Gaussian elimination method Do you know if R can do that automatically ? I have seen that solve has an option LAPACK but it does not seem to work with me :( Thank you very much _ Le blog Messenger de Michel, candidat de la Nouvelle Star : analyse, news, coulisses A découvrir ! [[alternative HTML version deleted]] _ Le blog Messenger de Michel, candidat de la Nouvelle Star : analyse, news, coulisses A découvrir ! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] restructuring matrix
Hi all, let's say I have matrix PeopleDescValue Mary Height50 Mary Weight 100 FannyHeight 60 Fanny Height200 Is there a quick way to form the following matrix? People HeightWeight Mary 50 100 Fanny 60200 (Assuming I don't know the length of people/desc and let's say these are characters matrix.. I tried play with row(), col(), etc.. but I don't seem to find like a duplicate match function... I'm trying to write some one/two liner that convert my resulting matrix to vector and pick the appropriate fields.. etc ) Thanks! -- View this message in context: http://www.nabble.com/restructuring-matrix-tf3991741.html#a11334950 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] restructuring matrix
If your original matrix is A then unique(A$People) and unique(A$Desc) will produce a vector of different people and a vector of different descriptions. --- yoo [EMAIL PROTECTED] wrote: Hi all, let's say I have matrix PeopleDescValue Mary Height50 Mary Weight 100 FannyHeight 60 Fanny Height200 Is there a quick way to form the following matrix? People HeightWeight Mary 50 100 Fanny 60200 (Assuming I don't know the length of people/desc and let's say these are characters matrix.. I tried play with row(), col(), etc.. but I don't seem to find like a duplicate match function... I'm trying to write some one/two liner that convert my resulting matrix to vector and pick the appropriate fields.. etc ) Thanks! -- View this message in context: http://www.nabble.com/restructuring-matrix-tf3991741.html#a11334950 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Sweave bug? when writing figures / deleting variable in chunk
I have found a quite strange (to me) behaviour in Sweave. It only occurs in the following situation: 1. define a variable in one chunk 2. use it within a subsequent figure-generating chunk 3. delete it at the end of that same chunk Then the Sweave driver chokes, not finding the variable name when generating the figure Example: % document bug2.Rnw \documentclass{article} \usepackage{Sweave} \begin{document} \SweaveOpts{eps=false} = sel - 1:5 @ fig=T= plot(trees[sel,]) rm(sel) @ \end{document} Try to sweave: Sweave(bug2.Rnw) Writing to file bug2.tex Processing code chunks ... 1 : echo term verbatim 2 : echo term verbatim pdf Error: no function to return from, jumping to top level Error in plot(trees[sel, ]) : error in evaluating the argument 'x' in selecting a method for function 'plot' Error in driver$runcode(drobj, chunk, chunkopts) : Error in plot(trees[sel, ]) : error in evaluating the argument 'x' in selecting a method for function 'plot' The generated .tex is complete up through the rm() but no figure is generated. The file bug2-002.pdf is incomplete (corrupt). ... \begin{Schunk} \begin{Sinput} plot(trees[sel, ]) rm(sel) \end{Sinput} \end{Schunk} The following ALL eliminate the problem: 0. Executing the code directly, also with ESS 1. fig=F 2. moving rm(sel) to a separate, later code chunk 3. Stangle the source and then source it 4. don't use a variable, i.e. in this case: plot(trees[1:5,]) It seems that Sweave is executing the rm(sel) before it uses it in the trees[sel,]. Technical details: R 2.5.0, Mac OS X 10.4.10, PPC Same behaviour in stand-alone R for Mac and for R within Aquamacs using ESS Workaround: I am putting any deletions into a later code chunk. This only has the disadvantage of making more chunks, so now that I know what's happening it's no big deal. But it's driving me crazy... am I missing something? Thanks! D. G. Rossiter Senior University Lecturer Department of Earth Systems Analysis International Institute for Geo-Information Science and Earth Observation (ITC) Hengelosestraat 99 PO Box 6, 7500 AA Enschede, The Netherlands Phone: +31-(0)53 4874 499 Fax:+31-(0)53 4874 336 mailto:rossiter--at--itc.nl, Internet: http://www.itc.nl/personal/ rossiter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] restructuring matrix
Yea... let's say I constructed a matrix with rownames/colnames be those unique elements.. then what should I do? I don't want to do mapply, etc to find the field.. I'm wondering if there's a smarter way using row/col.. etc... Thanks! Moshe Olshansky-2 wrote: If your original matrix is A then unique(A$People) and unique(A$Desc) will produce a vector of different people and a vector of different descriptions. --- yoo [EMAIL PROTECTED] wrote: Hi all, let's say I have matrix PeopleDescValue Mary Height50 Mary Weight 100 FannyHeight 60 Fanny Height200 Is there a quick way to form the following matrix? People HeightWeight Mary 50 100 Fanny 60200 (Assuming I don't know the length of people/desc and let's say these are characters matrix.. I tried play with row(), col(), etc.. but I don't seem to find like a duplicate match function... I'm trying to write some one/two liner that convert my resulting matrix to vector and pick the appropriate fields.. etc ) Thanks! -- View this message in context: http://www.nabble.com/restructuring-matrix-tf3991741.html#a11334950 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/restructuring-matrix-tf3991741.html#a11335437 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave bug? when writing figures / deleting variable in chunk
On 6/27/07, D G Rossiter [EMAIL PROTECTED] wrote: I have found a quite strange (to me) behaviour in Sweave. It only occurs in the following situation: 1. define a variable in one chunk 2. use it within a subsequent figure-generating chunk 3. delete it at the end of that same chunk Then the Sweave driver chokes, not finding the variable name when generating the figure The reason is that by default, every fig=TRUE chunk is run twice, once to produce postscript, once for pdf. -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave bug? when writing figures / deleting variable in chunk
On 27/06/2007 9:06 PM, D G Rossiter wrote: I have found a quite strange (to me) behaviour in Sweave. It only occurs in the following situation: 1. define a variable in one chunk 2. use it within a subsequent figure-generating chunk 3. delete it at the end of that same chunk Then the Sweave driver chokes, not finding the variable name when generating the figure By default, Sweave runs figure chunks twice (once for pdf, once for eps). They shouldn't change the environment they need to run in. Not sure where this is documented, but it's well known by people who've been bitten by it. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave bug? when writing figures / deleting variable in chunk
On Wed, 27 Jun 2007 21:06:04 -0400 D G Rossiter wrote: I have found a quite strange (to me) behaviour in Sweave. It only occurs in the following situation: 1. define a variable in one chunk 2. use it within a subsequent figure-generating chunk 3. delete it at the end of that same chunk Then the Sweave driver chokes, not finding the variable name when generating the figure Sweave() executes figure chunks more than once because they might also create printed output. If you create both EPS and PDF graphics, it executes them three times (print + EPS + PDF). Hence, data manipulations should be avoided in figure chunks. I was also once bitten by this when I permuted columns of a table prior to plotting and never obtained the desired order... Fritz, maybe this is worth an entry in the FAQ? Z Example: % document bug2.Rnw \documentclass{article} \usepackage{Sweave} \begin{document} \SweaveOpts{eps=false} = sel - 1:5 @ fig=T= plot(trees[sel,]) rm(sel) @ \end{document} Try to sweave: Sweave(bug2.Rnw) Writing to file bug2.tex Processing code chunks ... 1 : echo term verbatim 2 : echo term verbatim pdf Error: no function to return from, jumping to top level Error in plot(trees[sel, ]) : error in evaluating the argument 'x' in selecting a method for function 'plot' Error in driver$runcode(drobj, chunk, chunkopts) : Error in plot(trees[sel, ]) : error in evaluating the argument 'x' in selecting a method for function 'plot' The generated .tex is complete up through the rm() but no figure is generated. The file bug2-002.pdf is incomplete (corrupt). ... \begin{Schunk} \begin{Sinput} plot(trees[sel, ]) rm(sel) \end{Sinput} \end{Schunk} The following ALL eliminate the problem: 0. Executing the code directly, also with ESS 1. fig=F 2. moving rm(sel) to a separate, later code chunk 3. Stangle the source and then source it 4. don't use a variable, i.e. in this case: plot(trees[1:5,]) It seems that Sweave is executing the rm(sel) before it uses it in the trees[sel,]. Technical details: R 2.5.0, Mac OS X 10.4.10, PPC Same behaviour in stand-alone R for Mac and for R within Aquamacs using ESS Workaround: I am putting any deletions into a later code chunk. This only has the disadvantage of making more chunks, so now that I know what's happening it's no big deal. But it's driving me crazy... am I missing something? Thanks! D. G. Rossiter Senior University Lecturer Department of Earth Systems Analysis International Institute for Geo-Information Science and Earth Observation (ITC) Hengelosestraat 99 PO Box 6, 7500 AA Enschede, The Netherlands Phone:+31-(0)53 4874 499 Fax: +31-(0)53 4874 336 mailto:rossiter--at--itc.nl, Internet: http://www.itc.nl/personal/ rossiter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave bug? when writing figures / deleting variable in chunk
I have found a quite strange (to me) behaviour in Sweave. It only occurs in the following situation: You need to understand what Sweave does when it creates pictures: = sel - 1:5 @ fig=T= plot(trees[sel,]) rm(sel) @ By default, a eps and pdf version of the graphic is made. That is, this chunk producing the graphic is *run twice*: once to make the eps file, once to make the pdf file. After this code chunk is run once: fig=T= plot(trees[sel,]) rm(sel) ...the variable sel is obviously deleted, so the second time it runs... well, there's your error message. Best to place the command rm( sel ) in it's own separate chunk. P. -- Dr Peter Dunn | dunn at usq.edu.au Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc This email (including any attached files) is confidential an...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] unequal variance assumption for lme (mixed effect model)
Dear Douglas and R-help, Does lme assume normal distribution AND equal variance among groups like anova() does? If it does, is there any method like unequal variance T-test (Welch T) in lme when each group has unequal variance in my data? Thanks, Shirley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] restructuring matrix
Is this what you want? x - PeopleDescValue + Mary Height50 + Mary Weight 100 + FannyHeight 60 + Fanny Weight200 x - read.table(textConnection(x), header=TRUE, as.is=TRUE) reshape(x, direction='wide', idvar=People, timevar=Desc) People Value.Height Value.Weight 1 Mary 50 100 3 Fanny 60 200 On 6/27/07, yoo [EMAIL PROTECTED] wrote: Hi all, let's say I have matrix PeopleDescValue Mary Height50 Mary Weight 100 FannyHeight 60 Fanny Height200 Is there a quick way to form the following matrix? People HeightWeight Mary 50 100 Fanny 60200 (Assuming I don't know the length of people/desc and let's say these are characters matrix.. I tried play with row(), col(), etc.. but I don't seem to find like a duplicate match function... I'm trying to write some one/two liner that convert my resulting matrix to vector and pick the appropriate fields.. etc ) Thanks! -- View this message in context: http://www.nabble.com/restructuring-matrix-tf3991741.html#a11334950 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] stepAIC on lm() where response is a matrix..
I see several options for you: 1. Write a function 'dropterm.mlm', copying 'dropterm.lm' and modifying it as you think appropriate. The function 'dropterm.lm' is hidden in a namespace, which you can see from 'methods(dropterm)'. To get it, either use getAnywhere(dropterm.lm) or MASS:::dropterm.lm. 2. Use 'stepAIC' in the univariate mode. If they both select the same model, it would strongly suggest that you would get the same answer from a multivariate version. Fit that multivariate version and be happy. 3. If univariate analyses produce different models and you want a common one, take the models you get, and interpolate manually a list of alternative plausible models between the two best univariate models. Then fit those manually and select the one with the smallest AIC. Hope this helps. Spencer Graves vinod gullu wrote: dear R users, I have fit the lm() on a mtrix of responses. i.e M1 = lm(cbind(R1,R2)~ X+Y+0). When i use summary(M1), it shows details for R1 and R2 separately. Now i want to use stepAIC on these models. But when i use stepAIC(M1) an error message comes saying that dropterm.mlm is not implemented. What is the way out to use stepAIC in such cases. regards, The fish are biting. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] skeleton for C code?
On 6/27/07, ivo welch [EMAIL PROTECTED] wrote: Dear R experts---I would like to write a replacement for the read.csv function that is less general, but also more efficient. could someone please provide me with a skeleton function that shows me how to read the arguments and return a data frame for a call to a C function that handles returned.data.frame = my.read.csv(file, header = TRUE, sep = ,, quote=\, dec=., fill = TRUE, comment.char=, ...) this may be very difficult, of course, in which case writing such a function would not be worth it. I guess I would be happy just to learn how to return a basic data frame that holds data vectors that are either strings or numbers---nothing more complex. help appreciated. Should we assume that you have already read the relevant sections of the manual Writing R Extensions? The .Call interface is the easiest way to return an object like a data frame. I might pass the result back as a list and use something like do.call(data.frame, .Call(my_csv_reader, file, ...)) rather than duplicating all the error checking that is done in the data.frame function. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Gaussian elimination - singular matrix
RSiteSearch(generalized inverse, fun) produced 194 hits for me just now, including references to the following: Ginv {haplo.stats} ginv {MASS} invgen {far} Ginv {haplo.score} At least some of these should provide a solution to a singular system. You could further provide side constraints as Moshe suggested, but I suspect that 'ginv', for example, might return the minimum length solution automatically. Hope this helps. Spencer Graves Moshe Olshansky wrote: All the nontrivial solutions to AX = 0 are the eigenvectors of A corresponding to eigenvalue 0 (try eigen function). The non-negative solution may or may not exist. For example, if A is a 2x2 matrix Aij = 1 for 1 =i,j =2 then the only non-trivial solution to AX = 0 is X = a*(1,-1), where a is any nonzero scalar. So in this case there is no non-negative solution. Let X1, X2,...,Xk be all the k independent eigenvectors corresponding to eigenvalue 0, i.e. AXi = 0 for i = 1,2,...,k. Any linear combination of them, X = X1,...,Xk, i.e. a1*X1 + ... + ak*Xk is also a solution of AX = 0. Let B be a matrix whose COLUMNS are the vectors X1,...,Xk (B = (X1,...,Xk). Then finding a1,...,ak for which all elements of X are non-negative is equivalent to finding a vector a = (a1,...,ak) such that B*a = 0. Of course a = (0,...,0) is a solution. The question whether there exists another one. Try to solve the following Linear Programming problem: max a1 subject to B*a = 0 (you can start with a = (0,...,0) which is a feasible solution). If you get a non-zero solution fine. If not try to solve min a1 subject to B*a = 0 if you still get 0 try this with max a2, then min a2, max a3, min a3, etc. If all the 2k problems have only 0 solution then there are no nontrivial nonnegative solutions. Otherwise you will find it. Instead of 2k LP (Linear Programming) problems you can look at one QP (Quadratic Programming) problem: max a1^2 + a2^2 + ... + ak^2 subject to B*a = 0 If there is a nonzero solution a = (a1,...,ak) then X = a1X1 +...+ak*Xk is what you are looking for. Otherwise there is no nontrivial nonnegative solution. --- Bruce Willy [EMAIL PROTECTED] wrote: I am sorry, there is just a mistake : the solution cannot be unique (because it is a vectorial space) (but then I might normalize it) can R find one anyway ? This is equivalent to finding an eigenvector in fact From: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date: Wed, 27 Jun 2007 22:51:41 + Subject: [R] Gaussian elimination - singular matrix Hello, I hope it is not a too stupid question. I have a singular matrix A (so not invertible). I want to find a nontrivial nonnegative solution to AX=0 (kernel of A) It is a special matrix A (so maybe this nonnegative solution is unique) The authors of the article suggest a Gaussian elimination method Do you know if R can do that automatically ? I have seen that solve has an option LAPACK but it does not seem to work with me :( Thank you very much _ Le blog Messenger de Michel, candidat de la Nouvelle Star : analyse, news, coulisses… A découvrir ! [[alternative HTML version deleted]] _ Le blog Messenger de Michel, candidat de la Nouvelle Star : analyse, news, coulisses… A découvrir ! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] levelplot in lattice
Thank you Deepayan. Let's do the following exercise to reproduce the problem I'm facing. In the following code, I tried to have plot.rw1 and plot.rw2 shows in two separate rows on my plot windows. However, after the call to the 2nd levelplot, plot of plot.rw2 replace my first plot and the result shows only 1 row on my windows. Any lights on this would be really appreciated. Thank you.x - seq(0.1,1,0.1);y - seq(0.1,1,0.1);dat - rnorm(4*length(x)*length(y));Pa.dat - expand.grid(x,y);Pa.dat$z - dat[1:100];Pa.dat$cond - Pa;plot.rw1 - Pa.dat;Pb.dat - expand.grid(x,y);Pb.dat$z - dat[101:200];Pb.dat$cond - Pb;plot.rw1 - rbind(plot.rw1, Pb.dat);names(plot.rw1) - c(x,y,z,cond);Days1.dat - expand.grid(x,y);Days1.dat$z - dat[201:300];Days1.dat$cond - Day Work;plot.rw2 - Days1.dat;Days2.dat - expand.grid(x,y);Days2.dat$z - dat[301:400];Days2.dat$cond - Day Rest;plot.rw2 - rbind(plot.rw2, Days2.dat);names(plot.rw2) - c(x,y,z,cond);windows();pa! r(mfrow=c(2,1));levelplot(z ~ x*y|cond, plot.rw1);levelplot(z ~ x*y|cond, plot.rw2);- Original Message -From: Deepayan Sarkar Date: Wednesday, June 27, 2007 7:00 pmSubject: Re: [R] levelplot in latticeTo: [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch On 6/27/07, [EMAIL PROTECTED] wrote: Hi, I'm new to lattice. So please kindly be patient with me. I'm trying to arrange groups of levelplots into 3 rows as follows: Row1: Probabilities as functions of x and y, and conditioned on an event factor vector factor(a,b,c) Row2: Number of days as functions of x and y, and conditioned on, again the same event factor(a,b,c) Row2: Costs as functions of x and y, and conditioned on, again the same event factor(a,b,c) I tried the following: windows(); par(mfrow=c(3,1)); levelplot(z ~ x*y|events, probDat); levelplot(z ~ x*y|events, daysDat); levelplot(z ~ x*y|events, costDat); It does no! t do what I want. It replace the previous plot every time I call a n ew levelplot. I can't put them into the same matrix and plot them all at once because the scale of each data type is very different, i.e.g probability=c(0,1), days=c(0,10), etc. I'm wondering if you could suggest a way to solve this problem. It all depends on the details. Please give a small reproducible example. Also, if I would like to put in mathematical notation on the top strip of the plot instead of using text in my events factor vector, what can I do? Use expressions (see ?plotmath). Again, please give details. -Deepayan [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] levelplot in lattice
Sorry. My email editor from my ISP always screws up the text after sending out. Below is my response to you (in plain text). Thank you Deepayan. Let's do the following exercise to reproduce the problem I'm facing. In the following code, I tried to have plot.rw1 and plot.rw2 shows in two separate rows on my plot windows. However, after the call to the 2nd levelplot, plot of plot.rw2 replace my first plot and the result shows only 1 row on my windows. Any lights on this would be really appreciated. Thank you x - seq(0.1,1,0.1); y - seq(0.1,1,0.1); dat - rnorm(4*length(x)*length(y)); Pa.dat - expand.grid(x,y); Pa.dat$z - dat[1:100]; Pa.dat$cond - Pa; plot.rw1 - Pa.dat; Pb.dat - expand.grid(x,y); Pb.dat$z - dat[101:200]; Pb.dat$cond - Pb; plot.rw1 - rbind(plot.rw1, Pb.dat); names(plot.rw1) - c(x,y,z,cond); Days1.dat - expand.grid(x,y); Days1.dat$z - dat[201:300]; Days1.dat$cond - Day Work; plot.rw2 - Days1.dat; Days2.dat - expand.grid(x,y); Days2.dat$z - dat[301:400]; Days2.dat$cond - Day Rest; plot.rw2 - rbind(plot.rw2, Days2.dat); names(plot.rw2) - c(x,y,z,cond); windows(); par(mfrow=c(2,1)); levelplot(z ~ x*y|cond, plot.rw1); levelplot(z ~ x*y|cond, plot.rw2); - Original Message -From: [EMAIL PROTECTED]: Wednesday, June 27, 2007 9:34 pmSubject: Re: [R] levelplot in latticeTo: Deepayan Sarkar Cc: r-help@stat.math.ethz.ch Thank you Deepayan. Let's do the following exercise to reproduce the problem I'm facing. In the following code, I tried to have plot.rw1 and plot.rw2 shows in two separate rows on my plot windows. However, after the call to the 2nd levelplot, plot of plot.rw2 replace my first plot and the result shows only 1 row on my windows. Any lights on this would be really appreciated. Thank you.x - seq(0.1,1,0.1);y - seq(0.1,1,0.1);dat - rnorm(4*length(x)*length(y));Pa.dat - expand.grid(x,y);Pa.dat$z - dat[1:100];Pa.dat$cond - Pa;plot.rw1 - Pa.dat;Pb.dat - expand.grid(x,y);Pb.dat$z - dat[101:200];Pb.dat$cond - Pb;plot.rw1 - rbind(plot.rw1, Pb.dat);names(plot.rw1) - c(x,y,z,cond);Days1.dat - expand.grid(x,y);Days1.dat$z - dat[201:300];Days1.dat$cond - Day Wor! k;plot.rw2 - Days1.dat;Days2.dat - expand.grid(x,y);Days2.dat$z - dat[301:400];Days2.dat$cond - Day Rest;plot.rw2 - rbind(plot.rw2, Days2.dat);names(plot.rw2) - c(x,y,z,cond);windows();pa! r(mfrow=c(2,1));levelplot(z ~ x*y|cond, plot.rw1);levelplot(z ~ x*y|cond, plot.rw2);- Original Message -From: Deepayan Sarkar Date: Wednesday, June 27, 2007 7:00 pmSubject: Re: [R] levelplot in latticeTo: [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch On 6/27/07, [EMAIL PROTECTED] wrote: Hi, I'm new to lattice. So please kindly be patient with me. I'm trying to arrange groups of levelplots into 3 rows as follows: Row1: Probabilities as functions of x and y, and conditioned on an event factor vector factor(a,b,c) Row2: Number of days as functions of x and y, and conditioned on, again the same event factor(a,b,c) Row2: Costs as functions of x and y, and conditioned on, again! the same event factor(a,b,c) I tried the following: windows(); par(mfrow=c(3,1)); levelplot(z ~ x*y|events, probDat); levelplot(z ~ x*y|events, daysDat); levelplot(z ~ x*y|events, costDat); It does no! t do what I want. It replace the previous plot every time I call a n ew levelplot. I can't put them into the same matrix and plot them all at once because the scale of each data type is very different, i.e.g probability=c(0,1), days=c(0,10), etc. I'm wondering if you could suggest a way to solve this problem. It all depends on the details. Please give a small reproducible example. Also, if I would like to put in mathematical notation on the top strip of the plot instead of using text in my events factor vector, what can I do? Use expressions (see ?plotmath). Again, please give details. -Deepayan [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman! /listinfo/r-help PLEASE do read the posting guide http://www.R- project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] epitools and R 2.5
--- Prof Brian Ripley [EMAIL PROTECTED] wrote: On Mon, 11 Jun 2007, Pietro Bulian wrote: At work after updating to R 2.5 I get an error using epitab from package epitools, when at home (R 2.4) I get no error. Could someone help me? The maintainer: this is a long-standing bug in the package. But you have enough information from the error message to correct the bug and rebuild the package yourself. There are no such versions of R as '2.5' and '2.4' (see the posting guide), but R 2.4.0 did give a warning on your example. Note that you are using different versions of epitools in your two locations, a difference you failed to mention and which may be important. Thanks Pietro! I am the maintainer and found the bug. In the 'epitab' function: if (method == oddsratio) { ... else { fin - list(tab = tab, measure = oddsratio, conf.level = conf.level, pvalue = pvalue, ) } The comma should not be after the second pvalue. You can correct this in your local workspace. I will correct and upload new package. Tomas === Tomas Aragon, MD, DrPH Tel: 510-847-9139 (mobile) Web: http://www.medepi.net/aragon __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] unequal variance assumption for lme (mixed effect model)
The default settings for lme do assume equal variances within groups. You can change that by using the various varClasses. see ?varClasses. A simple example would be to allow unequal variances across groups. So if your call to lme was: lme(...,random=~1|group,...) then to allow each group to have its own variance, use: lme(...,random=~1|group, weights=varIdent(form=~1|group),...) You really really should read Pinheiro Bates (2000). It's all there. HTH, Simon. , On Wed, 2007-06-27 at 21:55 -0400, shirley zhang wrote: Dear Douglas and R-help, Does lme assume normal distribution AND equal variance among groups like anova() does? If it does, is there any method like unequal variance T-test (Welch T) in lme when each group has unequal variance in my data? Thanks, Shirley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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 email: S.Blomberg1_at_uq.edu.au 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] levelplot in lattice
On 6/27/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Sorry. My email editor from my ISP always screws up the text after sending out. Below is my response to you (in plain text). Thank you Deepayan. Let's do the following exercise to reproduce the problem I'm facing. In the following code, I tried to have plot.rw1 and plot.rw2 shows in two separate rows on my plot windows. However, after the call to the 2nd levelplot, plot of plot.rw2 replace my first plot and the result shows only 1 row on my windows. Any lights on this would be really appreciated. Thank you x - seq(0.1,1,0.1); y - seq(0.1,1,0.1); dat - rnorm(4*length(x)*length(y)); Pa.dat - expand.grid(x,y); Pa.dat$z - dat[1:100]; Pa.dat$cond - Pa; plot.rw1 - Pa.dat; Pb.dat - expand.grid(x,y); Pb.dat$z - dat[101:200]; Pb.dat$cond - Pb; plot.rw1 - rbind(plot.rw1, Pb.dat); names(plot.rw1) - c(x,y,z,cond); Days1.dat - expand.grid(x,y); Days1.dat$z - dat[201:300]; Days1.dat$cond - Day Work; plot.rw2 - Days1.dat; Days2.dat - expand.grid(x,y); Days2.dat$z - dat[301:400]; Days2.dat$cond - Day Rest; plot.rw2 - rbind(plot.rw2, Days2.dat); names(plot.rw2) - c(x,y,z,cond); windows(); par(mfrow=c(2,1)); levelplot(z ~ x*y|cond, plot.rw1); levelplot(z ~ x*y|cond, plot.rw2); ## option 1: levelplot(z ~ x * y | cond, make.groups(plot.rw1, plot.rw2)) ## equivalent in this case levelplot(z ~ x * y | cond, rbind(plot.rw1, plot.rw2)) ## option 2 (not exactly the same) print(levelplot(z ~ x*y|cond, plot.rw1), split = c(1, 2, 1, 2)) print(levelplot(z ~ x*y|cond, plot.rw2), split = c(1, 1, 1, 2), newpage = FALSE) -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Correlation ratio
Hi Bruce, correlation ratio (eta) is different from correlation coefficient (rho). While correlation coefficient captures only a linear relationship btw variables, correlation ratio captures both linear and non-linear relationships. It is the defined as the ratio of the variance between arrays to the total variance. Thanks, Suman On 6/27/07, Bruce Willy [EMAIL PROTECTED] wrote: hello try cor(x, y = NULL, use = all.obs, method = c(pearson, kendall, spearman)) in the R console, you can type ?cor to get some help on a particular function and help.search(correlation) if you do know the keyword Date: Wed, 27 Jun 2007 18:00:05 -0400 From: [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Subject: [R] Correlation ratio Hi, I wanted to know how to compute the correlation ratio (eta) between two variables using R. Is there any function to compute the correlation ratio. Any help will be very much appreciated. Thanks, Suman [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Besoin d'un e-mail ? Créez gratuitement un compte Windows Live Hotmail et bénéficiez de 2 Go de stockage ! Windows Live Hotmailhttp://www.windowslive.fr/hotmail/default.asp [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] unequal variance assumption for lme (mixed effect model)
Hi Simon, Thanks for your reply. Your reply reminds me that book. I've read it long time ago, but haven't try the weights option in my projects yet:) Is the heteroscedastic test always less powerful because we have to estimate the within group variance from the given data? Should we check whether each group has equal variance before using weights=varIdent()? If we should, what is the function for linear mixed model? Thanks, Shirley On 6/27/07, Simon Blomberg [EMAIL PROTECTED] wrote: The default settings for lme do assume equal variances within groups. You can change that by using the various varClasses. see ?varClasses. A simple example would be to allow unequal variances across groups. So if your call to lme was: lme(...,random=~1|group,...) then to allow each group to have its own variance, use: lme(...,random=~1|group, weights=varIdent(form=~1|group),...) You really really should read Pinheiro Bates (2000). It's all there. HTH, Simon. , On Wed, 2007-06-27 at 21:55 -0400, shirley zhang wrote: Dear Douglas and R-help, Does lme assume normal distribution AND equal variance among groups like anova() does? If it does, is there any method like unequal variance T-test (Welch T) in lme when each group has unequal variance in my data? Thanks, Shirley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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 email: S.Blomberg1_at_uq.edu.au 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] stepAIC on lm() where response is a matrix..
On Wed, 27 Jun 2007, Spencer Graves wrote: I see several options for you: 1. Write a function 'dropterm.mlm', copying 'dropterm.lm' and modifying it as you think appropriate. The function 'dropterm.lm' is hidden in a namespace, which you can see from 'methods(dropterm)'. To get it, either use getAnywhere(dropterm.lm) or MASS:::dropterm.lm. To do so you would have to decide what the AIC was for the mlm model. If the two responses are regarded as independent, this would be easy, but mlm is also the basis of 'manova' models: see ?anova.mlm and ?summary.manova. Given Spencer's point 2, independence is not normally what people intend when fitting a multivariate linear model: more likely they are fitting a model with correlated observations not by maximum likelihood (and hence AIC is not appropriate). 2. Use 'stepAIC' in the univariate mode. If they both select the same model, it would strongly suggest that you would get the same answer from a multivariate version. Fit that multivariate version and be happy. 3. If univariate analyses produce different models and you want a common one, take the models you get, and interpolate manually a list of alternative plausible models between the two best univariate models. Then fit those manually and select the one with the smallest AIC. Hope this helps. Spencer Graves vinod gullu wrote: dear R users, I have fit the lm() on a mtrix of responses. i.e M1 = lm(cbind(R1,R2)~ X+Y+0). When i use summary(M1), it shows details for R1 and R2 separately. Now i want to use stepAIC on these models. But when i use stepAIC(M1) an error message comes saying that dropterm.mlm is not implemented. What is the way out to use stepAIC in such cases. regards, -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Loading problem with XML_1.9
Please don't post to multiple lists: I have removed the BioC-devel list. This is about MacOS X, and the appropriate list is R-sig-mac. There is no intrinsic 64-bit problem: package XML 1.9-0 (sic) works fine on 64-bit versions of Solaris and Linux. Most likely there was an installation problem, and you do not have a 64-bit version of libxml2 installed or in the run-time library path. On Wed, 27 Jun 2007, Luo Weijun wrote: Hello all, I have loading problem with XML_1.9 under 64 bit R2.3.1, which I got from http://R.research.att.com/. For MacOS X, unstated. XML_1.9 works fine under 32 bit R2.5.0. I thought that could be installation problem, and I tried install.packages or biocLite, every time the package installed fine, except some warning messages below: ld64 warning: in /usr/lib/libxml2.dylib, file does not contain requested architecture ld64 warning: in /usr/lib/libz.dylib, file does not contain requested architecture ld64 warning: in /usr/lib/libiconv.dylib, file does not contain requested architecture ld64 warning: in /usr/lib/libz.dylib, file does not contain requested architecture ld64 warning: in /usr/lib/libxml2.dylib, file does not contain requested architecture Here is the error messages I got, when XML is loaded: library(XML) Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library '/usr/local/lib64/R/library/XML/libs/XML.so': dlopen(/usr/local/lib64/R/library/XML/libs/XML.so, 6): Symbol not found: _xmlMemDisplay Referenced from: /usr/local/lib64/R/library/XML/libs/XML.so Expected in: flat namespace Error: .onLoad failed in 'loadNamespace' for 'XML' Error: package/namespace load failed for 'XML' I understand that it has been pointed out that Sys.getenv(PATH) needs to be revised in the file XML/R/zzz.R, but I canât even find that file under XML/R/ directory. Does anybody have any idea what might be the problem, and how to solve it? Thanks a lot! BTW, the reason I need to use R64 is that I have memory limitation issue with R 32 bit version when I load some very large XML trees. Session information sessionInfo() Version 2.3.1 Patched (2006-06-27 r38447) powerpc64-apple-darwin8.7.0 attached base packages: [1] methods stats graphics grDevices utils datasets [7] base Weijun -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] WEIBULL FRAILTY MODEL HELP
Dear R users, I try to write an rcode for a paranetric weibull model with unobserved heterogeneity. The data I have are giuven below. ( The data comes from Keiding and Klein artricle published in the Statistics in Medicine 1996) . While the simple weibull model runs perfectly ( I get -2*loglikelihood 1093,905), the weibull frailty model does not run well. The code I write is : likelihood.weibul - function(p) { cumhaz - exp(x1*p[4])*(timeto^p[2])/p[1] cumhaz - sum(cumhaz) lnhaz - (x1*p[4]+log((p[2]*timeto^(p[2]-1))/p[1]))*stat lik - p[3]*log(p[3])-log(gamma(p[3]))+sum(lnhaz)+ log(gamma(di+p[3]))-(p[3]+di)*log(p[3]+cumhaz) -2*lik } di -sum(stat) initial-c(50,2.8,.5,1.8) # initial 1/exp(constant) t-nlm(likelihood.weibul,initial,print.level=1,hessian=T) Best Regards, Denis Lalountas University of Patras insem-read.table(Melanoma.txt,header=T) id - insem$id timeto-insem$time stat-insem$status x1-insem$ulcer x2 -insem$thickness x2 - log(x2) id time status sex age year thickness ulcer 1 1 10 0 1 76 1972 6.76 1 2 2 30 0 1 56 1968 0.65 0 3 3 35 0 1 41 1977 1.34 0 4 4 99 0 0 71 1968 2.90 0 5 5 185 1 1 52 1965 12.08 1 6 6 204 1 1 28 1971 4.84 1 7 7 210 1 1 77 1972 5.16 1 8 8 232 0 0 60 1974 3.22 1 9 9 232 1 1 49 1968 12.88 1 10 10 279 1 0 68 1971 7.41 1 11 11 295 1 0 53 1969 4.19 1 12 12 355 0 0 64 1972 0.16 1 13 13 386 1 0 68 1965 3.87 1 14 14 426 1 1 63 1970 4.84 1 15 15 469 1 0 14 1969 2.42 1 16 16 493 0 1 72 1971 12.56 1 17 17 529 1 1 46 1971 5.80 1 18 18 621 1 1 72 1972 7.06 1 19 19 629 1 1 95 1968 5.48 1 20 20 659 1 1 54 1972 7.73 1 21 21 667 1 0 89 1968 13.85 1 22 22 718 1 1 25 1967 2.34 1 23 23 752 1 1 37 1973 4.19 1 24 24 779 1 1 43 1967 4.04 1 25 25 793 1 1 68 1970 4.84 1 26 26 817 1 0 67 1966 0.32 0 27 27 826 0 0 86 1965 8.54 1 28 28 833 1 0 56 1971 2.58 1 29 29 858 1 0 16 1967 3.56 0 30 30 869 1 0 42 1965 3.54 0 31 31 872 1 0 65 1968 0.97 0 32 32 967 1 1 52 1970 4.83 1 33 33 977 1 1 58 1967 1.62 1 34 34 982 1 0 60 1970 6.44 1 35 35 1041 1 1 68 1967 14.66 0 36 36 1055 1 0 75 1967 2.58 1 37 37 1062 1 1 19 1966 3.87 1 38 38 1075 1 1 66 1971 3.54 1 39 39 1156 1 0 56 1970 1.34 1 40 40 1228 1 1 46 1973 2.24 1 41 41 1252 1 0 58 1971 3.87 1 42 42 1271 1 0 74 1971 3.54 1 43 43 1312 1 0 65 1970 17.42 1 44 44 1427 0 1 64 1972 1.29 0 45 45 1435 1 1 27 1969 3.22 0 46 46 1499 0 1 73 1973 1.29 0 47 47 1506 1 1 56 1970 4.51 1 48 48 1508 0 1 63 1973 8.38 1 49 49 1510 0 0 69 1973 1.94 0 50 50 1512 0 0 77 1973 0.16 0 51 51 1516 1 1 80 1968 2.58 1 52 52 1525 0 0 76 1970 1.29 1 53 53 1542 0 0 65 1973 0.16 0 54 54 1548 1 0 61 1972 1.62 0 55 55 1557 0 0 26 1973 1.29 0 56 56 1560 1 0 57 1973 2.10 0 57 57 1563 0 0 45 1973 0.32 0 58 58 1584 1 1 31 1970 0.81 0 59 59 1605 0 0 36 1973 1.13 0 60 60 1621 1 0 46 1972 5.16 1 61 61 1627 0 0 43 1973 1.62 0 62 62 1634 0 0 68 1973 1.37 0 63 63 1641 0 1 57 1973 0.24 0 64 64 1641 0 0 57 1973 0.81 0 65 65 1648 0 0 55 1973 1.29 0 66 66 1652 0 0 58 1973 1.29 0 67 67 1654 0 1 20 1973 0.97 0 68 68 1654 0 0 67 1973 1.13 0 69 69 1667 1 0 44 1971 5.80 1 70 70 1678 0 0 59 1973 1.29 0 71 71 1685 0 0 32 1973 0.48 0 72 72 1690 1 1 83 1971 1.62 0 73 73 1710 0 0 55 1973 2.26 0 74 74 1710 0 1 15 1973 0.58 0 75 75 1726 1 0 58 1970 0.97 1 76 76 1745 0 0 47 1973 2.58 1 77 77 1762 0 0 54 1973 0.81 0 78 78 1779 0 1 55 1973 3.54 1 79 79 1787 0 1 38 1973 0.97 0 80 80 1787 0 0 41 1973 1.78 1 81 81 1793 0 0 56 1973 1.94 0 82 82
Re: [R] Correlation ratio
Suman, Try this: # some data example(aov) # the summary table anova(npk.aov) # extract sums of squares SS - anova(npk.aov)$Sum Sq SS #[1] 343.295 189.2816667 8.4016667 95.2016667 21.2816667 33.135 0.4816667 185.287 # eta-squared for factor N #SS factor N/SS Total SS[2]/sum(SS) #[1] 0.2159850 # partial eta-squared for factor N # SS factor N/(SS Factor N + SS Residuals) SS[2]/(sum(SS[2],SS[8])) #[1] 0.5053328 Hope this helps, Scot suman Duvvuru wrote: Hi Bruce, correlation ratio (eta) is different from correlation coefficient (rho). While correlation coefficient captures only a linear relationship btw variables, correlation ratio captures both linear and non-linear relationships. It is the defined as the ratio of the variance between arrays to the total variance. Thanks, Suman On 6/27/07, Bruce Willy [EMAIL PROTECTED] wrote: hello try cor(x, y = NULL, use = all.obs, method = c(pearson, kendall, spearman)) in the R console, you can type ?cor to get some help on a particular function and help.search(correlation) if you do know the keyword Date: Wed, 27 Jun 2007 18:00:05 -0400 From: [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Subject: [R] Correlation ratio Hi, I wanted to know how to compute the correlation ratio (eta) between two variables using R. Is there any function to compute the correlationratio. Any help will be very much appreciated. Thanks, Suman -- Scot McNary smcnary at charm dot net __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.