[R] RE
Hi any, Can some please detail me the createX command in bayesm package? To make things easy for you to help me, let me put forward my problem Suppose I have 3 covariates (say X matrix) and my Y has 3 categories say (1,2,3). Now from the CreateX I understand that the data matrix say 'Xa' must be of dimension n* (naxp), where 'na' is the number of variables and 'p' is the number of categories that Y has and 'n' is the number of observations. Now the Xa matrix will have 9 columns if I give na=3 and p=3, and 6 columns if I give na =2 and p=3. I understand this part. In order to create Xa with a dimension of n*9 or n*6 we have to create Xa as cbind(Xa,-Xa) and now when I get the design matrix say XD then I have 5 or 4 variables, which will be same as the beta matrix that I intend to get, I get this, but my question is when I get the XD matrix as explained below the covariate matrix (X) which initially had 3 columns now changed to a 9 rows and one column and two additional variables X4 and X5 as explained belwo which I guess for the beta, what is the role of these variables in the 'rmnlIndepMetrop'analysis. example x1-runif(3,-1,1) x2-runif(3,0,1) x3-runif(3,10,50) X-cbind(x1,x2,x3) X x1x2 x3 [1,] -0.9701396 0.4084203 41.31097 [2,] 0.3844539 0.4791997 36.85861 [3,] 0.2732056 0.5433642 13.14610 Xa-cbind(X,-X) XD-createX(p=3,na=2,nd=NULL,Xa=Xa,Xd=NULL) XD [,1] [,2] [,3][,4] [1,]10 -0.9701396 0.9701396 [2,]01 0.4084203 -0.4084203 [3,]00 41.3109655 -41.3109655 [4,]10 0.3844539 -0.3844539 [5,]01 0.4791997 -0.4791997 [6,]00 36.8586070 -36.8586070 [7,]10 0.2732056 -0.2732056 [8,]01 0.5433642 -0.5433642 [9,]00 13.1461040 -13.1461040 Xa-cbind(X,-X,X^2) (is this a correct way) XD-createX(p=3,na=3,nd=NULL,Xa=Xa,Xd=NULL) XD [,1] [,2] [,3][,4] [,5] [1,]10 -0.9701396 0.97013960.9411709 [2,]01 0.4084203 -0.40842030.1668071 [3,]00 41.3109655 -41.3109655 1706.5958746 [4,]10 0.3844539 -0.38445390.1478048 [5,]01 0.4791997 -0.47919970.2296324 [6,]00 36.8586070 -36.8586070 1358.5569127 [7,]10 0.2732056 -0.27320560.0746413 [8,]01 0.5433642 -0.54336420.2952447 [9,]00 13.1461040 -13.1461040 172.8200512 In the above example my X matrix as you can see has 3 columns with 3 observations, which now in XD are 9 observations in 3rd column, I don't know how col 4 and col 5 of XD play a role in computing the llmnl and rmnlIndepMetrop. Thanks for all your help and time. Regards, Murthy. __ 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] questions on aggregate data
Dear friends, my question is how to aggregate dataset and the inverse manipulation. e.g.My dataset data structure1: x 1 1 2 3 3 data structure2: x freq 1 2 2 1 3 2 Then how to generate dataset2 from dataset1 and generate dataset1 from dataset2? e.g. dataset2 from dataset1 : x-c(1,1,2,3,3) a-tab(x) as.data.frame(a) *But i can't do the inverse manipulation:generate dataset1 from dataset2*, anybody can help me on the two different manipulations? Thanks a lot! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[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] rpad, leaps, regsubsets
Thanks for the resources, Berton. but unfortunately, that rpad link fails, and I still do not know where to get leaps or regsubsets functions. Sincerely, Boris. -- Hello, dear r team. Please help the newbie. My r is not finding leaps or regsubsets finctions. What should I do? Any name changes or library loading issues? - Boris Garbuzov E-mail: [EMAIL PROTECTED] ICQ: 146995300 MSN: [EMAIL PROTECTED] Residence: 3007 Hamilton Hall, University Drive, Burnaby BC, V5A 1S6, Canada Telephone: 604-339-9964 (cell), 1.888.9.555.777 (toll free). - Original Message - From: Berton Gunter [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Tuesday, August 01, 2006 2:47 PM Subject: [R] R Reference Card and other help (especially useful for Newbies) Hi all: Newbies (and others!) may find useful the R Reference Card made available by Tom Short and Rpad at http://www.rpad.org/Rpad/Rpad-refcard.pdf or through the Contributed link on CRAN (where some other reference cards are also linked). It categorizes and organizes a bunch of R's basic, most used functions so that they can be easily found. For example, paste() is under the Strings heading and expand.grid() is under Data Creation. For newbies struggling to find the right R function as well as veterans who can't quite remember the function name, it's very handy. Also don't forget R's other Help facilties: help.search(keyword or phrase) to search the **installed** man pages __ 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] questions on aggregate data
data.frame(x = with(df1, rep(x, freq))) --- Jacques VESLOT CNRS UMR 8090 I.B.L (2ème étage) 1 rue du Professeur Calmette B.P. 245 59019 Lille Cedex Tel : 33 (0)3.20.87.10.44 Fax : 33 (0)3.20.87.10.31 http://www-good.ibl.fr --- zhijie zhang a écrit : Dear friends, my question is how to aggregate dataset and the inverse manipulation. e.g.My dataset data structure1: x 1 1 2 3 3 data structure2: x freq 1 2 2 1 3 2 Then how to generate dataset2 from dataset1 and generate dataset1 from dataset2? e.g. dataset2 from dataset1 : x-c(1,1,2,3,3) a-tab(x) as.data.frame(a) *But i can't do the inverse manipulation:generate dataset1 from dataset2*, anybody can help me on the two different manipulations? Thanks a lot! __ 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] Support vector in lcrabs example
The examples in the book were run in 2001, using S-PLUS (as it says). The R package e1071 has changed since then, and hence the results it gives have changed. However, the S-PLUS version (which has not been updated) still gives the results in the book. The `problem' is your expectation that R in 2006 is identical to S-PLUS in 2001. On Wed, 2 Aug 2006, G.C. McGuinness wrote: Can anyone explain the root of my problem? When I type the following code into R, I receive 42 support vectors insted of the 21 stated in the book 'Modern Applied Statistics with S': library(MASS); library(e1071); library(class); lcrabs - log(crabs[,4:8]); (svm(crabs$sp ~ ., data = lcrabs, cost = 100, gamma = 1)); By changing the value of gamma I can obtain only 21 support vectors, but I not sure where an explanation to my problem can be found. I use R 2.3.2 and the most recent version of the package 'e1071'. My goal is to minimise the number of SVs for a separate data set. There is no `R 2.3.2'. Many thanks, Graeme. __ 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. -- 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] Syntax of Levene's test
Dear All I am trying to use Levene's test (of package car), but I do not understand quite well how to use it. '?levene.test' does not unfortunately provide any example. My data are in a data frame and correspond to 4 factors plus response. Could someone please give me an example about how to use the command levene.test(y, group) ? Thanks in advance, Paul __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] loop, pipe connection, quote/unquote
Hi all, I have the following problem. Inside R, I am trying to run a loop on several files. The data are stored in these files in a peculiar way, thus, at the same time I load the data, I would like to invoke a utility. I do this with pipe. (The utility I am using is gbget from the package gbutils. It works correctly from shell, and it is not the problem.) The problem is that from within pipe I do not know how to have the loop running. I guess I should manage to unquote the quotation mark inside the pipe for the loop to run, but I do not how to do it. In the following examples, for instance, I would like pipe to interpret the i as the file.names of the loop specified above. # specify the files on which I want to have the loop running file.names - system(ls ???.gz, intern=TRUE) # Start loop for(i in file.names){ dati - read.table(pipe(gbget 'i[160](1)' '[37](1)' '[145](1)' |gbget '()D' )) # [...] some statistical analysis follows [...] } Thanks for your help (hoping I manged to be enough clear), marco -- Marco Grazzi - PhD Candidate in Economics and Management LEM-Sant'Anna School of Advanced Studies Piazza Martiri della Liberta', 33 56127 Pisa, Italy Tel. +39-050-883365 Fax +39-050-883344 Web site: https://mail.sssup.it/~grazzi __ 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] Trying to use segmented in a function
Hi folks I wonder if anyone can help me. I want to run some simulations to see how big a sample size might be necessary to distinguish a curved bivariate relationship (e.g. something that might be best described by a quadratic model) from a relationship that is two straight lines with a sudden change in slope (e.g. something best described by a breakpoint regression). I am using segmented to do the breakpoint regression: this package seems to be the one that most people use for this, as far as I can see. Since I want to run some simulations, I'm trying to write functions that use segmented, and it's driving me mad. Here's a simple example: simdata-function (Ns=200,Xmean=20,Xsd=5,SdYerr=0.5,Yint=0,threshold=20,slopebelow=0.5,slo peabove=1) { Xs-rnorm(Ns,Xmean,Xsd) Yerr-rnorm(Ns,0,SdYerr) D-ifelse(Xs=threshold,0,1) XminusX0-Xs-threshold Ys-Yint+slopebelow*Xs+slopeabove*XminusX0*D+Yerr plot(Xs,Ys) linmod-lm(Ys~Xs) segment-segmented(linmod,Z=Xs,psi=threshold) segment } This code should simply simulate some breakpoint data, with the change in slope at threshold and then fit a model with segmented. If I just use the code for simulating the data, and run that, and then run segmented as normal in R, then I occasionally get an error when it exceeds the maximum iterations, but 99% of the time it will fit a model happily. When I incorporate it into the function, however, it will sometimes fit a model (about 20% of the time) but most of the time I get this: test-simdata() Error in segmented.lm(linmod, Z = Xs, psi = threshold) : (Some) estimated psi out of its range I emphasise that this is using exactly the same code to simulate the data that gives good results when used without segmented in the function. I'm even giving it the exact right value of the breakpoint to start with in its estimation. If anyone could give me some advice on where I'm going wrong, I would be very pleased to hear it. Thanks everyone Rob Knell School of Biological Sciences Queen Mary, University of London 'Phone +44 (0)20 7882 7720 Skype Rob Knell http://www.qmw.ac.uk/~ugbt794 http://www.mopane.org The truth is that they have no clue why the beetles had horns, it's the researchers who have sex on the brain and everything has to have a sexual explanation. And this is reasearch?! Correspondent known as FairOpinion on Neo-Con American website discussing my research. __ 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] loop, pipe connection, quote/unquote
Try something along these lines assuming that the current directory is \Program Files\R\R-2.3.1pat. Note use of paste to create the command line to pass to pipe: # search for indicated string in each of the files and # for each match output the file name Files - c(CHANGES, COPYING, NEWS, NEWS) for(f in Files) print(readLines(pipe(paste(findstr /m out-of-range, f On 8/2/06, Marco Grazzi [EMAIL PROTECTED] wrote: Hi all, I have the following problem. Inside R, I am trying to run a loop on several files. The data are stored in these files in a peculiar way, thus, at the same time I load the data, I would like to invoke a utility. I do this with pipe. (The utility I am using is gbget from the package gbutils. It works correctly from shell, and it is not the problem.) The problem is that from within pipe I do not know how to have the loop running. I guess I should manage to unquote the quotation mark inside the pipe for the loop to run, but I do not how to do it. In the following examples, for instance, I would like pipe to interpret the i as the file.names of the loop specified above. # specify the files on which I want to have the loop running file.names - system(ls ???.gz, intern=TRUE) # Start loop for(i in file.names){ dati - read.table(pipe(gbget 'i[160](1)' '[37](1)' '[145](1)' |gbget '()D' )) # [...] some statistical analysis follows [...] } Thanks for your help (hoping I manged to be enough clear), marco -- Marco Grazzi - PhD Candidate in Economics and Management LEM-Sant'Anna School of Advanced Studies Piazza Martiri della Liberta', 33 56127 Pisa, Italy Tel. +39-050-883365 Fax +39-050-883344 Web site: https://mail.sssup.it/~grazzi __ 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] Syntax of Levene's test
Dear Paul, The argument y is the response variable and group is a factor defining groups (as ?levene.test says). If you have more than one factor, then you can use interaction() to create from them a factor with levels given by the product set of the levels of the individual factors. Here's an example library(car) data(Moore) attach(Moore) levene.test(conformity, interaction(fcategory, partner.status)) Levene's Test for Homogeneity of Variance Df F value Pr(F) group 5 1.4694 0.2219 39 levels(interaction(fcategory, partner.status)) [1] high.high low.highmedium.high high.lowlow.low [6] medium.low levels(fcategory) [1] high lowmedium levels(partner.status) [1] high low I'll add a couple of examples to the help page. I hope this helps, John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith Sent: Wednesday, August 02, 2006 5:33 AM To: r-help@stat.math.ethz.ch Subject: [R] Syntax of Levene's test Dear All I am trying to use Levene's test (of package car), but I do not understand quite well how to use it. '?levene.test' does not unfortunately provide any example. My data are in a data frame and correspond to 4 factors plus response. Could someone please give me an example about how to use the command levene.test(y, group) ? Thanks in advance, Paul __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 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] missing value
Hi all # I have this data set and how can I assign NA´s in just one command ? And why the summary(dat) function preserves the value 9 as real. ? x - c(1,2,3,9,4) y - c(3,6,9,2,3) z - c(9,9,2,2,8) w - c(6,5,3,0,9) dat - cbind(x,y,z,w) summary(dat) x[x==9] - NA y[y==9] - NA z[z==9] - NA w[w==9] - NA summary(dat) summary(x) summary(y) summary(z) summary(w) Thank you all, Mauricio __ 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] missing value
Mauricio Cardeal wrote: Hi all # I have this data set and how can I assign NA´s in just one command ? is.na(dat[dat==9]) - TRUE And why the summary(dat) function preserves the value 9 as real. ? Because you have not changed the contents of dat at all, only the contents of x,y,z, and w. Uwe Ligges x - c(1,2,3,9,4) y - c(3,6,9,2,3) z - c(9,9,2,2,8) w - c(6,5,3,0,9) dat - cbind(x,y,z,w) summary(dat) x[x==9] - NA y[y==9] - NA z[z==9] - NA w[w==9] - NA summary(dat) summary(x) summary(y) summary(z) summary(w) Thank you all, Mauricio __ 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] How to share variables
Hi, I would like to realize in R a structure like the fortran common ie a way to declare some variable that can only be accessed by all the functions which need to. Browsing the archive it seems that the simplest way is to declare the variables and the functions in a big function which wraps all. But this is impratical when the functions are big. The environments seems to do the trick but I am not enough familiar with them to make my ways out. Is there any example or pointers to easy but complete environment usage? Thanks in Advance Sergio Martino __ 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] missing value
dat[dat==9] - NA because the result of mean() is real and summary()'s output is a vector. --- Jacques VESLOT CNRS UMR 8090 I.B.L (2ème étage) 1 rue du Professeur Calmette B.P. 245 59019 Lille Cedex Tel : 33 (0)3.20.87.10.44 Fax : 33 (0)3.20.87.10.31 http://www-good.ibl.fr --- Mauricio Cardeal a écrit : Hi all # I have this data set and how can I assign NA´s in just one command ? And why the summary(dat) function preserves the value 9 as real. ? x - c(1,2,3,9,4) y - c(3,6,9,2,3) z - c(9,9,2,2,8) w - c(6,5,3,0,9) dat - cbind(x,y,z,w) summary(dat) x[x==9] - NA y[y==9] - NA z[z==9] - NA w[w==9] - NA summary(dat) summary(x) summary(y) summary(z) summary(w) Thank you all, Mauricio __ 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] Fitting models in a loop
Thanks to all for their help. I am busy today but tomorrow I will have time to digest all the feedback and follow up if necessary Cheers, Murray -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: [EMAIL PROTECTED]Fax 7 838 4155 Phone +64 7 838 4773 wkHome +64 7 825 0441Mobile 021 1395 862 __ 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.spss and umlaut
Hello When I read a SPSS *.por file with read.spss everything after a umlaut is missing: library(foreign) spssdaten - read.spss(projets.por) attr(spssdaten$PROJETX, value.labels)[1:20] Bg Stammzellenforschung Bb 863 862 Bb Neugestaltung des Finanzausgleichs 861 854 EV Postdienste f Bb 853 852 Bb Bg Steuerpaket 851 843 Bb Anhebung der Mehrwertsteuer s 11. AHV-Revision 842 841 Volkinitiative Lebenslange Verwahrung 833 832 Gegenentwurf zur Avanti EV Lehrstellen-Initiative 831 824 EV Moratorium PlusEV Strom ohne Atom 823 822 EV Ja zu fairen Mieten EV Gleiche Rechte f 821 815 EV GesundheitsinitiativeEV Sonntags-Initiative 814 813 The SPSS-File is okay: system(cat projets.por |grep Postdienste) echtserwerb 3. GenerationSD/N/EV Postdienste für alleSE/16/Änderrung Bg EOG Mut How can I read the SPSS-File with the Umlaut? Bye Thomas Kuster R: 2.1.0 (2005-04-18) OS: Debian Sarge (Version 2.6.10-isgee-neptun-1) __ 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.spss and umlaut
Hello When I read a SPSS *.por file with read.spss everything after a umlaut is missing: library(foreign) spssdaten - read.spss(projets.por) attr(spssdaten$PROJETX, value.labels)[1:20] Bg Stammzellenforschung Bb 863 862 Bb Neugestaltung des Finanzausgleichs 861 854 EV Postdienste f Bb 853 852 Bb Bg Steuerpaket 851 843 Bb Anhebung der Mehrwertsteuer s 11. AHV-Revision 842 841 Volkinitiative Lebenslange Verwahrung 833 832 Gegenentwurf zur Avanti EV Lehrstellen-Initiative 831 824 EV Moratorium PlusEV Strom ohne Atom 823 822 EV Ja zu fairen Mieten EV Gleiche Rechte f 821 815 EV GesundheitsinitiativeEV Sonntags-Initiative 814 813 The SPSS-File is okay: system(cat projets.por |grep Postdienste) echtserwerb 3. GenerationSD/N/EV Postdienste für alleSE/16/Änderrung Bg EOG Mut How can I read the SPSS-File with the Umlaut? Bye Thomas Kuster R: 2.1.0 (2005-04-18) OS: Debian Linux, 2.6.10-isgee-neptun-1 __ 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] Pseudo R for Quant Reg
Dear R Users, Did someone implemented the R1 (Pseudo R-2) and likelihood ratio statistics for quantile regressions, which are some of the inference procedures for quantile regression found in Koenker and Machado (1999)? I tried the Ox version, but my dataset is too large ( 50.000) and the algorith breaks. Ricardo Gonçalves Silva, M. Sc. Apoio aos Processos de Modelagem Matemática Econometria Inadimplência Serasa S.A. (11) - 6847-8889 [EMAIL PROTECTED] ** As informações contidas nesta mensagem e no(s) arquivo(s...{{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.
Re: [R] How to share variables
On 8/2/06, Sergio Martino [EMAIL PROTECTED] wrote: Hi, I would like to realize in R a structure like the fortran common ie a way to declare some variable that can only be accessed by all the functions which need to. Browsing the archive it seems that the simplest way is to declare the variables and the functions in a big function which wraps all. But this is impratical when the functions are big. There is a demonstration of that found by issuing the command: demo(scoping) The environments seems to do the trick but I am not enough familiar with them to make my ways out. Yes place your data in an environment as shown and then for each function that is to access the environment should have its environment set accordingly: e - new.env() e$dat - 1:3 myfun - function(x) sum(x + dat) environment(myfun) - e myfun(10) # fun can access dat Realize that what you are trying to do is to create a sort of object oriented structure with the data being the objects and the functions being the methods. The proto package provides some functionality to implement that and also supports delegation (similar to inheritance): library(proto) package?proto # all sources of info on proto # example - create proto object p with some data dat and a method fun p - proto(dat = 1:3, fun = function(., x) sum(x + .$dat)) # invoke method p$fun(10) # runs fun. fun has access to dat # create a child q of p and run fun # q overrides dat with its own dat while inheriting fun q - p$proto(dat = 4:6) q$fun(10) Another possibility would be to look at the R.oo package which is another object oriented infrastructure based on environments. Is there any example or pointers to easy but complete environment usage? Thanks in Advance Sergio Martino __ 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] Plotting a ranef object in NLME
Hi I am following the model building strategy that is outlined in the Pinheiro and Bates book wrt including covariates but am having a problem with the plot. Basically I am using 4 covariates (1 of them is continuous) and 3 of them are fine but the 4th one is being shown as a scatterplot despite the fact that it is a factor. I have explicitly declared this to be a factor (pcat-as.factor(pcat)) and have also checked by using the is.factor and the levels command that it is a factor. Yet despite this the plot command is not recognising it as a factor. Any ideas? Many thanks Greg BTW I have 1st created an object that holds the random effects estimated by my model (D1C2.ran - ranef(mod11.103nlme,augFrame=T)) and then it is this object that I try plot (plot(D1C2.ran,form= C ~site+mutcat2+pcat+pdens0). [[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] Pseudo R for Quant Reg
This is getting to be a faq -- here is a prior answer: No, but the objective function can be computed for any fitted rq object, say f, as rho - function(u,tau=.5)u*(tau - (u 0)) V - sum(rho(f$resid, f$tau)) so it is easy to roll your own I don't much like R1, or R2 for that matter, so it isn't likely to be automatically provided in quantreg any time soon. url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 On Aug 1, 2006, at 11:46 AM, [EMAIL PROTECTED] wrote: Dear R Users, Did someone implemented the R1 (Pseudo R-2) and likelihood ratio statistics for quantile regressions, which are some of the inference procedures for quantile regression found in Koenker and Machado (1999)? I tried the Ox version, but my dataset is too large ( 50.000) and the algorith breaks. Ricardo Gonçalves Silva, M. Sc. Apoio aos Processos de Modelagem Matemática Econometria Inadimplência Serasa S.A. (11) - 6847-8889 [EMAIL PROTECTED] ** As informações contidas nesta mensagem e no(s) arquivo(s...{{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-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] best way to calculate per-parameter differences in across-subject means
Hello, I have some data in a data.frame where for each of a number of subjects, I have scores for all of a number of symptoms. Subjects are subdivided in a number of groups, which have unequal sizes. I'd like to plot between-group differences in the scores on the various symptoms. Ideally, that would be in a form as would be produced by bwplot( Score~Symptom ) but I'm not sure one can say anything about the distribution of differences when the sample sizes differ as much as they do. So I will start plotting the per-group differences in the per-symptom mean scores. Is there a better way (rather than using loops) to get a table of those per-symptom means, something like with( subset(dat, group==1, drop=FALSE), Score~Symptom ) Thanks in advance, René Bertin __ 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] ordering columns (longitudinal data in wide format)
Hi, I am working on some longitudinal data in wide format and I am having a problem ordering the data columns. To expand, a subset of what I am working on is as follows; s L.qol.0 L.qol.0.08 L.qol.0.17 L.qol.0.25 L.qol.0.5 L.qol.0.42 L.qol.0.34 1 83 86 89 9291 87 90 names(s) [1] L.qol.0L.qol.0.08 L.qol.0.17 L.qol.0.25 L.qol.0.5 [6] L.qol.0.42 L.qol.0.34 # in this object s (not a vector), 'L.qol' is measured at time points 0, 0.08, 0.17, 0.25, 0.34, 0.42 and 0.5. As you can see, however, the time points are not in the correct order in object s. Does anyone know how to order these column names along with their corresponding measurements? Clearly s[order(s)] does not work since this just orders the corresponding measurements. I would be extremely grateful for any help on this matter, it may be really simple, but I have tried for ages. Thank you, Zoe __ 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] expected survival from a frailty cox model using survfit
Hello R users Would somebody know how to estimate survival from a frailty cox model, using the function survfit and the argument newdata ? (or from any other way that could provide individual expected survival with standard error); Is the problem related to how the random term is included in newdata ? kfitm1 - coxph(Surv(time,status) ~ age + sex + disease + frailty(id, dist='gauss'), kidney) survfit(kfitm1) #ok for mean expected survival Call: survfit.coxph(object = kfitm1) n events median 0.95LCL 0.95UCL 76 58 63 39 132 survfit(kfitm1, newdata=kidney[1,]) #return an error message Erreur dans x2 %*% coef : arguments inadéquats Thanks in Advance -- Emmanuel Tillard Veterinaire CIRAD-EMVT Unite de recherche 18 UMR868 Elevage des Ruminants en Regions Chaudes (ERRC) Campus ENSA-INRA 2 place Viala 34060 Montpellier cedex 1 tel:0499612265 (fixe) 0633850598 (gsm) fax:0467545694 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] read.spss and umlaut
On Wed, 2 Aug 2006, Thomas Kuster wrote: Hello When I read a SPSS *.por file with read.spss everything after a umlaut is missing: This sounds like a conflict between encodings -- eg if R is assuming UTF-8 and the file is encoding in Latin-1 then the sequence U+00FC : LATIN SMALL LETTER U WITH DIAERESIS U+0072 : LATIN SMALL LETTER R is coded as FC72 in the file, which is an illegal byte sequence in UTF-8. The underlying C code (being written in the US quite a long time ago) doesn't know about encodings, and I don't know what the rules are in SPSS for valid characters (I suspect that in these old portable file formats it probably just reads and writes bytes, leaving it up to the OS to interpret them. You could try running R in a non-UTF-8 locale to see if it helps. If anyone has definitive information about how SPSS represents strings and decides on valid characters that might be useful too. -thomas library(foreign) spssdaten - read.spss(projets.por) attr(spssdaten$PROJETX, value.labels)[1:20] Bg Stammzellenforschung Bb 863 862 Bb Neugestaltung des Finanzausgleichs 861 854 EV Postdienste f Bb 853 852 Bb Bg Steuerpaket 851 843 Bb Anhebung der Mehrwertsteuer s 11. AHV-Revision 842 841 Volkinitiative Lebenslange Verwahrung 833 832 Gegenentwurf zur Avanti EV Lehrstellen-Initiative 831 824 EV Moratorium PlusEV Strom ohne Atom 823 822 EV Ja zu fairen Mieten EV Gleiche Rechte f 821 815 EV GesundheitsinitiativeEV Sonntags-Initiative 814 813 The SPSS-File is okay: system(cat projets.por |grep Postdienste) echtserwerb 3. GenerationSD/N/EV Postdienste für alleSE/16/Änderrung Bg EOG Mut How can I read the SPSS-File with the Umlaut? Bye Thomas Kuster R: 2.1.0 (2005-04-18) OS: Debian Linux, 2.6.10-isgee-neptun-1 __ 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. Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle__ 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] ordering columns (longitudinal data in wide format)
Assuming this data: s - structure(list(L.qol.0 = 83, L.qol.0.08 = 86, L.qol.0.17 = 89, L.qol.0.25 = 92, L.qol.0.5 = 91, L.qol.0.42 = 87, L.qol.0.34 = 90), .Names = c(L.qol.0, L.qol.0.08, L.qol.0.17, L.qol.0.25, L.qol.0.5, L.qol.0.42, L.qol.0.34), class = data.frame, row.names = 1) # we can sort it by column names like this: s[,sort(names(s))] # also note that mixed sort in gtools can sort by numeric # value in mixed character/numeric names which gives the # same result here but may not in different examples library(gtools) s[,mixedsort(names(s))] On 8/2/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I am working on some longitudinal data in wide format and I am having a problem ordering the data columns. To expand, a subset of what I am working on is as follows; s L.qol.0 L.qol.0.08 L.qol.0.17 L.qol.0.25 L.qol.0.5 L.qol.0.42 L.qol.0.34 1 83 86 89 9291 87 90 names(s) [1] L.qol.0L.qol.0.08 L.qol.0.17 L.qol.0.25 L.qol.0.5 [6] L.qol.0.42 L.qol.0.34 # in this object s (not a vector), 'L.qol' is measured at time points 0, 0.08, 0.17, 0.25, 0.34, 0.42 and 0.5. As you can see, however, the time points are not in the correct order in object s. Does anyone know how to order these column names along with their corresponding measurements? Clearly s[order(s)] does not work since this just orders the corresponding measurements. I would be extremely grateful for any help on this matter, it may be really simple, but I have tried for ages. Thank you, Zoe __ 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] question about correlation coefficeint and root mean square
Dear all, I am using different multiple regression models (OLS and principal component regression (PCR)) to make prediction of my test set. And those models come from the same training set, except that the number of variables or descriptors (columns of X) used in OLS is less than those used in PCR. And I use square correlation coefficient (r^2) and root mean square to see the relationship between my prediction and the experimental measurements of the test set. Here is the problem: My r^2 from PCR prediction is higher than r^2 from OLS prediction (0.8 vs. 0.7). However, my RMS of PCR prediction is also higher than OLS (0.55 vs. 0.48). I would expect r^2 and RMS show consistant trend. But why am I getting opposite results? Is it because PCR is a biased method? Which one (r^2 or RMS) should be more reliable to evaluate the model? Really appreciate your kind help! Sincerely, Jeny __ 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] rpad, leaps, regsubsets
Boris: Thankyou for this. All the RPAD links now appear to be dead. However, the Reference Card is still available in the CONTRIBUTED link on CRAN, as I said. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA Thanks for the resources, Berton. but unfortunately, that rpad link fails, and I still do not know where to get leaps or regsubsets functions. Sincerely, Boris. -- Hello, dear r team. Please help the newbie. My r is not finding leaps or regsubsets finctions. What should I do? Any name changes or library loading issues? - Boris Garbuzov E-mail: [EMAIL PROTECTED] ICQ: 146995300 MSN: [EMAIL PROTECTED] Residence: 3007 Hamilton Hall, University Drive, Burnaby BC, V5A 1S6, Canada __ 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] best way to calculate per-parameter differences in across-subject means
René J.V. Bertin rjvbertin at gmail.com writes: I have some data in a data.frame where for each of a number of subjects, I have scores for all of a number of symptoms. Subjects are subdivided in a number of groups, which have unequal sizes. I'd like to plot between-group differences in the scores on the various symptoms. Ideally, that would be in a form as would be produced by Maybe it's a bit more than you want, but possibly you are happy with it: see the example under TukeyHSD. summary(fm1 - aov(breaks ~ wool + tension, data = warpbreaks)) TukeyHSD(fm1, tension, ordered = TRUE) plot(TukeyHSD(fm1, tension)) Dieter __ 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] [Off-Topic-but somewhat related] DIA/FDA Open Toolbox Initiative
UseR's- As this is slightly off-topic I will limit the discussion to only the major points; for further information feel free to reply off-line. DIA and FDA are hosting a forum to discuss (as per the Goal of the announcement--see link below) a vendor-neutral software product to support validated analytic procedures (tools) and make tool development a collaborative effort among reviewers, academic researchers, and the pharmaceutical industry. The analytic procedures could be done in R. SAS (gasp), Stata, Splus, or other programming language. This is just an initiative and the hope is to attract people that would like to contribute to the effort and also assist in guiding the direction of the development of such software. This is a free event held on Sept. 14, 2006 in Bethesda, Maryland (Washington DC area). Space is limited to the first 30 to register, so if interested please do so early. For further details including how to register please see the following link. http://www.diahome.org/DIAHome/Education/FindEducationalOffering.aspx?pr oductID=12092eventType=Meeting Thank you and apologies for the off-topic post, but I felt this might be of interest to some of the many great UseRs. Cheers, -Mat Standard Disclaimer: The views and opinions expressed are those of the author and not those of the FDA. *** Mat Soukup, Ph.D. Food and Drug Administration 10903 New Hampshire Ave. BLDG 22 RM 5329 Silver Spring, MD 20993-0002 Phone: 301.796.1005 *** [[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] Summary method needed?
Hi list, I'm updating my fpc package at the moment and will add some new functions. I learned that there should be print and summary methods for the key functions. The purpose of the summary methods seems to be to reduce the possibly incredibly complex information in the function's output and the print method (print.summary.foo) should print an overview of the result. But in some cases the print method will make use of more or less all the output information of the function. Is there any reason to implement a summary method in these cases? Best, Christian *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 [EMAIL PROTECTED], www.homepages.ucl.ac.uk/~ucakche __ 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] listing of permutations
Dear R People: Suppose I have the 4 numbers: 1,2,3,4. I would like to create a listing of the permutations of 4 items taken 4 at a time. Is there a built in function for that, please? Thanks in advance! R 2-3-1 for Windows or Linux Sincerely, Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [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] listing of permutations
not very-well hidden: permutations in (e1071) permn in (combinat) David L. Reiner Rho Trading Securities, LLC Chicago IL 60605 312-362-4963 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erin Hodgess Sent: Wednesday, August 02, 2006 11:57 AM To: r-help@stat.math.ethz.ch Subject: [R] listing of permutations Dear R People: Suppose I have the 4 numbers: 1,2,3,4. I would like to create a listing of the permutations of 4 items taken 4 at a time. Is there a built in function for that, please? Thanks in advance! R 2-3-1 for Windows or Linux Sincerely, Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [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. __ 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] question about correlation coefficeint and root mean square (with code used)
Dear all, I am using different multiple regression models (OLS and principal component regression (PCR)) to make prediction of my test set. And those models come from the same training set, except that the number of variables or descriptors (columns of X) used in OLS is less than those used in PCR. And I use square correlation coefficient (r^2) and root mean square to see the relationship between my prediction and the experimental measurements of the test set. Here is the problem: My r^2 from PCR prediction is higher than r^2 from OLS prediction (0.8 vs. 0.7). However, my RMS of PCR prediction is also higher than OLS (0.55 vs. 0.48). I would expect r^2 and RMS show consistant trend (r^2 increase rms decrease, or the opposite). But why am I getting opposite results? Is it because PCR is a biased method? Which one (r^2 or RMS) should be more reliable to evaluate the model? Here is the simple code I used for calculating r^2 and RMS in R (test set size is 40): r2=cor(test$p50, test.pred$fit)*cor(test$p50, test.pred$fit) rms=sqrt((test.pred$fit-test$p50)%*%(test.pred$fit-test$p50)/40) Really appreciate your kind help! Sincerely, Jeny __ 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] listing of permutations
Erin: You got 2 (so far) pre-packaged functions .Here's an obscenely inefficient but short un-prepackaged way to do it: k-4 z- do.call('expand.grid',as.data.frame(matrix(rep(1:k,k),nc=k))) results- z[apply(z,1,function(x)length(unique(x))==k),] It is too inefficient to make public, though. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erin Hodgess Sent: Wednesday, August 02, 2006 9:57 AM To: r-help@stat.math.ethz.ch Subject: [R] listing of permutations Dear R People: Suppose I have the 4 numbers: 1,2,3,4. I would like to create a listing of the permutations of 4 items taken 4 at a time. Is there a built in function for that, please? Thanks in advance! R 2-3-1 for Windows or Linux Sincerely, Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [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. __ 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 adjusted Bonferroni? (was: Multiple tests on repeated measurements)
HI, just my 2 cents. Bonferroni et al, assume independent tests, thus p ~ p*k with k the number of tests, in repeated measures, each measure is correlated with the previous, so k is not 2 but 2-q. I do not know q but it should be a function of the correlation between measures, ie the Sigma in gee. A long time ago, in my days as a student i remember, vagely, I saw a paper in Biometics on a correction to apply to Fisher method for pooling several tests to take into account the correlation between the variables. Heberto Ghezzo McGill University Montreal - Canada -Original Message- From: [EMAIL PROTECTED] on behalf of Spencer Graves Sent: Wed 8/2/2006 4:25 AM To: Grathwohl, Dominik, LAUSANNE, NRC-BAS Cc: r-help@stat.math.ethz.ch; Torsten Hothorn Subject: Re: [R] Correlation adjusted Bonferroni? (was: Multiple tests on repeated measurements) I'm not familiar with the correlation adjustment to Bonferroni you mention below, though it sounds interesting. However, I think there is something not right about it or about how you have interpreted it. Your code produced the following for me: p.value.raw p.value.bon p.value.adj = raw.p = bon.p =multcomp.p bon.cor.p diff/v=0 0.028572509 0.057145019 0.054951102 0.034934913 diff/v=1 0.001727993 0.003455987 0.003415545 0.002119276 In the absence of other information, I'd be inclined to believe csimint(..)$p.value.adj or ..$p.value.bon over your bon.cor.p. Hope this helps. Spencer Graves Grathwohl, Dominik, LAUSANNE, NRC-BAS wrote: Dear R-helpers: My question is how do I efficient and valid correct for multiple tests in a repeated measurement design: Suppose we measure at two distinct visits with repeated subjects a treatment difference on the same variable. The treatment differences are assessed with a mixed model and adjusted by two methods for multiple tests: # 1. Method: Adjustment with library(multcomp) library(nlme) library(multcomp) n - 30 # number of subjects sd1 - 0.5 # Standard deviation of the random intercept sd2 - 0.8 # Standard deviation of the residuals id - rep(1:n,times=2); v - rep(0:1, each=n); trt - rep(sample(rep(0:1, each=n/2), n), times=2) df - data.frame(id, v, trt, y=2 + rep(rnorm(10,0,sd1), times=2) + 0.5*v + 0.7*trt + 0.2*v*trt + rnorm(2*n, 0, sd2)) m1 - lme(y ~ v + trt + v*trt, data=df, random= ~ 1|id) summary(m1) par4 - m1$coef$fixed cov4 - vcov(m1) cm4 - matrix(c(0, 0, 1, 0, 0, 0, 1, 1), nrow = 2, ncol=4, byrow=TRUE, dimnames = list(c(diff/v=0, diff/v=1), c(C.1, C.2, C.3, C.4))) v4 - csimint(estpar=par4, df=n-6, # I'm not sure whether I found # the correct degrees of freedom covm=cov4, cmatrix=cm4, conf.level=0.95) sv4 - summary(v4) # 2. Method: I found in Handbook of Statistics Vol 13, p.616, # same can be found in http://home.clara.net/sisa/bonhlp.htm # Bonferroni on correlated outcomes: raw.p - sv4$p.value.raw co4 - cor(df$y[df$v==0],df$y[df$v==1]) rho - mean(c(1,co4,co4,1)) pai - 1-(1-raw.p)^2^(1-rho) # The results of two methods are presented in the following lines: out - cbind(raw.p, sv4$p.value.bon, sv4$p.value.adj, pai) colnames(out) - c(raw.p, bon.p, multcomp.p, bon.cor.p) out As you can see there are quite big differences between the two ways adjusting for multiple tests on repeated measurements. I guess that the multcomp library is not appropriate for this kind of hypotheses. However I could not find an explanation in the help files. May be one of the experts can point me in the right direction? Kind regards, Dominik platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor2.1 year 2005 month12 day 20 svn rev 36812 language R [[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] Summary method needed?
On Wed, 2 Aug 2006, Christian Hennig wrote: Hi list, I'm updating my fpc package at the moment and will add some new functions. I learned that there should be print and summary methods for the key functions. for 'classes', I think. The purpose of the summary methods seems to be to reduce the possibly incredibly complex information in the function's output and the print method (print.summary.foo) should print an overview of the result. Normally, summary() gives more information than print() would give for a non-data object, often by manipulations on the object. Now, the White Book said that summary produces `a synopsis of an object', but that does not seem to be the practice for model-fitting classes even in the White Book (but it is for data objects). But in some cases the print method will make use of more or less all the output information of the function. Is there any reason to implement a summary method in these cases? Would a more concise print() method be useful? If so the existing print() could become summary(). -- 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] Summary method needed?
Thank you Brian! I'm updating my fpc package at the moment and will add some new functions. I learned that there should be print and summary methods for the key functions. for 'classes', I think. Yes. But in some cases the print method will make use of more or less all the output information of the function. Is there any reason to implement a summary method in these cases? Would a more concise print() method be useful? If so the existing print() could become summary(). :-) What I initially did some years ago was to write summary methods to print out the required informations. Then M. Maechler told me that this is not the purpose of a summary method and I should write a print.summary method for this. Now I realise that I actually just want to print, and I don't really need the extra synopsis to be done by summary(). Now is there any recommendation on this? My intuition would be to write a print, but not a summary method. Christian -- 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 *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 [EMAIL PROTECTED], www.homepages.ucl.ac.uk/~ucakche __ 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] lme4 and lmeSplines
I'm trying to use the lmeSplines package together with lme4. Below is (1) an example of lmeSplines together with nlme (2) an attempt to use lmeSplines with lme4 (3) then a comparison of the random effects from the two different methods. (1) require(lmeSplines) data(smSplineEx1) dat - smSplineEx1 dat.lo - loess(y~time, data=dat) plot(dat.lo) dat$all - rep(1,nrow(dat)) times20 - seq(1,100,length=20) Zt20 - smspline(times20) dat$Zt20 - approx.Z(Zt20, times20, dat$time) fit1.20 - lme(y~time, data=dat, random=list(all=pdIdent(~Zt20-1))) # Loess model dat.lo - loess(y~time, data=dat) plot(dat.lo) # Spline model with(dat, lines(fitted(fit1.20)~time, col=red)) # Save random effects for later ranef.nlme - unlist(ranef(fit1.20)) (2) Now an attempt to use lme4: library(lmeSplines) detach(package:nlme) library(lme4) data(smSplineEx1) # Use 20 spline in lme4 dat - smSplineEx1 times20 - seq(1,100,length=20) Zt20 - smspline(times20) dat - cbind(dat, approx.Z(Zt20, times20, dat$time)) names(dat)[4:21] - paste(Zt,names(dat)[4:21],sep=) dat$all - rep(1, nrow(dat)) fit1.20 - lmer(y~time +(-1+Zt1|all)+(-1+Zt2|all)+(-1+Zt3|all)+(-1+Zt4|all)+(-1+Zt5|all)+(-1+Zt6|all) +(-1+Zt7|all)+(-1+Zt8|all)+(-1+Zt9|all)+(-1+Zt10|all)+(-1+Zt11|all)+(-1+Zt12|all) +(-1+Zt13|all)+(-1+Zt14|all)+(-1+Zt15|all)+(-1+Zt16|all)+(-1+Zt17|all)+(-1+Zt18|all), data=dat) #summary(fit1) # Plot the data and loess fit dat.lo - loess(y~time, data=dat) plot(dat.lo) # Fitting with splines with(dat, lines(fitted(fit1.20)~time, col=red)) ranef.lme4 - unlist(ranef(fit1.20)) (3) Compare nlme lme4 random effects plot(ranef.nlme~ranef.lme4) The plot of fitted values from lme4 is visually appealing, but the random effects from lme4 are peculiar--three are non-zero and the rest are essentially zero. Any help in getting lme4 + lmeSplines working would be appreciated. It is not unlikely that I have the lmer syntax wrong. Kevin Wright __ 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] ggplot facet label font size
How do I change the font size in the facet labels along the edges of the plot? For example (from the ggplot help file): p-ggplot(tips, sex ~ smoker, aesthetics=list(x=tip/total_bill)) gghistogram(p) In this plot, the facet labels are smoker: No, smoker: Yes, sex: Female, sex: Male. What command can I use to reduce the font size of these labels? In lattice terminology, cex is used to scale these strip labels. But I couldn't find the equivalent in ggplot. The reason I'm asking is I have a 9x7 array of plots which I've been plotting with lattice. I wanted to use ggplot because I like having the labels on the edge of the plots, but the label font size is too large and exceeding the size of the label box. Thanks in advance... -Sam __ 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 adjusted Bonferroni? (was: Multiple tests on repeated measurements)
On 2 Aug 2006 at 13:48, R Heberto Ghezzo, Dr wrote: HI, just my 2 cents. Bonferroni et al, assume independent tests, thus p ~ p*k with k the number of tests, in repeated measures, each measure is correlated with the previous, so k is not 2 but 2-q. I do not know q but it should be a function of the correlation between measures, ie the Sigma in gee. A long time ago, in my days as a student i remember, vagely, I saw a paper in Biometics on a correction to apply to Fisher method for pooling several tests to take into account the correlation between the variables. Heberto Ghezzo McGill University Montreal - Canada Most assuredly, the (usual) Bonferroni correction does not assume independent test statistics, as it is based on Bonferroni's Inequality which holds for absolutely any collection of valid tests. If the test statistics were independent 1-(1-p)^k would replace p*k. But strong correlation among test statistics can certainly reduce the limit well below 1-(1-p)^k . ---JRG John R. Gleason Syracuse University 430 Huntington Hall Voice: 315-443-3107 Syracuse, NY 13244-2340 USA FAX: 315-443-4085 PGP public key at keyservers __ 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] Summary method needed?
On Wed, 2 Aug 2006, Christian Hennig wrote: Thank you Brian! I'm updating my fpc package at the moment and will add some new functions. I learned that there should be print and summary methods for the key functions. for 'classes', I think. Yes. But in some cases the print method will make use of more or less all the output information of the function. Is there any reason to implement a summary method in these cases? Would a more concise print() method be useful? If so the existing print() could become summary(). :-) What I initially did some years ago was to write summary methods to print out the required informations. Then M. Maechler told me that this is not the purpose of a summary method and I should write a print.summary method for this. Now I realise that I actually just want to print, and I don't really need the extra synopsis to be done by summary(). Now is there any recommendation on this? My intuition would be to write a print, but not a summary method. That sounds fine for your purposes. -- 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] tcl/tk bind destroy event
Hello! I want to create a messagebox whenever the user wants to destroy the window (e.g. Alt-F4 or the 'x' in the right top corner) and ask if a modified file should be saved or not. If 'cancel' is chosen then nothing should happen and the windows still should be existing. This doesn't work. When I press cancel the window will be destroyed although. I also implemented a menu item 'Quit' where I show the same messagebox and there it works fine. How can I make it work or is there another method to do this? I'm very new to R and tcl/tk. Here is part of my code: exitProg - function() { returnVal - tkmessageBox(title=Question, message=Save modified file?, icon=question, type=yesnocancel, default=yes) returnVal - as.character(returnVal) if( returnVal == yes ) { # save file value - saveFile() # destroy window when save was successfull if( value == 1 ) tkdestroy(mw) } if( returnVal == no ) { tkdestroy(mw) } if( returnVal == cancel ) { # do nothing cat(Cancel was pressed.\n) } } # bind the destroy event in order to show a message box tkbind(mw,Destroy,exitProg) # menu item which works fine tkadd(fileMenu, command, label=Quit, command=exitProg) Thank you. Franco Mendolia __ 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] Course***Dr Frank Harrell's Regression Modeling Strategies in R/Splus course *** September 2006 near you (San Francisco, Washington DC, Atlanta)
__ 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] Finding the position of a variable in a data.frame
Simple problem but I don't see the answer. I'm trying to clean up some data I have 120 columns in a data.frame. I have one value in a column named blaw that I want to change. How do I find the coordinates. I can find the row by doing a subset on the data.frame but how do I find out here blaw is in columns without manually counting them or converting names(Df) to a list and reading down the list. Simple example cat - c( 3,5,6,8,0) dog - c(3,5,3,6, 0) rat - c (5, 5, 4, 9, 0) bat - c( 12, 42, 45, 32, 54) Df - data.frame(cbind(cat, dog, rat, bat)) Df subset(Df, bat = 50) results cat dog rat bat 5 0 0 0 54 Thus I know that my target is in row 5 but how do I figure out where 'bat' is? All I want to do is be able to say Df[5,4] - 100 Is there some way to have function(bat) return the column number: some kind of a colnum() function? I had thought that I had found somthing in library(gdata) matchcols but no luck. __ 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] Finding the position of a variable in a data.frame
?which which(Df = 50, arr.ind=T) row col 5 5 4 On 8/2/06, John Kane [EMAIL PROTECTED] wrote: Simple problem but I don't see the answer. I'm trying to clean up some data I have 120 columns in a data.frame. I have one value in a column named blaw that I want to change. How do I find the coordinates. I can find the row by doing a subset on the data.frame but how do I find out here blaw is in columns without manually counting them or converting names(Df) to a list and reading down the list. Simple example cat - c( 3,5,6,8,0) dog - c(3,5,3,6, 0) rat - c (5, 5, 4, 9, 0) bat - c( 12, 42, 45, 32, 54) Df - data.frame(cbind(cat, dog, rat, bat)) Df subset(Df, bat = 50) results cat dog rat bat 5 0 0 0 54 Thus I know that my target is in row 5 but how do I figure out where 'bat' is? All I want to do is be able to say Df[5,4] - 100 Is there some way to have function(bat) return the column number: some kind of a colnum() function? I had thought that I had found somthing in library(gdata) matchcols but no luck. __ 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] Finding the position of a variable in a data.frame
--- jim holtman [EMAIL PROTECTED] wrote: ?which which(Df = 50, arr.ind=T) row col 5 5 4 I knew it was going to be blinding obvious! I even read ?which somehow misunderstood arr.ind. Thanks again. On 8/2/06, John Kane [EMAIL PROTECTED] wrote: Simple problem but I don't see the answer. I'm trying to clean up some data I have 120 columns in a data.frame. I have one value in a column named blaw that I want to change. How do I find the coordinates. I can find the row by doing a subset on the data.frame but how do I find out here blaw is in columns without manually counting them or converting names(Df) to a list and reading down the list. Simple example cat - c( 3,5,6,8,0) dog - c(3,5,3,6, 0) rat - c (5, 5, 4, 9, 0) bat - c( 12, 42, 45, 32, 54) Df - data.frame(cbind(cat, dog, rat, bat)) Df subset(Df, bat = 50) results cat dog rat bat 5 0 0 0 54 Thus I know that my target is in row 5 but how do I figure out where 'bat' is? All I want to do is be able to say Df[5,4] - 100 Is there some way to have function(bat) return the column number: some kind of a colnum() function? I had thought that I had found somthing in library(gdata) matchcols but no luck. __ 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? __ 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] Finding the position of a variable in a data.frame
it is the well-known wicked which problem: if you had (grammatically incorrectly) thought ... which I want to change then you might have been led to type (in another window): ?which and you would have seen the light. Maybe that() should be an alias for which()? url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 On Aug 2, 2006, at 4:01 PM, John Kane wrote: Simple problem but I don't see the answer. I'm trying to clean up some data I have 120 columns in a data.frame. I have one value in a column named blaw that I want to change. How do I find the coordinates. I can find the row by doing a subset on the data.frame but how do I find out here blaw is in columns without manually counting them or converting names(Df) to a list and reading down the list. Simple example cat - c( 3,5,6,8,0) dog - c(3,5,3,6, 0) rat - c (5, 5, 4, 9, 0) bat - c( 12, 42, 45, 32, 54) Df - data.frame(cbind(cat, dog, rat, bat)) Df subset(Df, bat = 50) results cat dog rat bat 5 0 0 0 54 Thus I know that my target is in row 5 but how do I figure out where 'bat' is? All I want to do is be able to say Df[5,4] - 100 Is there some way to have function(bat) return the column number: some kind of a colnum() function? I had thought that I had found somthing in library(gdata) matchcols but no luck. __ 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] Finding the position of a variable in a data.frame
John Kane wrote: Simple problem but I don't see the answer. I'm trying to clean up some data I have 120 columns in a data.frame. I have one value in a column named blaw that I want to change. How do I find the coordinates. I can find the row by doing a subset on the data.frame but how do I find out here blaw is in columns without manually counting them or converting names(Df) to a list and reading down the list. Simple example cat - c( 3,5,6,8,0) dog - c(3,5,3,6, 0) rat - c (5, 5, 4, 9, 0) bat - c( 12, 42, 45, 32, 54) Df - data.frame(cbind(cat, dog, rat, bat)) Df subset(Df, bat = 50) results cat dog rat bat 5 0 0 0 54 Thus I know that my target is in row 5 but how do I figure out where 'bat' is? grep(bat, names(Df)) All I want to do is be able to say Df[5,4] - 100 Why not do it this way? Df$bat - replace(Df$bat, Df$bat =50, 100) Is there some way to have function(bat) return the column number: some kind of a colnum() function? I had thought that I had found somthing in library(gdata) matchcols but no luck. __ 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.
[R] question about stdize() in PLS package
Dear all, I am using the PLS package for PLSR analysis. And I have a basic question about the standardize procedure, which I feel the PLS manual does not explain clearly. I am hoping that I could get some help from the list. From the example in the Standardization of Data Matrices section, I can standardize X matrix and make prediction by using: mod=plsr(y~stdize(X),ncomp=6,data=NIR[NIR$train,]) pred=predict(mod,newdata=NIR[!NIR$train,]) In the manual, it is commented that the prediction is automatically standardized. So I guess I won't need to standardize X matrix of the test set for the prediction. However, what if I do not want a standardize model from the beginning? Then my code would be like: mod=plsr(y~X,ncomp=6,data=NIR[NIR$train,]) But the R code for the prediction should still be the same (please correct me if any code is wrong): pred=predict(mod,newdata=NIR[!NIR$train,]) Would this time the X matrix of the newdata be automatical standardized or not? I am so confused about the automatically standardization. Please share some experience. Really appreciate your kind help! Sincerely, Jeny __ 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] Finding the position of a variable in a data.frame
--- Chuck Cleland [EMAIL PROTECTED] wrote: John Kane wrote: Simple problem but I don't see the answer. I'm trying to clean up some data I have 120 columns in a data.frame. I have one value in a column named blaw that I want to change. How do I find the coordinates. I can find the row by doing a subset on the data.frame but how do I find out here blaw is in columns without manually counting them or converting names(Df) to a list and reading down the list. Simple example cat - c( 3,5,6,8,0) dog - c(3,5,3,6, 0) rat - c (5, 5, 4, 9, 0) bat - c( 12, 42, 45, 32, 54) Df - data.frame(cbind(cat, dog, rat, bat)) Df subset(Df, bat = 50) results cat dog rat bat 5 0 0 0 54 Thus I know that my target is in row 5 but how do I figure out where 'bat' is? grep(bat, names(Df)) Thank you, I have never used grep. More reading :( All I want to do is be able to say Df[5,4] - 100 Why not do it this way? Df$bat - replace(Df$bat, Df$bat =50, 100) Maybe because it is too blinding simple? I'm still thinking in SAS or Systat. A great solution thanks very much Is there some way to have function(bat) return the column number: some kind of a colnum() function? I had thought that I had found somthing in library(gdata) matchcols but no luck. __ 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] Finding the position of a variable in a data.frame
--- roger koenker [EMAIL PROTECTED] wrote: it is the well-known wicked which problem: if you had (grammatically incorrectly) thought ... which I want to change then you might have been led to type (in another window): ?which and you would have seen the light. Maybe that() should be an alias for which()? One also has to understand which and I missed it. I don't think that which is really that grammatically incorrect anymore. Thanks url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 On Aug 2, 2006, at 4:01 PM, John Kane wrote: Simple problem but I don't see the answer. I'm trying to clean up some data I have 120 columns in a data.frame. I have one value in a column named blaw that I want to change. How do I find the coordinates. I can find the row by doing a subset on the data.frame but how do I find out here blaw is in columns without manually counting them or converting names(Df) to a list and reading down the list. Simple example cat - c( 3,5,6,8,0) dog - c(3,5,3,6, 0) rat - c (5, 5, 4, 9, 0) bat - c( 12, 42, 45, 32, 54) Df - data.frame(cbind(cat, dog, rat, bat)) Df subset(Df, bat = 50) results cat dog rat bat 5 0 0 0 54 Thus I know that my target is in row 5 but how do I figure out where 'bat' is? All I want to do is be able to say Df[5,4] - 100 Is there some way to have function(bat) return the column number: some kind of a colnum() function? I had thought that I had found somthing in library(gdata) matchcols but no luck. __ 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 with formatting legend in xyplot
I am doing a xyplot: (x~y, groups = z, pch=8, auto.key=T). This changes the symbol in the graph to an asterisk (*), but not in the legend, which is still an open circle. I have found out how to manipulate the position and the color of the letters in the legend, but cannot change the legend symbol to match the symbol in the graph. Could you help? Thanks, Kaushik [[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] Syntax of Levene's test
On 8/2/06, John Fox [EMAIL PROTECTED] wrote: The argument y is the response variable and group is a factor defining groups (as ?levene.test says). If you have more than one factor, then you can use interaction() to create from them a factor with levels given by the product set of the levels of the individual factors. Here's an example library(car) data(Moore) attach(Moore) levene.test(conformity, interaction(fcategory, partner.status)) Levene's Test for Homogeneity of Variance Df F value Pr(F) group 5 1.4694 0.2219 39 levels(interaction(fcategory, partner.status)) [1] high.high low.highmedium.high high.lowlow.low [6] medium.low levels(fcategory) [1] high lowmedium levels(partner.status) [1] high low I'll add a couple of examples to the help page. Thanks, John. Now, I understand how to use levene.test. There is only a question remaining: is the null hypothesis corresponding to homogeneity of variances, i.e., should one conclude that Levene's Test for Homogeneity of Variance Df F valuePr(F) group 95 3.5919 2.2e-16 *** 864 tell us that the hypothesis that the variances are equal is (highly) significant? Paul __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with formatting legend in xyplot
If you set it through par.settings then it will affect both the drawing and the legend: xyplot(Sepal.Length ~ Petal.Length, iris, groups = Species, auto.key = TRUE, par.settings = list(superpose.symbol = list(pch = *, cex = 1))) On 8/2/06, Kaushik Katari [EMAIL PROTECTED] wrote: I am doing a xyplot: (x~y, groups = z, pch=8, auto.key=T). This changes the symbol in the graph to an asterisk (*), but not in the legend, which is still an open circle. I have found out how to manipulate the position and the color of the letters in the legend, but cannot change the legend symbol to match the symbol in the graph. Could you help? Thanks, Kaushik [[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] Baseline levels summary.Design
Does anyone know how summary.Design in Hmisc selects the baseline level for an odds ratio? Does it select the level of the factor variable with the largest number of observations? Regards, -Cody This e-mail, facsimile, or letter and any files or attachmen...{{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.
Re: [R] Finding the position of a variable in a data.frame
On Wed, 02 Aug 2006 17:12:53 -0400, Chuck Cleland wrote: Why not do it this way? Df$bat - replace(Df$bat, Df$bat =50, 100) Is that any different, performancewise, than the following? Df$bat[Df$bat = 50] - 100 Gerald Jansen ... John Kane wrote: Simple example cat - c( 3,5,6,8,0) dog - c(3,5,3,6, 0) rat - c (5, 5, 4, 9, 0) bat - c( 12, 42, 45, 32, 54) Df - data.frame(cbind(cat, dog, rat, bat)) ... __ 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] unbalanced mixed effects models for fully factorial designs
Does anyone know of a way of dealing with unbalanced mixed effects (fixed and random factors) for fully factorial designs. An example of such data is given below; The response variable is SQRTRECRUITS SEASON is a random factor DENSITY is a fixed factor Thus DENSITY:SEASON is a fixed factor. Therefore, whereas the effects of SEASON and DENSITY:SEASON should be tested against the overall residual (error) term, the effect of DENSITY should be tested against the DENSITY:SEASON interaction. To complicate matters, the data are unbalanced, and thus Type III SS are preferable quinn - structure(list(SEASON = structure(as.integer(c(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4)), .Label = c(Autumn, Spring, Summer, Winter), class = factor, contrasts = contr.sum), DENSITY = structure(as.integer(c(2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1)), .Label = c(High, Low), class = factor), RECRUITS = as.integer(c(15, 10, 13, 13, 5, 11, 10, 15, 10, 13, 1, 21, 31, 21, 18, 14, 27, 34, 49, 69, 55, 28, 54, 14, 18, 20, 21, 4, 22, 30, 36, 13, 13, 8, 0, 0, 10, 1, 5, 9, 4, 5)), SQRTRECRUITS = c(3.872983, 3.162278, 3.605551, 3.605551, 2.236068, 3.316625, 3.162278, 3.872983, 3.162278, 3.605551, 1, 4.582576, 5.567764, 4.582576, 4.242641, 3.741657, 5.196152, 5.830952, 7, 8.306624, 7.416198, 5.291503, 7.348469, 3.741657, 4.242641, 4.472136, 4.582576, 2, 4.690416, 5.477226, 6, 3.605551, 3.605551, 2.828427, 0, 0, 3.162278, 1, 2.236068, 3, 2, 2.236068), GROUP = structure(as.integer(c(4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 8, 8, 8, 7, 7, 7, 7, 7, 7)), .Label = c(AutumnHigh, AutumnLow, SpringHigh, SpringLow, SummerHigh, SummerLow, WinterHigh, WinterLow ), class = factor)), .Names = c(SEASON, DENSITY, RECRUITS, SQRTRECRUITS, GROUP), row.names = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42), class = data.frame) I realise that Anova (car package) calculated Type III SS (given the correct contrasts), however, this does not permit mixed models. Conversely, if I was to specify a aov model such as; summary(aov(SQRTRECRUITS ~ SEASON+DENSITY+Error(DENSITY:SEASON), data=quinn)) purely to obtain a test for DENSITY (ignoring the test for SEASON), the SS are Type I. Although it is possible to calculate out the F-ratio (and p-value) calculations manually and substitute them into the anova tables, I cant help think that there must be a better solution. Is there any expectation that there will be a summary routine that provides Type II and Type II SS, and or is aov ever likely to accommodate non-hierarchical mixed models? Regards Murray __ 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] ggplot facet label font size
On 8/2/06, Walker, Sam [EMAIL PROTECTED] wrote: How do I change the font size in the facet labels along the edges of the plot? For example (from the ggplot help file): p-ggplot(tips, sex ~ smoker, aesthetics=list(x=tip/total_bill)) gghistogram(p) In this plot, the facet labels are smoker: No, smoker: Yes, sex: Female, sex: Male. What command can I use to reduce the font size of these labels? In lattice terminology, cex is used to scale these strip labels. But I couldn't find the equivalent in ggplot. The reason I'm asking is I have a 9x7 array of plots which I've been plotting with lattice. I wanted to use ggplot because I like having the labels on the edge of the plots Note that lattice can do that by using custom strip functions: library(ggplot) # data resides here library(lattice) my.strip - function(which.given, which.panel, ...) if (which.given == 1 which.panel[2] == 2) strip.default(which.given, which.panel, ...) my.strip.left - function(which.given, which.panel, ..., horizontal) if (which.given == 2 which.panel[1] == 1) strip.default(which.given, which.panel, horizontal = FALSE, ...) histogram(~ tip/total_bill | sex + smoker, tips, strip = my.strip, strip.left = my.strip.left, par.settings = list(add.text = list(cex = 0.7))) __ 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] Syntax of Levene's test
Dear Paul, Levene's test tests the null hypothesis that the variance are equal, so a small p-value suggests that they are not. Looking at your output, it seems odd that you have as many as 96 groups. John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith Sent: Wednesday, August 02, 2006 5:02 PM To: r-help@stat.math.ethz.ch Subject: Re: [R] Syntax of Levene's test On 8/2/06, John Fox [EMAIL PROTECTED] wrote: The argument y is the response variable and group is a factor defining groups (as ?levene.test says). If you have more than one factor, then you can use interaction() to create from them a factor with levels given by the product set of the levels of the individual factors. Here's an example library(car) data(Moore) attach(Moore) levene.test(conformity, interaction(fcategory, partner.status)) Levene's Test for Homogeneity of Variance Df F value Pr(F) group 5 1.4694 0.2219 39 levels(interaction(fcategory, partner.status)) [1] high.high low.highmedium.high high.low low.low [6] medium.low levels(fcategory) [1] high lowmedium levels(partner.status) [1] high low I'll add a couple of examples to the help page. Thanks, John. Now, I understand how to use levene.test. There is only a question remaining: is the null hypothesis corresponding to homogeneity of variances, i.e., should one conclude that Levene's Test for Homogeneity of Variance Df F valuePr(F) group 95 3.5919 2.2e-16 *** 864 tell us that the hypothesis that the variances are equal is (highly) significant? Paul __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 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] Syntax of Levene's test
On 8/3/06, John Fox [EMAIL PROTECTED] wrote: Levene's test tests the null hypothesis that the variance are equal, so a small p-value suggests that they are not. Looking at your output, it seems odd that you have as many as 96 groups. Thanks again, John. I have 4 factors with 3, 4, 4 and 2 levels (resulting in 96 groups), respectively. For each combination of the 4 factors, I have 10 observations. Paul __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] read.spss 'error reading system-file header'
Finn Sandø fs at fs-analyse.dk writes: When I try to import an spss sav file with read.spss() I am getting the following error 'Error in read.spss(X:\\.sav) : error reading system-file header' and the import process is aborted. I have tried in v. 2.3.0 and 2.3.1 The sav-file loads without problems in spss v14 I have tried saving in older spss v7 but are getting the same result. The read.spss() has other errors (the 'Unrecognized record type 7, subtype 7 encountered in system file') but it does not seem to have any impact. These are also the error messages you get when the .sav file in question was created with the SPSS Data Entry product. If that is the case, then it is covered by section 3.1 of the R Data Import/Export document. Michael __ 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] Fitting models in a loop
Thanks to all who helped me with this problem, especially Bill Venables and Gabor Grothendieck. I hope one day to learn more about the advanced features of the language used by Bill. From a practical standpoint I think I will just avoid doing things like this in my teaching. It is hard enough just getting across the elementary ideas. Murray Jorgensen -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: [EMAIL PROTECTED]Fax 7 838 4155 Phone +64 7 838 4773 wkHome +64 7 825 0441Mobile 021 1395 862 __ 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 in step()
Hi.. I pass a lm() object to step() but after a few steps it stops with the error message. say: x1-lm(y~.,data=z) x2-step(x1) i have 516 observations and 299 variables. after a few steps i get the error message: Error in one %*% x : requires numeric matrix/vector arguments anyone knows why this happens after some steps. its an lm object that is passed so i am not sure where the error might be Thanks. Harsh - [[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.