[R] plot legend: combining filled boxes and lines
Hello, I have difficulties combining boxes and lines in plot legend. I searched previous R-posts and found this (with no solution): http://tolstoy.newcastle.edu.au/R/help/06/07/30248.html. Is there a way to avoid boxes behind the line legends? x1 - rnorm(100) x2 - rnorm(100, 2) hist(x1, main = , col = orange,ylab = density, xlab = x, freq = F, density = 55, xlim = c(-2, 5), ylim = c(0, 0.5)) par(new = T) hist(x2, main = , col = green, ylab = , xlab = ,axes = F, xlim = c(-2, 5), ylim = c(0, 0.5), density = 45, freq = F) abline(v = mean(x1), col = orange, lty = 2, lwd = 2.5) abline(v = mean(x2), col = green, lty = 2, lwd = 2.5) legend(3, 0.45, legend = c(x1, x2, mean(x1), mean(x2)), col = c(orange, green), fill=c(orange,green, 0, 0), lty = c(0, 0, 2, 2), merge = T) Thanks Lauri __ 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] plot legend: combining filled boxes and lines
Check out: http://tolstoy.newcastle.edu.au/R/e2/help/07/05/16777.html On 9/10/07, Lauri Nikkinen [EMAIL PROTECTED] wrote: Hello, I have difficulties combining boxes and lines in plot legend. I searched previous R-posts and found this (with no solution): http://tolstoy.newcastle.edu.au/R/help/06/07/30248.html. Is there a way to avoid boxes behind the line legends? x1 - rnorm(100) x2 - rnorm(100, 2) hist(x1, main = , col = orange,ylab = density, xlab = x, freq = F, density = 55, xlim = c(-2, 5), ylim = c(0, 0.5)) par(new = T) hist(x2, main = , col = green, ylab = , xlab = ,axes = F, xlim = c(-2, 5), ylim = c(0, 0.5), density = 45, freq = F) abline(v = mean(x1), col = orange, lty = 2, lwd = 2.5) abline(v = mean(x2), col = green, lty = 2, lwd = 2.5) legend(3, 0.45, legend = c(x1, x2, mean(x1), mean(x2)), col = c(orange, green), fill=c(orange,green, 0, 0), lty = c(0, 0, 2, 2), merge = T) Thanks Lauri __ 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] Problems with strsplit
Hello, I would like to know what can I do if I use strplit with a string and I want to use the middle left,I mean I have this: strsplit(bA531F16-rep,\\-) [[1]] [1] bA531F16 rep I would like to work just with bA531F16 in another variable, what could I do?, Thank you - Sé un Mejor Amante del Cine ¿Quieres saber cómo? ¡Deja que otras personas te ayuden!. [[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] lattice panel.lmline problem
Why not use the more simple xyplot(total.fat~x|variable,groups=Group, data=tmp1,type=c(p,r)) ??? See ?panel.xyplot and especially the type argument of that panel function. Best regards Frede Aakmann Tøgersen Scientist UNIVERSITY OF AARHUS Faculty of Agricultural Sciences Dept. of Genetics and Biotechnology Blichers Allé 20, P.O. BOX 50 DK-8830 Tjele Phone: +45 8999 1900 Direct: +45 8999 1878 E-mail: [EMAIL PROTECTED] Web: http://www.agrsci.org This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email. -Oprindelig meddelelse- Fra: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] På vegne af Ross Darnell Sendt: 10. september 2007 07:55 Til: r-help@stat.math.ethz.ch Emne: [R] lattice panel.lmline problem I am wanting to generate panels showing scatterplots with the linear fitted line for two groups within each panel superimposed. I have two conditioning factors, variable and Group and I want separate panels for each level of variable with different symbols and lmlines for each level of Group. However all observations for a group are missing for some variables so I would still like the points and lmline for the observed group plotted for that variable(panel). My attempt is print(xyplot(total.fat~x|variable,data=tmp1,subscripts=TRUE, scales=list(x=list(relation=free)),xlab=,groups=Group, panel=function(x,y,subscripts,...){ panel.superpose(x,y,subscripts,...) if(length(x[subscripts])!=0) {panel.superpose(x,y,panel.groups=panel.lmline,subscripts,...)}})) Which gives an error Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases Which occurs when the first panel with all values for one group are missing. The same error is returned if I replace the last line without the if statement which obviously means it's ignored. Of course I may be taking the wrong tack completely to get the result I need. Any advice would be appreciated Ross Darnell [[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] plot legend: combining filled boxes and lines
Thanks Gabor, I got it! For example: x1 - rnorm(100) x2 - rnorm(100, 2) hist(x1, main = , col = orange,ylab = density, xlab = x, freq = F, density = 55, xlim = c(-2, 5), ylim = c(0, 0.5)) par(new = T) hist(x2, main = , col = green, ylab = , xlab = ,axes = F, xlim = c(-2, 5), ylim = c(0, 0.5), density = 45, freq = F) abline(v = mean(x1), col = orange, lty = 2, lwd = 2.5) abline(v = mean(x2), col = green, lty = 2, lwd = 2.5) legend(3, 0.45, legend = c(x1, x2, mean(x1), mean(x2)), col = rep(c(orange, green), 2), pch=c(15,15, NA, NA), pt.cex=2, lty = c(0, 0, 2, 2)) -Lauri 2007/9/10, Gabor Grothendieck [EMAIL PROTECTED]: Check out: http://tolstoy.newcastle.edu.au/R/e2/help/07/05/16777.html On 9/10/07, Lauri Nikkinen [EMAIL PROTECTED] wrote: Hello, I have difficulties combining boxes and lines in plot legend. I searched previous R-posts and found this (with no solution): http://tolstoy.newcastle.edu.au/R/help/06/07/30248.html. Is there a way to avoid boxes behind the line legends? x1 - rnorm(100) x2 - rnorm(100, 2) hist(x1, main = , col = orange,ylab = density, xlab = x, freq = F, density = 55, xlim = c(-2, 5), ylim = c(0, 0.5)) par(new = T) hist(x2, main = , col = green, ylab = , xlab = ,axes = F, xlim = c(-2, 5), ylim = c(0, 0.5), density = 45, freq = F) abline(v = mean(x1), col = orange, lty = 2, lwd = 2.5) abline(v = mean(x2), col = green, lty = 2, lwd = 2.5) legend(3, 0.45, legend = c(x1, x2, mean(x1), mean(x2)), col = c(orange, green), fill=c(orange,green, 0, 0), lty = c(0, 0, 2, 2), merge = T) Thanks Lauri __ 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] Are the error messages of ConstrOptim() consisten with each other?
Dear Friends. I found something very puzzling with constOptim(). When I change the parameters for ConstrOptim, the error messages do not seem to be consistent with each other: constrOptim(c(0.5,0.3,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci) Error in constrOptim(c(0.5, 0.3, 0.5), f = fit.error, gr = fit.error.grr, : initial value not feasible constrOptim(c(0.5,0.9,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci) Error in constrOptim(c(0.5, 0.9, 0.5), f = fit.error, gr = fit.error.grr, : initial value not feasible constrOptim(c(0.3,0.5,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci) Error in f(theta, ...) : argument lambda1 is missing, with no default I only changed the parameters, how come the lambda1 that is not missing in the first 2 cases suddently become missing? For your convenience, I put the complete code below: Best Wishes Yuchen Luo rm(list = ls()) mat=5 rint=c(4.33,4.22,4.27,4.43,4.43,4.44,4.45,4.65,4.77,4.77) tot=rep(13319.17,10) sh=rep(1553656,10) sigmae=c(0.172239074,0.188209271,0.193703774,0.172659891,0.164427247,0.24602361,0.173555309,0.186701165,0.193150456, 0.1857315601) ss=c(56.49,56.39,56.55,57.49,57.37,55.02,56.02,54.35,54.09, 54.67) orange=rep(21.25,10) apple2=expression(rint*(1.0-rec)*(1.0-(pnorm(-lambda/2.0+log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/lambda)-((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))*pnorm(-lambda/2.0-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/lambda))+(exp(rint*(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)*ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0+0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))-sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0*(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*! 1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(-sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0+0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0*(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))-(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0+0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt((lambda*lam! bda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh* 1000.0))-sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0*(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt((lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(-sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0+0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt((lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0*(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt((lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))/((pnorm(-lambda/2.0+log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/lambda)-((ss+(tot/sh*100!
[R] statistical tests under serial dependence
Dear Rosa, please be more specific. Statistical tests for which hypothesis? For example, some tests can be made robust using Heteroskedasticity- *and Autocorrelation-* Consistent (HAC) covariance matrices in package 'sandwich': see - waldtest{lmtest} for a redundant variables test much like anova(). - linear.hypothesis{car} for general linear hypothesis testing in linear regression models. Besides, I'm very ignorant about VIF but I remember there being an article in R-News some years ago, see http://cran.r-project.org/doc/Rnews/Rnews_2003-1.pdf. I hope it helps. Giovanni ## original message was: ## -- Message: 21 Date: Sat, 08 Sep 2007 19:25:07 +0100 From: Rosa Trancoso [EMAIL PROTECTED] Subject: [R] statistical tests under serial dependence To: r-help@stat.math.ethz.ch Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hello! I would like to know if there are already programmed statistical tests for data under serial dependence, for example, considering the variance inflation factor? Thank you very much Best regards Rosa Giovanni Millo Research Dept., Assicurazioni Generali SpA Via Machiavelli 4, 34131 Trieste (Italy) tel. +39 040 671184 fax +39 040 671160 Ai sensi del D.Lgs. 196/2003 si precisa che le informazioni ...{{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] Problems with strsplit
unlist(strsplit(bA531F16-rep,\\-))[1] [1] bA531F16 --- Carlos Morales [EMAIL PROTECTED] wrote: Hello, I would like to know what can I do if I use strplit with a string and I want to use the middle left,I mean I have this: strsplit(bA531F16-rep,\\-) [[1]] [1] bA531F16 rep I would like to work just with bA531F16 in another variable, what could I do?, Thank you - Sé un Mejor Amante del Cine ¿Quieres saber cómo? ¡Deja que otras personas te ayuden!. [[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] command to plot variannce of data (like error bar plot)
Yogesh Tiwari wrote: Hi, How to plot a variance over a data point, something like error bar. Hi Yogesh, The generic method is to use the arrows function, and there are quite a few variations on this theme (in alpha order): brkdn.plot(plotrix) dispbars(plotrix) errbar(Hmisc and sfsmisc) plotCI(gplots and plotrix) plotMeans (Rcmdr) and there are surely more error bar functions of which I am unaware. 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] lattice panel.lmline problem
Thanks Frede I didn't know about the r type. Ross Darnell -Original Message- From: Frede Aakmann Tøgersen [mailto:[EMAIL PROTECTED] Sent: Mon 10-Sep-07 4:45 PM To: Ross Darnell; r-help@stat.math.ethz.ch Subject: SV: [R] lattice panel.lmline problem Why not use the more simple xyplot(total.fat~x|variable,groups=Group, data=tmp1,type=c(p,r)) ??? See ?panel.xyplot and especially the type argument of that panel function. Best regards Frede Aakmann Tøgersen Scientist UNIVERSITY OF AARHUS Faculty of Agricultural Sciences Dept. of Genetics and Biotechnology Blichers Allé 20, P.O. BOX 50 DK-8830 Tjele Phone: +45 8999 1900 Direct: +45 8999 1878 E-mail: [EMAIL PROTECTED] Web: http://www.agrsci.org This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email. -Oprindelig meddelelse- Fra: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] På vegne af Ross Darnell Sendt: 10. september 2007 07:55 Til: r-help@stat.math.ethz.ch Emne: [R] lattice panel.lmline problem I am wanting to generate panels showing scatterplots with the linear fitted line for two groups within each panel superimposed. I have two conditioning factors, variable and Group and I want separate panels for each level of variable with different symbols and lmlines for each level of Group. However all observations for a group are missing for some variables so I would still like the points and lmline for the observed group plotted for that variable(panel). My attempt is print(xyplot(total.fat~x|variable,data=tmp1,subscripts=TRUE, scales=list(x=list(relation=free)),xlab=,groups=Group, panel=function(x,y,subscripts,...){ panel.superpose(x,y,subscripts,...) if(length(x[subscripts])!=0) {panel.superpose(x,y,panel.groups=panel.lmline,subscripts,...)}})) Which gives an error Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases Which occurs when the first panel with all values for one group are missing. The same error is returned if I replace the last line without the if statement which obviously means it's ignored. Of course I may be taking the wrong tack completely to get the result I need. Any advice would be appreciated Ross Darnell [[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] PCA IN R
prcomp() in stats handles matrices with n p well, IMO. -- Bjørn-Helge Mevik __ 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] artificial data matrix with 100000 rows
PS == Paul Smith [EMAIL PROTECTED] on Sun, 9 Sep 2007 12:17:32 +0100 writes: PS On 9/9/07, kevinchang [EMAIL PROTECTED] wrote: I tried to made the matrix with this size by either matrix() or array(). However, there seems to be default limit of number for rows made. I got sort of error message from R .To be specific, m--matrix(ncol=3,nrow=10) error message:[ reached getOption(max.print) -- omitted 7 rows ]] or a-array(dim=c(1,3,10)) error message:reached getOption(max.print) -- omitted 6667 row(s) and 6 matrix slice(s) ] PS That is not an error message, I guess. Definitely not, thank you, Paul! Also, they were not produced by what Kevin showed (namely assignments) but rather when he *prints* the contents of his huge matrix / array. PS When the matrices are huge, R is unable to print them PS totally on the screen, but all data are present. Not at all unable !! R protects you from accidentally overflowing your console with huge amount of non-sensical output. As the warning above mentions, you should look at ? getOption ? options and particularly the 'max.print' option Is '' reached getOption(max.print) '' too difficult to read? You *can* increase the 'max.print' option as much as you like, and that's why I said 'not at all unable' above. Regards, Martin PS For instance, m[(nrow(m)-10):nrow(m),] PS [,1] [,2] [,3] PS [1,] NA NA NA PS [2,] NA NA NA PS [3,] NA NA NA PS [4,] NA NA NA PS [5,] NA NA NA PS [6,] NA NA NA PS [7,] NA NA NA PS [8,] NA NA NA PS [9,] NA NA NA PS [10,] NA NA NA PS [11,] NA NA NA or rather just tail(m) or tail(m, 11) or head(m) or str(m) etc etc PS See PS ?getOption yes indeed. Martin PS 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] Information theoretic approach
Hi, I have been suggested to use Information theoretic approach instead of a Geneal linear model for a multiple regression. Is is possible to perform this type of anlaysis in R? Thanks, Adela -- Adela González Megías Depto. Biología Animal Fac. Ciencias Universidad de Granada 18071 Granada Spain tel: +34 958242309 fax: +34 958243238 __ 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 in installing and loading the BradleyTerry add on package in R
How do I install and load the BradleyTerry add on package in R 2.5.1 in MSWindowsXP environment? Kalyan Roy Indian Market Research Bureau (IMRB) International New Delhi, India [[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] Help in installing and loading the BradleyTerry add on package in R
However you may also need to install the package brlr, since the BradleyTerry package depends on this. For Windows users, it's usually easiest to install packages using the Packages menu in the RGui - any dependencies are then automatically installed. Heather -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jim Lemon Sent: 10 September 2007 12:07 To: [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Help in installing and loading the BradleyTerry add on package in R Kalyan Roy (DEL/MSG) wrote: How do I install and load the BradleyTerry add on package in R 2.5.1 in MSWindowsXP environment? Hi Kalyan, If R CMD INSTALL doesn't work, you can use WinZip or Zip Reader to unzip the package to: C:\Program Files\R-2.5.1\library or whatever your path to the library directory is, and then hand edit the packages.html file in: C:\Program Files\R-2.5.1\doc\html to include the new package in your HTML listing. This will allow you to access the help files and use the package. 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. __ 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] artificial data matrix with 100000 rows
On 9/10/07, Martin Maechler [EMAIL PROTECTED] wrote: PS On 9/9/07, kevinchang [EMAIL PROTECTED] wrote: I tried to made the matrix with this size by either matrix() or array(). However, there seems to be default limit of number for rows made. I got sort of error message from R .To be specific, m--matrix(ncol=3,nrow=10) error message:[ reached getOption(max.print) -- omitted 7 rows ]] or a-array(dim=c(1,3,10)) error message:reached getOption(max.print) -- omitted 6667 row(s) and 6 matrix slice(s) ] PS That is not an error message, I guess. Definitely not, thank you, Paul! Also, they were not produced by what Kevin showed (namely assignments) but rather when he *prints* the contents of his huge matrix / array. PS When the matrices are huge, R is unable to print them PS totally on the screen, but all data are present. Not at all unable !! R protects you from accidentally overflowing your console with huge amount of non-sensical output. As the warning above mentions, you should look at ? getOption ? options and particularly the 'max.print' option Is '' reached getOption(max.print) '' too difficult to read? You *can* increase the 'max.print' option as much as you like, and that's why I said 'not at all unable' above. Regards, Martin PS For instance, m[(nrow(m)-10):nrow(m),] PS [,1] [,2] [,3] PS [1,] NA NA NA PS [2,] NA NA NA PS [3,] NA NA NA PS [4,] NA NA NA PS [5,] NA NA NA PS [6,] NA NA NA PS [7,] NA NA NA PS [8,] NA NA NA PS [9,] NA NA NA PS [10,] NA NA NA PS [11,] NA NA NA or rather just tail(m) or tail(m, 11) or head(m) or str(m) etc etc PS See PS ?getOption yes indeed. Thanks, Martin, for your detailed comments. I have learned something from them. 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 in installing and loading the BradleyTerry add on package in R
Kalyan Roy (DEL/MSG) wrote: How do I install and load the BradleyTerry add on package in R 2.5.1 in MSWindowsXP environment? Hi Kalyan, If R CMD INSTALL doesn't work, you can use WinZip or Zip Reader to unzip the package to: C:\Program Files\R-2.5.1\library or whatever your path to the library directory is, and then hand edit the packages.html file in: C:\Program Files\R-2.5.1\doc\html to include the new package in your HTML listing. This will allow you to access the help files and use the package. 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.
[R] I can't do it again on an other PC : R+RMySQL -error loading dll
Hello, Some weeks ago, thanks to you, I managed to install R, to connect to a local MySQL Database and to launch some queries with a script written with Tinn-R. My script is now ok and would like to test it with the real database. I did the same installation of R, DBI package and RMySQL package I did on my PC (I wrote everything I did in order to make it easy ...) but when I type libray(RMySQL), I got an error message (see below). I tried to copy libmySQL.dll and RMySQL.dll in \system\ (like on my PC), in \system32\, in \R\bin\ and to change the path. But always the same error message ... Has anybody any other solution I can try ? Thanks in advance, Ptit Bleu. - R version 2.5.1 (2007-06-27) Copyright (C) 2007 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R est un logiciel libre livré sans AUCUNE GARANTIE. Vous pouvez le redistribuer sous certaines conditions. Tapez 'license()' ou 'licence()' pour plus de détails. R est un projet collaboratif avec de nombreux contributeurs. Tapez 'contributors()' pour plus d'information et 'citation()' pour la façon de le citer dans les publications. Tapez 'demo()' pour des démonstrations, 'help()' pour l'aide en ligne ou 'help.start()' pour obtenir l'aide au format HTML. Tapez 'q()' pour quitter R. library() .libPaths() [1] C:/R/library library(DBI) library(RMySQL) Error in dyn.load(x, as.logical(local), as.logical(now)) : impossible de charger la bibliothèque partagée 'C:/R/library/RMySQL/libs/RMySQL.dll': LoadLibrary failure: L'accès à cet emplacement de la mémoire n'est pas valide. Erreur : le chargement du package / espace de noms a échoué pour 'RMySQL' -- View this message in context: http://www.nabble.com/I-can%27t-do-it-again-on-an-other-PC-%3A-R%2BRMySQL--%3Eerror-loading-dll-tf4414597.html#a12592576 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] corrected resampled t-test
Hi, I'm looking for an implementation of the corrected resampled t-test [1] to compare to different machine learning classifiers. Any idea, whether this is implemented in a R package? Thanks in advance, Christian [1] Nadeau Bengio, 2003, Inference for the Generalization Error, Machine Learning __ 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] plot legend: combining filled boxes and lines
This is not quite what you want but you can try this: legend(3, 0.45, legend = c(x1, x2, mean(x1), mean(x2)), col = c(orange, green),pch = c(15,15,-1,-1), lty=c(-1,-1,2,2)) Although pch=22 should draw a filled square with a border - but it draws only the border instead Monica __ Message: 24Date: Mon, 10 Sep 2007 09:05:27 +0300From: Lauri Nikkinen [EMAIL PROTECTED]Subject: [R] plot legend: combining filled boxes and linesTo: [EMAIL PROTECTED]:[EMAIL PROTECTED]Content-Type: text/plain; charset=ISO-8859-1 Hello, I have difficulties combining boxes and lines in plot legend. Isearched previous R-posts and found this (with no solution):http://tolstoy.newcastle.edu.au/R/help/06/07/30248.html. Is there away to avoid boxes behind the line legends? x1 - rnorm(100)x2 - rnorm(100, 2)hist(x1, main = , col = orange,ylab = density, xlab = x, freq= F, density = 55, xlim = c(-2, 5), ylim = c(0, 0.5))par(new = T)hist(x2, main = , col = green, ylab = , xlab = ,axes = F, xlim= c(-2, 5), ylim = c(0, 0.5), density = 45, freq = F) abline(v = mean(x1), col = orange, lty = 2, lwd = 2.5)abline(v = mean(x2), col = green, lty = 2, lwd = 2.5)legend(3, 0.45, legend = c(x1, x2, mean(x1), mean(x2)), col =c(orange, green), fill=c(orange,green, 0, 0), lty = c(0, 0,2, 2), merge = T) ThanksLauri _ Gear up for Halo® 3 with free downloads and an exclusive offer. Its our way of saying thanks for using Windows Live. [[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] \uxxxx in libraries
I'm trying to build an extension that uses the \u characters, but building the library fails. The Writing R Extensions guide says that these characters should not be used, but I really can't find any way around them. Is there any way to configure the building of a library so that it will allow them to be used? I'm currently building and installing using the following code. R CMD build newpkg R CMD INSTALL GUIdemo_1.0.tar.gz If there is absolutely no way to include the escape characters then I may have to go a different way, but using \u seems to be the only way to include greek symbols in tcltk menus, so I would prefer to keep using them. Thanks, 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.
[R] mode or parameters of readBin
Hi, sapply(formals(readBin), mode) con what n sizesignedendian namename numeric logical logicalcall returns for the mode of size logical. But in the documentation is said that size should be integer. Does anyone know why the mode is logical? Thanks in advance Sigbert Klinke __ 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] overlay lattice histograms with goodness-of-fit pdfs
The following is one of the examples in the help page for histogram: histogram( ~ height | voice.part, data = singer, xlab = Height (inches), type = density, panel = function(x, ...) { panel.histogram(x, ...) panel.mathdensity(dmath = dnorm, col = black, args = list(mean=mean(x),sd=sd(x))) } ) This should give you some thing to start from. Also using the subset argument of the lattice functions will make make your code more readable. Instead of your code histogram(~ data | month * station, data = sta.stack[sta.stack[,type]==precip (sta.stack[,month]==Dec | sta.stack[,month]==Jan | sta.stack[,month]==Feb),], xlab = Precipitation (mm)) you can use (not tested because you didn't supply a reproducable example) histogram(~ data | month * station, data = sta.stack subset = type==precip month %in% c(Dec, Jan, Feb), xlab = Precipitation (mm)) Med venlig hilsen Frede Aakmann Tøgersen -Oprindelig meddelelse- Fra: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] På vegne af Brad Christoffersen Sendt: 10. september 2007 12:08 Til: R-help@stat.math.ethz.ch Emne: [R] overlay lattice histograms with goodness-of-fit pdfs Hello, I am new to R exploratory data analysis and plotting. Is anyone aware of a way to overlay a set of conditional histograms with conditional PDFs? Below, I generate a lattice plot of precipitation histograms based on different months and stations, given a subset of the dataset: histogram(~ data | month * station, data = sta.stack[sta.stack[,type]==precip (sta.stack[,month]==Dec | sta.stack[,month]==Jan | sta.stack[,month]==Feb),], xlab = Precipitation (mm)) I previously used a combination of the low-level 'lines()' and 'dgamma()' functions to overlay a gamma PDF onto a single histogram. Now what I would like to do is to do the same thing, but with a function that allows me to specify a formula similar to that in the histogram function above [SomeKindOfPDF] ~ [x-range] | month * station which will plot the PDF with the appropriate factors (month and station). All I'm looking for is for someone to get me going in the right direction with a useful package or function to use. Any help is much appreciated! Brad Christoffersen __ 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] mode or parameters of readBin
On 9/10/2007 10:26 AM, Sigbert Klinke wrote: Hi, sapply(formals(readBin), mode) con what n sizesignedendian namename numeric logical logicalcall returns for the mode of size logical. But in the documentation is said that size should be integer. Does anyone know why the mode is logical? The default value is NA, and the mode of NA is logical. (It will automatically be promoted into another type if included in a vector, e.g. c(1:2, NA) promotes it to integer, c(3.14, NA) promotes it to numeric.) More generally, I'd say reading the man page or the source is a better way to find out about the requirements for the arguments of a function. 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] Problems with strsplit
You could directly use strsplit(bA531F16-rep,\\-)[[1]][1] and strsplit(bA531F16-rep,\\-)[[1]][2] Regards Carlos Morales-2 wrote: Hello, I would like to know what can I do if I use strplit with a string and I want to use the middle left,I mean I have this: strsplit(bA531F16-rep,\\-) [[1]] [1] bA531F16 rep I would like to work just with bA531F16 in another variable, what could I do?, Thank you - Sé un Mejor Amante del Cine ¿Quieres saber cómo? ¡Deja que otras personas te ayuden!. [[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. -- View this message in context: http://www.nabble.com/Problems-with-strsplit-tf4412525.html#a12594380 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] ggplot legend consolidation
I have recently been introduced to the ggplot package by Hadley Wickham and must say I am quite impressed so far at how easy it is to make attractive plots, but one thing I am struggling over is how to consolidate legends. It's not currently possible to consolidate them (although in the distant future that would be something nice to have), but you can turn them off: hide_colour - scale_colour_continuous() hide_colour$legend - FALSE p - ggplot(data = mtcars) + geom_point(mapping = aes(x = hp, y = mpg, colour = cyl)) + hide_colour You'll also need to twiddle your viewports a little so that you still have space for the viewport, since space will not be allocated automatically anymore. The next thing is to extract the grob for the legend itself - this is a little tricker, because there's currently no way to get at the scales after they have been trained with the data. Load get_legends from http://pastie.textmate.org/95755, and then you can do: grid.newpage(); grid.draw(get_legends(p)) If you're not familiar enough with grid to stitch all of these pieces together, please let me know, but this should be enough to get you started. Hadley __ 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] RWinEdt installation problems with Vista
Hi, I was trying to install the packageRWinEdt in my computer with Vista OS. Once I finished the installation, R just cannot load this library at all, reporting some error information. I reinstalled R and Winedit and reloaded this package. RWinEdt seemed to register in the computer but never work again. I searched some related information on internet. I did try using administer privilege to install R and Winedit. Ans I also opened it by run as administrator. The problem still insisted. R always report following results. Error in getRegistryKeyValues(createRegistryPath(path, top, isValue = FALSE)) : Error in get keys: The parameter is incorrect. Error : .onAttach failed in 'attachNamespace' Error: package/namespace load failed for 'RWinEdt' If anyone can help me out on this issue? Thank you in advance. Kevin [[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] machine learning on ordered (ranked) feature
Hi, there: just a little bit off-topic: any algorithm in classification is good for ordered features, like all variables used are 1, 2, 3,...; not really continuous but ordered. i tried random forest and dlda already. thanks. -- 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] RWinEdt installation problems with Vista
Hi, I was trying to install the packageRWinEdt in my computer with Vista OS. O Use Tinn-R it works with Vista although has some minor issues (which are probably system specific). https://sourceforge.net/projects/tinn-r Stefan -=-=- ... Time is an illusion, lunchtime doubly so. (Ford Prefect) __ 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] Are the error messages of ConstrOptim() consisten with each other?
Yuchen Luo wrote: Dear Friends. I found something very puzzling with constOptim(). When I change the parameters for ConstrOptim, the error messages do not seem to be consistent with each other: constrOptim(c(0.5,0.3,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci) Error in constrOptim(c(0.5, 0.3, 0.5), f = fit.error, gr = fit.error.grr, : initial value not feasible Not feasible means it doesn't satisfy the constraints. constrOptim(c(0.5,0.9,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci) Error in constrOptim(c(0.5, 0.9, 0.5), f = fit.error, gr = fit.error.grr, : initial value not feasible constrOptim(c(0.3,0.5,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci) Error in f(theta, ...) : argument lambda1 is missing, with no default This time your starting values satisfied the constraints, so your objective function was called, but you didn't pass it a value for lambda1. I only changed the parameters, how come the lambda1 that is not missing in the first 2 cases suddently become missing? For your convenience, I put the complete code below: Best Wishes Yuchen Luo rm(list = ls()) mat=5 rint=c(4.33,4.22,4.27,4.43,4.43,4.44,4.45,4.65,4.77,4.77) tot=rep(13319.17,10) sh=rep(1553656,10) sigmae=c(0.172239074,0.188209271,0.193703774,0.172659891,0.164427247,0.24602361,0.173555309,0.186701165,0.193150456, 0.1857315601) ss=c(56.49,56.39,56.55,57.49,57.37,55.02,56.02,54.35,54.09, 54.67) orange=rep(21.25,10) apple2=expression(rint*(1.0-rec)*(1.0-(pnorm(-lambda/2.0+log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/lambda)-((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))*pnorm(-lambda/2.0-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/lambda))+(exp(rint*(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)*ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0+0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))-sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0*(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/s! h*! 1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(-sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0+0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0*(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))-(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0+0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt((lambda*l! am! bda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh* 1000.0))-sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0*(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt((lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(-sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0+0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt((lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0*(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt((lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))/((pnorm(-lambda/2.0+log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/lambda)-((ss+(tot/sh*1! 00!
Re: [R] Survey package
On Thu, 6 Sep 2007, eugen pircalabelu wrote: Good afternoon! I'm trying to use the Survey package for a stratified sample which has 4 criteria on which the stratification is based. I would like to get the corrected weights and for every element i get a weight of 1 E.g: tipping design - svydesign (id=~1, strata= ~regiune + size_loc + age_rec_hhh + size_hh, data= tabel) and then weights(design) gives me: 1,1,1,1,1,1,1,1,1,1,1,... for each element There are two problems. The first is that you have the wrong syntax for strata. If you have one stage of sampling with multiple stratifying factors you need to create a single factor representing the strata. One way is with interaction() design - svydesign (id=~1, strata= ~interaction(regiune, size_loc, age_rec_hhh, size_hh), data= tabel) Second, you have not specified either weights or population sizes, so R has no way to work out the sampling weights. That's why you get weights of 1. You should also get a warning. -thomas __ 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] the survey package
On Thu, 6 Sep 2007, Tobias Verbeke wrote: eugen pircalabelu wrote: I'm trying to use the survey package to get a better point of view for my data, but i need some piece of advice: i have some data from a survey which has been stratified using 2 criteria: region(7 values), size of locality(5 values) Using the survey pakage how can i define in a correct way this design (taking into account all 4 strata not just one as in the Survey example) snip According to ?svydesign, strata is a formula. The following should work (untested): design - svydesign(ids=~0, strata=~regiune + size_loc, data=tabel) This would be a two-stage sample, you actually need ~interaction(regiune, size_loc). [this reply is just to make sure it ends up linked in the archives]. -thomas __ 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] writing complex outputs to table
Steve, This example works: x-TukeyHSD(fm1, tension, ordered = TRUE) as.table(x$tension) Steve Powers wrote: So I've come across a few cases where complex outputs from functions will not write to tables. The most recent case involves the TukeyHSD function in the stats package. If I save the TukeyHSD call and print it, that obviously goes fine, but when I try writing to a table, I get an error message that says cannot coerce class \multicomp\ into dataframe. What does this mean, and how do I work around it? Is there a more fail-safe general method of writing complex outputs to a table? The story here is I want to be able to call certain values from the TukeyHSD results to produce custom summaries. Using R version 2.4 on Windows XP.---steve __ 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/writing-complex-outputs-to-table-tf4407732.html#a12596104 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] Are the error messages of ConstrOptim() consisten with each other?
The error message about the feasible region comes from constrOptim(), before your function is called. The error message about missing lambda1 comes from calling your function. -thomas On Sun, 9 Sep 2007, Yuchen Luo wrote: Dear Friends. I found something very puzzling with constOptim(). When I change the parameters for ConstrOptim, the error messages do not seem to be consistent with each other: constrOptim(c(0.5,0.3,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci) Error in constrOptim(c(0.5, 0.3, 0.5), f = fit.error, gr = fit.error.grr, : initial value not feasible constrOptim(c(0.5,0.9,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci) Error in constrOptim(c(0.5, 0.9, 0.5), f = fit.error, gr = fit.error.grr, : initial value not feasible constrOptim(c(0.3,0.5,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci) Error in f(theta, ...) : argument lambda1 is missing, with no default I only changed the parameters, how come the lambda1 that is not missing in the first 2 cases suddently become missing? For your convenience, I put the complete code below: Best Wishes Yuchen Luo rm(list = ls()) mat=5 rint=c(4.33,4.22,4.27,4.43,4.43,4.44,4.45,4.65,4.77,4.77) tot=rep(13319.17,10) sh=rep(1553656,10) sigmae=c(0.172239074,0.188209271,0.193703774,0.172659891,0.164427247,0.24602361,0.173555309,0.186701165,0.193150456, 0.1857315601) ss=c(56.49,56.39,56.55,57.49,57.37,55.02,56.02,54.35,54.09, 54.67) orange=rep(21.25,10) apple2=expression(rint*(1.0-rec)*(1.0-(pnorm(-lambda/2.0+log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/lambda)-((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))*pnorm(-lambda/2.0-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/lambda))+(exp(rint*(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)*ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0+0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))-sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0*(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/s! h*! 1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(-sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0+0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0*(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))-(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0+0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt((lambda*la! m! bda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh* 1000.0))-sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0*(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt((lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(-sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0+0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt((lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0*(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))*sqrt((lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))/((pnorm(-lambda/2.0+log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda)))/lambda)-((ss+(tot/sh*1! 00!
Re: [R] Survey package
On Sun, 9 Sep 2007, eugen pircalabelu wrote: A short example: stratum id weight nh Nh y sex 1 1 3 5 15 23 1 1 2 3 5 15 25 1 1 3 3 5 15 27 2 1 4 3 5 15 21 2 1 5 3 5 15 22 1 2 6 4 3 12 33 1 2 7 4 3 12 27 1 2 8 4 3 12 29 2 where nh is size of sample stratum and Nh the corresponding population value, and y is metric variable. Now if i let design - svydesign( id=~1, data=age, strata=~stratum, fpc=~Nh) then weights(design) gives me 3,3,3,3,3,4,4,4. If i then let x- postStratify( design, strata=~sex, data.frame(sex=c(1,2), freq=c(10,15))) the weights become 123456 78 2.17 2.17 5.35 5.352.171.731.73 4.28 If i define design - svydesign( id=~1, data=age ) x- postStratify( design, strata=~sex, data.frame(sex=c(1,2), freq=c(10,15))) weights become 2 2 5 5 2 2 2 5 The question: does poststratify recognize that i have already stratified in the first design by stratum and then it post stratifies by sex? and why is that? (because i don't have the full joint distribution, the sex*stratum crossing, in order to apply correctly the post stratify function) I see that Mr Lumley uses the postStratify function when the design does not include strata (eg from ?poststratify: This gives you a design stratified by stratum and post-stratified by sex, which is not the same as stratifying by stratum*sex or post-stratifying by stratum*sex. In this case you should probably rake() on stratum and sex rather than just post-stratifying. Post-stratifying on sex is equivalent to one iteration of the iterative proportional fitting algorithm used in raking. -thomas __ 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] write.csv / string extraction and field limits
This example works fine: test-matrix(c(1,2,'VOICIUNPETITTES',3),ncol=2,nrow=2) write.csv(test,file='C:/xavier/test.csv') Could you provide the same small example when it doesn't work? kwaj wrote: Hello, I have a peculiar problem which I am hoping I can get help on. I am using the write.csv command to write a matrix structure to a file, which I later read in excel. The command works quite well for most strings and numerical values in the matrix structure. However, I have found that when a field in the matrix contains a string of long length, when the matrix is finally written the file - the field shows up as NA. I am assuming write.csv has a limit on the field size? Maybe 16 characters? Assuming the above is correct - I tried to extract a portion of the string using the 'substring' command and enter the extracted portion into the field before using the write.csv command. However I find, that when a string is extracted, the output from write.csv generates a NA in the file output. My questions are: 1) Does write.csv have a limit on the size of strings in the matrix fields? Is there anyway to place large strings in the field? 2) Is there anyway to make the substring command or an alternative but similar command, compatible with write.csv? I have tried 'as.character(substring(phrase, min, max)' and that does not seem to work cheers -- View this message in context: http://www.nabble.com/write.csv---string-extraction-and-field-limits-tf4395535.html#a12596551 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] mode or parameters of readBin
On Mon, 10 Sep 2007, Sigbert Klinke wrote: Hi, sapply(formals(readBin), mode) con what n sizesignedendian namename numeric logical logicalcall returns for the mode of size logical. But in the documentation is said that size should be integer. Does anyone know why the mode is logical? Because NA is a logical constant. -thomas __ 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: better OS for statistical computing
Good morning, everyone, I am sorry for this off-topic post but think I can get great answer from this list. My question is what is the best OS on PC (laptop) for statistical computing and why. I really appreciate your insight. Have a nice day. __ 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 legend consolidation
Hi Hadley, I just tried out your suggestion, but it does not look like the get_legends function is working correctly. Instead of returning a grob back to me it returns NULL. Here is my modified code and the results of running it. Any help would be appreciated. I believe that once I can get the legend in grob form then I can figure out how to deconstruct it myself. Thanks, Kaom p.legend - get_legends(p) grid.draw(p.legend) Error in grid.draw(p.legend) : no applicable method for grid.draw p.legend NULL BEGIN CODE ## Obtained from http://pastie.textmate.org/95755 get_legends - function(plot) { if (length(plot$layers) == 0) stop(No layers to plot, call.=FALSE) # Apply function to layer and matching data dlapply - function(f) mapply(f, data, layers, SIMPLIFY=FALSE) plot - plot_clone(plot) layers - plot$layers scales - plot$scales facet - plot$facet cs - plot$coordinates # Evaluate aesthetics data - lapply(layers, function(x) x$make_aesthetics(plot)) # Facet data - mapply(function(d, p) facet$stamp_data(d), data, layers, SIMPLIFY=FALSE) # Transform scales where possible. Also need to train so statisics # (e.g. stat_smooth) have access to info data - dlapply(function(d, p) p$scales_transform(d, scales)) dlapply(function(d, p) p$scales_train(d, scales)) # Apply statistics data - dlapply(function(d, p) p$calc_statistics(d, scales)) data - dlapply(function(d, p) p$map_statistics(d, plot)) # Adjust position before scaling data - dlapply(function(d, p) p$adjust_position(d, scales, before)) # Transform, train and map scales # data - dlapply(function(d, p) p$scales_transform(d, scales)) dlapply(function(d, p) p$scales_train(d, scales, adjust=TRUE)) data - dlapply(function(d, p) p$scales_map(d, scales)) # Adjust position after scaling data - dlapply(function(d, p) p$adjust_position(d, scales, after)) scales - scales$minus(plot$scales$get_scales(c(x, y, z))) legends(scales, FALSE) } library(ggplot2) data(mtcars) grid.newpage() hide_colour - scale_colour_continuous() hide_colour$legend - FALSE pushViewport(viewport(layout = grid.layout(2, 2))) p - ggplot(data = mtcars) + geom_point(mapping = aes(x = hp, y = mpg, colour = cyl)) + hide_colour pushViewport(viewport(layout.pos.col = 1, layout.pos.row = 1)) print(p, vp = current.viewport()) upViewport() p - ggplot(data = mtcars) + geom_point(mapping = aes(x = drat, y = disp, colour = cyl)) + hide_colour pushViewport(viewport(layout.pos.col = 2, layout.pos.row = 1)) print(p, vp = current.viewport()) upViewport() p - ggplot(data = mtcars) + geom_point(mapping = aes(x = qsec, y = mpg, colour = cyl)) + hide_colour pushViewport(viewport(layout.pos.col = 1, layout.pos.row = 2)) print(p, vp = current.viewport()) upViewport() pushViewport(viewport(layout.pos.col = 2, layout.pos.row = 2)) grid.rect() p.legend - get_legends(p) grid.draw(p.legend) --END CODE -Original Message- From: hadley wickham [mailto:[EMAIL PROTECTED] Sent: Monday, September 10, 2007 7:58 AM To: Te, Kaom Cc: r-help@stat.math.ethz.ch Subject: Re: [R] ggplot legend consolidation I have recently been introduced to the ggplot package by Hadley Wickham and must say I am quite impressed so far at how easy it is to make attractive plots, but one thing I am struggling over is how to consolidate legends. It's not currently possible to consolidate them (although in the distant future that would be something nice to have), but you can turn them off: hide_colour - scale_colour_continuous() hide_colour$legend - FALSE p - ggplot(data = mtcars) + geom_point(mapping = aes(x = hp, y = mpg, colour = cyl)) + hide_colour You'll also need to twiddle your viewports a little so that you still have space for the viewport, since space will not be allocated automatically anymore. The next thing is to extract the grob for the legend itself - this is a little tricker, because there's currently no way to get at the scales after they have been trained with the data. Load get_legends from http://pastie.textmate.org/95755, and then you can do: grid.newpage(); grid.draw(get_legends(p)) If you're not familiar enough with grid to stitch all of these pieces together, please let me know, but this should be enough to get you started. Hadley __ 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 and loop output [Cox model, for, function, loglik]
Dear R users, Below I have written 4 functions CIT1, CIT2a and CIT2b and CIT3 which recode a variable CLD_ISCH into 3 new variables(T1 T2 T3), I wish to use T1, T2 and T3 based on the values of tf1 and tf2. (NOTE:- T2a is used to create T2 in a long winded manner due to my lack of programming experience) I then attach T1 T2 and T3 to a dataset KidneyT that contains other variables i wish to use in a Cox regression model. I require the log likelihood statistic of a Cox model when variables T1 T2 T3 and some from KidneyT are fitted. ( coxmodel$loglik[2] ) ## I can get this to work fine for specified values of tf1 and tf2, but wish to get the loglikelihood value for many combinations of tf1 and tf2 which are times from 1 to 50 hours i.e I need loglik statistic when tf1 =1 and tf2 = 1 to 50, tf1=2 and tf2=1 to 50. I'd like to do this in increments of 0.5 hours. Ideally I'd like to end up with a matrix/array like tf1 tf2 loglik 1 0.5 -1200 1 1 -1250 1 1.5 -1251 2 0.5 -1252 2 1 -1249 2 1.5 -1159 etc. In the hope of finding a maximum for loglik. ## I've looked into loops and apply and many other functions but can't seem to get what i want. Any suggestions would be fantastic - else I'll be doing hundreds of calculations 1 at a time - ah! Code is below: - sorry for not including an example dataset. Am hoping the code itself. If not pls say and i'll try and repost with a small example dataset. # tf1=11 tf2=18 CIT1=function(var1,bp1){ { ifelse (var1=bp1,(var1=var1),(bp1)) } } T1=CIT1(CLD_ISCH,tf1) #--- ---# CIT2a=function(var1,var2,bp1){ { ifelse (var1=bp1,(var1=0),(var1=var2-bp1)) } } T2a=CIT2a(CLD_ISCH,CLD_ISCH,tf1) #--- ---# CIT2b=function(var1,var2,bp1,bp2){ { ifelse (var1(bp2-bp1),(var1=bp2-bp1),(var1=T2a)) } } T2=CIT2b(T2a,T2a,tf1,tf2) #--- ---# CIT3=function(var1,var2,bp2){ { ifelse (var1=bp2,(var1=0),(var1=var2-bp2)) } } T3=CIT3(CLD_ISCH,CLD_ISCH,tf2) #--- ---# #--- ---# newdata=data.frame(T1,T2,T3,kidneyT) attach(newdata) coxmodel=coxph(Surv(TSURV,STATUS)~RAGE+DAGE+REG_WTIME_M+POLY_VS+T1+T2+T3 , method=breslow, data=newdata) coxmodel$loglik[2] ## Regards and Thx DaveL Buying or selling a home? Click here for free info on real estate services. http://tagline.bidsystem.com/fc/Ioyw36XILaXQaXpqHLyCgxKj2HWmH06KAobcQpI xUGTio1SLafTDjw/ span id=m2wTlpfont face=Arial, Helvetica, sans-serif size=2 style=font-size:13.5px___BRGet the Free email that has everyone talking at a href=http://www.mail2world.com target=newhttp://www.mail2world.com/abr font color=#99Unlimited Email Storage #150; POP3 #150; Calendar #150; SMS #150; Translator #150; Much More!/font/font/span [[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] overlay lattice histograms with goodness-of-fit pdfs
Hello, I am new to R exploratory data analysis and plotting. Is anyone aware of a way to overlay a set of conditional histograms with conditional PDFs? Below, I generate a lattice plot of precipitation histograms based on different months and stations, given a subset of the dataset: histogram(~ data | month * station, data = sta.stack[sta.stack[,type]==precip (sta.stack[,month]==Dec | sta.stack[,month]==Jan | sta.stack[,month]==Feb),], xlab = Precipitation (mm)) I previously used a combination of the low-level 'lines()' and 'dgamma()' functions to overlay a gamma PDF onto a single histogram. Now what I would like to do is to do the same thing, but with a function that allows me to specify a formula similar to that in the histogram function above [SomeKindOfPDF] ~ [x-range] | month * station which will plot the PDF with the appropriate factors (month and station). All I'm looking for is for someone to get me going in the right direction with a useful package or function to use. Any help is much appreciated! Brad Christoffersen __ 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] off-topic: better OS for statistical computing
You want whatever all the people you are working with are using to make it as easy as possible to work together with them. On 9/10/07, Wensui Liu [EMAIL PROTECTED] wrote: Good morning, everyone, I am sorry for this off-topic post but think I can get great answer from this list. My question is what is the best OS on PC (laptop) for statistical computing and why. I really appreciate your insight. Have a nice day. __ 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] S-Plus resample package and associated functions
Are there any packages in R that reproduce the package resample of S-Plus? The sample() function in R doesn't provide equivalent flexibility of bootstrap() and bootstrap2(). Robert A. LaBudde, PhD, PAS, Dpl. ACAFS e-mail: [EMAIL PROTECTED] Least Cost Formulations, Ltd.URL: http://lcfltd.com/ 824 Timberlake Drive Tel: 757-467-0954 Virginia Beach, VA 23464-3239Fax: 757-467-2947 Vere scire est per causas scire __ 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 clustering analysis possible with R ?
I have 316 files storing a number of cycles of the respiratory signal from 316 different patients. Each file record is made up of the following data: amplitude,phase,timestamp,validflag,ttlin,mark,ttlout amplitude: is the position in cm relative to an arbitrary reference (signal amplitude) phase: is the phase value for the current sample (the time point at which the breathing signal was recorded) timestamp: time of the sample measurement in milliseconds validflag: value of 0 indicates a valid track and a periodic signal, and a value less than 0 indicates either a lost track, a bad video signal, or a non periodic signal ttlin: is the bit value indicating the status of a sensed TTL signal. Possible values include 1 (+5 VDC) and 0 (0 VDC). mark: specifies the sample when the phase value is closest to 0 or PI (180 degrees) . Possible values include Z (0 phase), P (PI phase), (null string), and - (neither 0 nor PI phase) ttl_out: is the bit value indicating the status of an output TTL signal. Possible values include 1 (+5 VDC) and 0 (0 VDC) The goal is to perform clustering analysis on such data, that is to group togther those which have common characteristics. Which characteristics and how many groups ... ??? ... well this is to be found out. Is R a good tool for analysing many data and find patterns common to data subsets ? Which other tool do you advice ? Thank you very much, -- Maura E.M __ 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 minimum positive value of some data
useRs, I am looking to find the minimum positive value of some data I have. Currently, I am able to find the minimum of data after I apply some other functions to it: x [1] 1 0 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10 sort(x) [1] 0 1 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10 diff(sort(x)) [1] 1 0 1 1 0 1 1 0 0 1 1 1 0 1 0 1 0 min(diff(sort(x))) [1] 0 The minimum is given as zero, which is clearly true, but I am interested in only the positive minimum, which is 1. Can I find this by using only 1 line of code, like I have above? Thanks! dxc13 -- View this message in context: http://www.nabble.com/finding-the-minimum-positive-value-of-some-data-tf4417250.html#a12599319 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] finding the minimum positive value of some data
Try this: min(diff(sort(x))[diff(sort(x))0]) -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O On 10/09/2007, dxc13 [EMAIL PROTECTED] wrote: useRs, I am looking to find the minimum positive value of some data I have. Currently, I am able to find the minimum of data after I apply some other functions to it: x [1] 1 0 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10 sort(x) [1] 0 1 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10 diff(sort(x)) [1] 1 0 1 1 0 1 1 0 0 1 1 1 0 1 0 1 0 min(diff(sort(x))) [1] 0 The minimum is given as zero, which is clearly true, but I am interested in only the positive minimum, which is 1. Can I find this by using only 1 line of code, like I have above? Thanks! dxc13 -- View this message in context: http://www.nabble.com/finding-the-minimum-positive-value-of-some-data-tf4417250.html#a12599319 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. [[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 minimum positive value of some data
On Mon, 2007-09-10 at 11:20 -0700, dxc13 wrote: useRs, I am looking to find the minimum positive value of some data I have. Currently, I am able to find the minimum of data after I apply some other functions to it: x [1] 1 0 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10 sort(x) [1] 0 1 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10 diff(sort(x)) [1] 1 0 1 1 0 1 1 0 0 1 1 1 0 1 0 1 0 min(diff(sort(x))) [1] 0 The minimum is given as zero, which is clearly true, but I am interested in only the positive minimum, which is 1. Can I find this by using only 1 line of code, like I have above? Thanks! dxc13 It's not clear to me which vector you wish to get the minimum for, but the basic premise would be along the lines of: x [1] 1 0 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10 min(x[which(x 0)]) [1] 1 or min(which(diff(sort(x)) 0)) [1] 1 See ?which HTH, Marc Schwartz __ 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] Too many warnings when updating R
Hello friends, I loaded R 2.4.1 onto a Fedora Core 6 Linux box (taking all defaults). Then I ran these commands from within R: options(CRAN=http://cran.stat.ucla.edu;) install.packages(CRAN.packages()[,1]) As a new user of R, I was shocked when I finished loading R and discovered the following message: There were 50 or more warnings (use warnings() to see the first 50) In addition to this, I saw errors such as this one: ERROR: lazy loading failed for package 'PerformanceAnalytics' What is this lazy loading? More importantly, do I have to worry about all these warnings? I am intimidated by the idea that I have to go back and fix each and every one in order to have a clean R update. Shouldn't the update with CRAN just work? Or is there something really important that I am missing? Thanks all for your help. A Lenzo [[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] ggplot legend consolidation
Sorry, I should have mentioned that get_legend won't work on the plots that you are actually plotting - you have turned their legends off! You'll need a plot which isn't plotted, but is used to produce the legends. Hadley On 9/10/07, Te, Kaom [EMAIL PROTECTED] wrote: Hi Hadley, I just tried out your suggestion, but it does not look like the get_legends function is working correctly. Instead of returning a grob back to me it returns NULL. Here is my modified code and the results of running it. Any help would be appreciated. I believe that once I can get the legend in grob form then I can figure out how to deconstruct it myself. Thanks, Kaom p.legend - get_legends(p) grid.draw(p.legend) Error in grid.draw(p.legend) : no applicable method for grid.draw p.legend NULL BEGIN CODE ## Obtained from http://pastie.textmate.org/95755 get_legends - function(plot) { if (length(plot$layers) == 0) stop(No layers to plot, call.=FALSE) # Apply function to layer and matching data dlapply - function(f) mapply(f, data, layers, SIMPLIFY=FALSE) plot - plot_clone(plot) layers - plot$layers scales - plot$scales facet - plot$facet cs - plot$coordinates # Evaluate aesthetics data - lapply(layers, function(x) x$make_aesthetics(plot)) # Facet data - mapply(function(d, p) facet$stamp_data(d), data, layers, SIMPLIFY=FALSE) # Transform scales where possible. Also need to train so statisics # (e.g. stat_smooth) have access to info data - dlapply(function(d, p) p$scales_transform(d, scales)) dlapply(function(d, p) p$scales_train(d, scales)) # Apply statistics data - dlapply(function(d, p) p$calc_statistics(d, scales)) data - dlapply(function(d, p) p$map_statistics(d, plot)) # Adjust position before scaling data - dlapply(function(d, p) p$adjust_position(d, scales, before)) # Transform, train and map scales # data - dlapply(function(d, p) p$scales_transform(d, scales)) dlapply(function(d, p) p$scales_train(d, scales, adjust=TRUE)) data - dlapply(function(d, p) p$scales_map(d, scales)) # Adjust position after scaling data - dlapply(function(d, p) p$adjust_position(d, scales, after)) scales - scales$minus(plot$scales$get_scales(c(x, y, z))) legends(scales, FALSE) } library(ggplot2) data(mtcars) grid.newpage() hide_colour - scale_colour_continuous() hide_colour$legend - FALSE pushViewport(viewport(layout = grid.layout(2, 2))) p - ggplot(data = mtcars) + geom_point(mapping = aes(x = hp, y = mpg, colour = cyl)) + hide_colour pushViewport(viewport(layout.pos.col = 1, layout.pos.row = 1)) print(p, vp = current.viewport()) upViewport() p - ggplot(data = mtcars) + geom_point(mapping = aes(x = drat, y = disp, colour = cyl)) + hide_colour pushViewport(viewport(layout.pos.col = 2, layout.pos.row = 1)) print(p, vp = current.viewport()) upViewport() p - ggplot(data = mtcars) + geom_point(mapping = aes(x = qsec, y = mpg, colour = cyl)) + hide_colour pushViewport(viewport(layout.pos.col = 1, layout.pos.row = 2)) print(p, vp = current.viewport()) upViewport() pushViewport(viewport(layout.pos.col = 2, layout.pos.row = 2)) grid.rect() p.legend - get_legends(p) grid.draw(p.legend) --END CODE -Original Message- From: hadley wickham [mailto:[EMAIL PROTECTED] Sent: Monday, September 10, 2007 7:58 AM To: Te, Kaom Cc: r-help@stat.math.ethz.ch Subject: Re: [R] ggplot legend consolidation I have recently been introduced to the ggplot package by Hadley Wickham and must say I am quite impressed so far at how easy it is to make attractive plots, but one thing I am struggling over is how to consolidate legends. It's not currently possible to consolidate them (although in the distant future that would be something nice to have), but you can turn them off: hide_colour - scale_colour_continuous() hide_colour$legend - FALSE p - ggplot(data = mtcars) + geom_point(mapping = aes(x = hp, y = mpg, colour = cyl)) + hide_colour You'll also need to twiddle your viewports a little so that you still have space for the viewport, since space will not be allocated automatically anymore. The next thing is to extract the grob for the legend itself - this is a little tricker, because there's currently no way to get at the scales after they have been trained with the data. Load get_legends from http://pastie.textmate.org/95755, and then you can do: grid.newpage(); grid.draw(get_legends(p)) If you're not familiar enough with grid to stitch all of these pieces together, please let me know, but this should be enough to get you started. Hadley -- http://had.co.nz/ __ R-help@stat.math.ethz.ch mailing list
Re: [R] S-Plus resample package and associated functions
http://www.burns-stat.com/pages/Tutor/bootstrap_resampling.html includes a synopsis of R packages that do bootstrapping. It is brief and incomplete, but hopefully useful. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) Robert A. LaBudde wrote: Are there any packages in R that reproduce the package resample of S-Plus? The sample() function in R doesn't provide equivalent flexibility of bootstrap() and bootstrap2(). Robert A. LaBudde, PhD, PAS, Dpl. ACAFS e-mail: [EMAIL PROTECTED] Least Cost Formulations, Ltd.URL: http://lcfltd.com/ 824 Timberlake Drive Tel: 757-467-0954 Virginia Beach, VA 23464-3239Fax: 757-467-2947 Vere scire est per causas scire __ 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] persp() problem
I am having some trouble getting the persp() package to change the x and y axis on a 3d plot. It defaults to the [0,1] interval and when I try to change it I get errors. Example: This works: D - c(1,2,3,4,5,6,7,8,9,10) M - c(11,12,13,14,15,16,17,18,19,20) DM - cbind(D,M) persp(DM, theta = 40, phi = 30, expand = 0.5, col = lightblue, ltheta = 120, shade = 0.75, ticktype = detailed, xlab = X, ylab = Y, zlab = Z) - But I want the axis to count 1 by ones. So I try: - D - c(1,2,3,4,5,6,7,8,9,10) M - c(11,12,13,14,15,16,17,18,19,20) DM - cbind(D,M) x - 1*0:10 y - 1*0:20 persp(x,y,DM, theta = 40, phi = 30, expand = 0.5, col = lightblue, ltheta = 120, shade = 0.75, ticktype = detailed, xlab = X, ylab = Y, zlab = Z) - I get: Error in persp(x, y, z, xlim, ylim, zlim, theta, phi, r, d, scale, expand, : invalid 'z' argument but the z was fine in the first version so I am not sure what the deal is. Any ideas? -Econ Guy __ 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] Too many warnings when updating R
A Lenzo wrote: Hello friends, I loaded R 2.4.1 onto a Fedora Core 6 Linux box (taking all defaults). Then I ran these commands from within R: options(CRAN=http://cran.stat.ucla.edu;) install.packages(CRAN.packages()[,1]) As a new user of R, I was shocked when I finished loading R and discovered the following message: There were 50 or more warnings (use warnings() to see the first 50) Let me get this straight: You install last year's R on last year's Fedora, then install over 1000 unspecified packages and you are shocked that you get warnings? In addition to this, I saw errors such as this one: ERROR: lazy loading failed for package 'PerformanceAnalytics' What is this lazy loading? More importantly, do I have to worry about all these warnings? I am intimidated by the idea that I have to go back and fix each and every one in order to have a clean R update. Shouldn't the update with CRAN just work? Or is there something really important that I am missing? Well, you need to know what you're doing. At the very least, notice what the warnings say and decide whether they point to real trouble or are just what they say they are: warnings. If you are worried about investigating all the packages, maybe install what you really need first. And no, you can't expect a repository like CRAN to keep track of all versions of R on all versions of all OS's. In each individual case, a human maintainer is responsible for fixing problems and he/she may or may not be around to fix issues. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@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] lattice panel.lmline problem
On 9/10/07, Ross Darnell [EMAIL PROTECTED] wrote: Thanks Frede I didn't know about the r type. For the record, this is probably what you wanted: xyplot(... panel = panel.superpose, panel.groups = function(x, y, ...) { panel.xyplot(x, y, ...) if (length(x) 0) panel.lmline(x, y, ...) }) x[subscripts] inside the panel function doesn't give anything meaningful ('x' is already subscripted). -Deepayan Ross Darnell -Original Message- From: Frede Aakmann Tøgersen [mailto:[EMAIL PROTECTED] Sent: Mon 10-Sep-07 4:45 PM To: Ross Darnell; r-help@stat.math.ethz.ch Subject: SV: [R] lattice panel.lmline problem Why not use the more simple xyplot(total.fat~x|variable,groups=Group, data=tmp1,type=c(p,r)) ??? See ?panel.xyplot and especially the type argument of that panel 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.
[R] MLE Function
I am just trying to teach myself how to use the mle function in R because it is much better than what is provided in MATLAB. I am following tutorial material from the internet, however, it gives the following errors, does anybody know what is happening to cause such errors, or does anybody know any better tutorial material on this particular subject. x.gam-rgamma(200,rate=0.5,shape=3.5) x-x.gam library(stats4) ll-function(lambda,alfa){n-200;x-x.gam -n*alfa*log(lambda)+n*log(gamma(alfa))-9alfa-1)*sum(log(x))+lambda*sum(x)} Error: syntax error, unexpected SYMBOL, expecting '\n' or ';' or '}' in ll-function(lambda,alfa){n-200;x-x.gam -n*alfa*log(lambda)+n*log(gamma(alfa))-9alfa ll-function(lambda,alfa){n-200;x-x.gam -n*alfa*log(lambda)+n*log(gamma(alfa))-(alfa-1)*sum(log(x))+lambda*sum(x)} est-mle(minuslog=ll,start=list(lambda=2,alfa=1)) Error in optim(start, f, method = method, hessian = TRUE, ...) : objective function in optim evaluates to length 200 not 1 audaces fortuna iuvat - [[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] off-topic: better OS for statistical computing
On 11/09/2007, at 4:22 AM, Wensui Liu wrote: Good morning, everyone, I am sorry for this off-topic post but think I can get great answer from this list. My question is what is the best OS on PC (laptop) for statistical computing and why. I really appreciate your insight. Have a nice day. Linux. It's best for ***everything***. cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confidenti...{{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] off-topic: better OS for statistical computing
Linux! Mac OS is ok to me2. On 9/10/07, Wensui Liu [EMAIL PROTECTED] wrote: Good morning, everyone, I am sorry for this off-topic post but think I can get great answer from this list. My question is what is the best OS on PC (laptop) for statistical computing and why. I really appreciate your insight. Have a nice day. __ 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] Are the error messages of ConstrOptim() consisten with each other?
Dear Professor Murdoch. Thank you for your help! 1. I believe c(0.5,0.3,0.5) satisfies the constrain because I did the following experiment ui=-1*ui ci=-1*ci constrOptim(c(0.5,0.3,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci) The same error message pops up. Any theta ( in this case, c(0.5,0.3,0.5)) cannot violate both ui%*%theta=ci and -ui%*%theta=-ci. 2. There is lambda1 available. The 0.3 in c(0.5,0.3,0.5) is lambda1. If you plug c(0.5,0.3,0.5) into fit.error and fit.error.grr by fit.error(0.5,0.3,0.5) fit.error.grr(0.5,0.3,0.5) It works. Best Wishes Yuchen Luo On 9/10/07, Duncan Murdoch [EMAIL PROTECTED] wrote: Yuchen Luo wrote: Dear Friends. I found something very puzzling with constOptim(). When I change the parameters for ConstrOptim, the error messages do not seem to be consistent with each other: constrOptim(c(0.5,0.3,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci) Error in constrOptim(c(0.5, 0.3, 0.5), f = fit.error, gr = fit.error.grr , : initial value not feasible Not feasible means it doesn't satisfy the constraints. constrOptim(c(0.5,0.9,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci) Error in constrOptim(c(0.5, 0.9, 0.5), f = fit.error, gr = fit.error.grr , : initial value not feasible constrOptim(c(0.3,0.5,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci) Error in f(theta, ...) : argument lambda1 is missing, with no default This time your starting values satisfied the constraints, so your objective function was called, but you didn't pass it a value for lambda1. I only changed the parameters, how come the lambda1 that is not missing in the first 2 cases suddently become missing? For your convenience, I put the complete code below: Best Wishes Yuchen Luo rm(list = ls()) mat=5 rint=c(4.33,4.22,4.27,4.43,4.43,4.44,4.45,4.65,4.77,4.77) tot=rep(13319.17,10) sh=rep(1553656,10) sigmae=c(0.172239074,0.188209271,0.193703774,0.172659891,0.164427247, 0.24602361,0.173555309,0.186701165,0.193150456, 0.1857315601) ss=c(56.49,56.39,56.55,57.49,57.37,55.02,56.02,54.35,54.09, 54.67) orange=rep(21.25,10) apple2=expression(rint*(1.0-rec)*(1.0- (pnorm(-lambda/2.0+log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0 )/lbar*exp(lambda*lambda)))/lambda)-((ss+(tot/sh*1000.0)*lbar)/(tot/sh* 1000.0)/lbar*exp(lambda*lambda))*pnorm(-lambda/2.0-log(((ss+(tot/sh*1000.0 )*lbar)/(tot/sh*1000.0 )/lbar*exp(lambda*lambda)))/lambda))+(exp(rint*(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh* 1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)*ss+(tot/sh*1000.0 )*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(sqrt(0.25+2.0*rint/ (sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0 +0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0 )/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0 )))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0 )))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))-sqrt(0.25+2.0*rint/ (sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0 *(sigmae*ss/(ss+lbar*(tot/sh*1000.0 )))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*! 1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+((ss+(tot/sh*1000.0 )*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(-sqrt(0.25+2.0*rint/ (sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0 +0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0 )/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0 )))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0 )))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+sqrt(0.25+2.0*rint/ (sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0 *(sigmae*ss/(ss+lbar*(tot/sh*1000.0 )))*sqrt(mat+(lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0 )))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))-(((ss+(tot/sh*1000.0 )*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(sqrt(0.25+2.0*rint/ (sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0 +0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0 )/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0 )))*sqrt((lambda*lam! bda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh* 1000.0))-sqrt(0.25+2.0*rint/(sigmae*ss/(ss+lbar*(tot/sh*1000.0 )))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0*(sigmae*ss/(ss+lbar*(tot/sh* 1000.0)))*sqrt((lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0 )))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+((ss+(tot/sh*1000.0 )*lbar)/(tot/sh*1000.0)/lbar*exp(lambda*lambda))^(-sqrt(0.25+2.0*rint/ (sigmae*ss/(ss+lbar*(tot/sh*1000.0)))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0 +0.5)*pnorm(-log(((ss+(tot/sh*1000.0)*lbar)/(tot/sh*1000.0 )/lbar*exp(lambda*lambda)))/((sigmae*ss/(ss+lbar*(tot/sh*1000.0 )))*sqrt((lambda*lambda/(sigmae*ss/(ss+lbar*(tot/sh*1000.0 )))/(sigmae*ss/(ss+lbar*(tot/sh*1000.0))+sqrt(0.25+2.0*rint/
Re: [R] MLE Function
Terence Broderick wrote: I am just trying to teach myself how to use the mle function in R because it is much better than what is provided in MATLAB. I am following tutorial material from the internet, however, it gives the following errors, does anybody know what is happening to cause such errors, or does anybody know any better tutorial material on this particular subject. x.gam-rgamma(200,rate=0.5,shape=3.5) x-x.gam library(stats4) ll-function(lambda,alfa){n-200;x-x.gam -n*alfa*log(lambda)+n*log(gamma(alfa))-9alfa-1)*sum(log(x))+lambda*sum(x)} Error: syntax error, unexpected SYMBOL, expecting '\n' or ';' or '}' in ll-function(lambda,alfa){n-200;x-x.gam -n*alfa*log(lambda)+n*log(gamma(alfa))-9alfa ll-function(lambda,alfa){n-200;x-x.gam -n*alfa*log(lambda)+n*log(gamma(alfa))-(alfa-1)*sum(log(x))+lambda*sum(x)} est-mle(minuslog=ll,start=list(lambda=2,alfa=1)) Error in optim(start, f, method = method, hessian = TRUE, ...) : objective function in optim evaluates to length 200 not 1 Er, not what I get. Did your version have that linefeed after x - x.gam ? If not, then you'll get your negative log-likelihood added to x.gam and the resulting likelihood becomes a vector of length 200 instead of a scalar. In general, the first piece of advice for mle() is to check that the likelihood function really is what it should be. Otherwise there is no telling what the result might mean... Secondly, watch out for parameter constraints. With your function, it very easily happens that alfa tries to go negative in which case the gamma function in the likelihood will do crazy things. A common trick in such cases is to reparametrize by log-parameters, i.e. ll - function(lambda,alfa){n-200; x-x.gam -n*alfa*log(lambda)+n*lgamma(alfa)-(alfa-1)*sum(log(x))+lambda*sum(x)} ll2 - function(llam, lalf) ll(exp(llam),exp(lalf)) est - mle(minuslog=ll2,start=list(llam=log(2),lalf=log(1))) par(mfrow=c(2,1)) plot(profile(est)) Notice, incidentally, the use of lgamma rather than log(gamma(.)), which is prone to overflow. In fact, you could also write this likelihood directly as -sum(dgamma(x, rate=lambda, shape=alfa, log=T)) audaces fortuna iuvat - [[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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@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] using bootstrap for tree selection step in rpart
Hi I was wondering if someone could help me with an rpart problem. I can see that cross-validation is the default for tree selection in rpart -- has a bootstrap method been implemented anywhere? I think this is a different thing to 'bagging' or 'boosting' -- I still want 'one' tree at the end, I just would like it chosen using a bootstrap method. Any ideas??? Thanks Fiona -- Fiona Callaghan, MA MS A432 Crabtree Hall Department of Biostatistics Graduate School of Public Health University of Pittsburgh Phone 412 624 3063 __ 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 'trackObjs' - mirror objects to files, provide summaries modification times
From ?trackObjs: Overview of trackObjs package Description: The trackObjs package sets up a link between R objects in memory and files on disk so that objects are automatically resaved to files when they are changed. R objects in files are read in on demand and do not consume memory prior to being referenced. The trackObjs package also tracks times when objects are created and modified, and caches some basic characteristics of objects to allow for fast summaries of objects. Each object is stored in a separate RData file using the standard format as used by 'save()', so that objects can be manually picked out of or added to the trackObjs database if needed. Tracking works by replacing a tracked variable by an 'activeBinding', which when accessed looks up information in an associated 'tracking environment' and reads or writes the corresponding RData file and/or gets or assigns the variable in the tracking environment. Details: There are three main reasons to use the 'trackObjs' package: * conveniently handle many moderately-large objects that would collectively exhaust memory or be inconvenient to manage in files by manually using 'save()' and 'load()' * keep track of creation and modification times on objects * get fast summaries of basic characteristics of objects - class, size, dimension, etc. There is an option to control whether tracked objects are cached in memory as well as being stored on disk. By default, objects are not cached. To save time when working with collections of objects that will all fit in memory, turn on caching with 'track.options(cache=TRUE)', or start tracking with 'track.start(..., cache=TRUE)'. Here is a brief example of tracking some variables in the global environment: library(trackObjs) track.start(tmp1) x - 123 # Not yet tracked track(x) # Variable 'x' is now tracked track(y - matrix(1:6, ncol=2)) # 'y' is assigned tracked z1 - list(a, b, c) z2 - Sys.time() track(list=c(z1, z2)) # Track a bunch of variables track.summary(size=F) # See a summary of tracked vars classmode extent lengthmodified TA TW x numeric numeric[1] 1 2007-09-07 08:50:58 0 1 y matrix numeric [3x2] 6 2007-09-07 08:50:58 0 1 z1 listlist [[3]] 3 2007-09-07 08:50:58 0 1 z2 POSIXt,POSIXct numeric[1] 1 2007-09-07 08:50:58 0 1 # (TA=total accesses, TW=total writes) ls(all=TRUE) [1] x y z1 z2 track.stop() # Stop tracking ls(all=TRUE) character(0) # Restart using the tracking dir -- the variables reappear track.start(tmp1) # Start using the tracking dir again ls(all=TRUE) [1] x y z1 z2 track.summary(size=F) classmode extent lengthmodified TA TW x numeric numeric[1] 1 2007-09-07 08:50:58 0 1 y matrix numeric [3x2] 6 2007-09-07 08:50:58 0 1 z1 listlist [[3]] 3 2007-09-07 08:50:58 0 1 z2 POSIXt,POSIXct numeric[1] 1 2007-09-07 08:50:58 0 1 track.stop() # the files in the tracking directory: list.files(tmp1, all=TRUE) [1] ... [3] filemap.txt .trackingSummary.rda [5] x.rday.rda [7] z1.rda z2.rda There are several points to note: * The global environment is the default environment for tracking - it is possible to track variables in other environments, but that environment must be supplied as an argument to the track functions. * Vars must be explicitly 'track()'ed - newly created objects are not tracked. (This is not a feature, but there is currently no way of automatically tracking newly created objects - this is on the wishlist.) Thus, it is possible for variables in a tracked environment to either tracked or untracked. * When tracking is stopped, all tracked variables are saved on disk and will be no longer accessible until tracking is started again. * The objects are stored each in their own file in the tracking dir, in the format used by 'save()'/'load()' (RData files). List of basic functions and common calling patterns: Six functions cover the majority of common usage of the trackObjs package: * 'track.start(dir=...)': start tracking the global environment, with files saved in 'dir' *
[R] Generating Replicate Datasets (using loops or other means)
Hello All, I have searched many help forums, message boards, etc. and I just can't apply the comments to what I need my program to do. I am running R 2.5.1 on an XP system, and my desire is to produce replicate datasets for a simulation study I am running. Essentially, I have sets of parameters (a's, b's, and c's) that define a function which produces a decimal value. This value is compared to a random uniform value, and is coded a 1 if the function is greater than the uniform value, 0 if it is = to the uniform value. My code thus far works great, but I just need it to run several times.Here we go: library(mvtnorm) library(sm) library(ltm) library(irtoys) k- 5000 set.seed(271828) t - rmvnorm(n=k,mean=c(-1,0,1),sigma=matrix(c(1,.8,.5,.8,1,.8,.5,.8,1),3,3)) #Using mv here because of the likely association of ability (theta = t) across time. t1-as.matrix(t[,1]) t2-as.matrix(t[,2]) t3-as.matrix(t[,3]) set.seed(271828) # Population item parameters (n=54) from which we will select relevant items # These are the parameters that are used in the function a - c(1.18120, 0.92613, 0.96886, 0.80503, 1.12384, 0.84073, 0.85544, 0.86801, 1.01054, 0.82278, 1.10353, 0.78865, 0.98421, 1.76071, 0.89603, 0.84671, 0.89737, 0.74775, 0.32190, 0.69730, 0.72059, 1.16762, 1.29257, 1.32902, 0.59540, 0.51022, 0.59259, 0.93951, 0.68568, 0.55649, 0.88084, 0.52940, 0.45735, 0.57560, 1.11779, 0.96984, 1.19692, 0.99102, 1.25847, 1.62555, 0.63049, 1.07807, 1.04897, 1.23138, 1.14014, 1.25230, 1.14844, 0.59287, 0.83143, 0.81723, 0.52141, 0.61980, 0.49945, 1.02749) b - c(-2.51737, -1.95897, -1.72667, -0.82988, -0.36093, 0.72554, 0.91442, 0.78061, 0.06088, 0.75733, -0.76371, 0.24552, -0.42050, 0.88232, -0.81761, 0.06466, -0.43866, -0.46042, 0.21636, -0.73147, -1.44086, -1.03718, 0.07275, -0.17197, 1.53796, -0.45631, -1.69826, -0.66506, 0.98921, 0.30714, -0.62245, 0.97253, 1.95894, 0.21277, 1.96346, 1.18825, 1.59917, -0.28401, -1.23530, -0.09671, -0.31581, -0.66149, -0.81284, -0.35399, -0.07623, 1.06442, -0.68559, 1.07591, 0.97458, 0.06436, 1.25622, 1.73954, 1.75052, 2.34088) c - c(0.0, 0.0, 0.0, 0.0, 0.19648, 0.31302, 0.26454, 0.19714, 0.06813, 0.21344, 0.0, 0.03371, 0.0, 0.16581, 0.11054, 0.08756, 0.07115, 0.26892, 0.0, 0.06883, 0.0, 0.14815, 0.32389, 0.19616, 0.17597, 0.0, 0.0, 0.04337, 0.19949, 0.20377, 0.0, 0.06243, 0.13639, 0.0, 0.18166, 0.15996, 0.20184, 0.08331, 0.24453, 0.26114, 0.16434, 0.20750, 0.32658, 0.31870, 0.45227, 0.35039, 0.31178, 0.17999, 0.22774, 0.21675, 0.10153, 0.17764, 0.15205, 0.19858) # Item parameters for generating 3PL data for all five testing occasions: # This selects the relevant parameters for a particular data generation run # Only parameters for the first testing occasion are shown to save space a1 - as.matrix(a[c(1:5,15:20,22:24,38:44)]) b1 - as.matrix(b[c(1:5,15:20,22:24,38:44)]) c1 - as.matrix(c[c(1:5,15:20,22:24,38:44)]) # Here is where I would like to begin my replications, but don't know how to make R do it. # The code below produces a matrix of 0's and 1's (which will be used by another program) # I would like to nest this in a do loop such that, say, 30 replicate datasets are produced using the #same parameters. N - nrow(t1) # number of examinees n - nrow(a1) # number of items d - 1.7 theta - t1 response - matrix (0,N,n) uni - matrix (runif(N*n),nrow = N) for (i in 1:N) { for (j in 1:n) { if ( c1[j]+(1-c1[j])/(1+exp(-d*a1[j]*(theta[i]-b1[j]))) uni[i,j] ) response[i,j] = 1 else response[i,j] = 0 } } write.table(response, file=C:/responses.dat, sep= ,row.names=FALSE, col.names=FALSE) I tried earlier nesting this in another for loop, but that indexes elements of matrices and vectors, and doesn't seem to apply to a global loop methodology. I am attempting to use replicate as we speak, but documentation is sparse (help(replicate) is nested in lapply information). Any guidance is greatly appreciated. Thanks in advance, Jonathan Beard -- View this message in context: http://www.nabble.com/Generating-Replicate-Datasets-%28using-loops-or-other-means%29-tf4418768.html#a12603580 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] clustering analysis is certainly possible with R.
See the article Cluster in R Task Views http://cran.at.r-project.org/src/contrib/Views/Cluster.html It lists names of packages for clustering analysis, which you can install. Or, go to choose another CRAN mirror closest to you from the R web site, then click on 'Task views' in the left frame. To install packages use the install.packages() function or the menu item in the GUI in you are on Windows. Maura E Monville wrote: I have 316 files storing a number of cycles of the respiratory signal from 316 different patients. Each file record is made up of the following data: [skipped data description] The goal is to perform clustering analysis on such data, that is to group togther those which have common characteristics. Which characteristics and how many groups ... ??? ... well this is to be found out. Is R a good tool for analysing many data and find patterns common to data subsets ? Which other tool do you advice ? Thank you very much, -- Maura E.M -- View this message in context: http://www.nabble.com/is-clustering-analysis-possible-with-R---tf4417188.html#a12602423 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] off-topic: better OS for statistical computing
My sense is that R users are even split between UNIX and Windows users so either will do in terms of the larger community. Some R packages may not be avaliable on every platform or will be available on one platform before another or there will be certain platform-specific issues. So in the end its easiest to have the same thing everyone else that you work with does. Also if you run into problems then you can ask others whereas if you are the lone person with something different you have no one to turn to. Also associated software may be, for example, Microsoft Office in a Microsoft environment and LaTeX in a UNIX environment. And networking will be simplified in a consistent environment too. Certainly there is Open Office, Samba and putty but the easiest is just not to have to worry about getting everything to work together by just having the same thing in the first place. Neither Linux nor Windows is superior to the other. People making such representations generally know one much better than the other and its more a reflection of their own experience than anything else. I personally have used both UNIX and Windows since their inception and find that I tend to have a slight preference for whatever I used last. Technical merits of one vs. the other are basically irrelevant for most purposes. On 9/10/07, Patrick Connolly [EMAIL PROTECTED] wrote: On Mon, 10-Sep-2007 at 12:26PM -0400, Gabor Grothendieck wrote: | You want whatever all the people you are working with are using | to make it as easy as possible to work together with them. Assuming you're using R, there is negligible difficulty using a different OS from what your colleagues use (apart from the inconsistencies you get between different versions of Windows, but even that has little effect on R). The standard .RData binary files work with Windows and Linux (and probably OS X). The only issue I come across is that Linux can't create WMF files as readily as Windows can, and that is more than made up for by the greater flexibility that Linux offers. It's easier in Linux to produce Excel files from dataframes and matrices using a perl script posted to this list by Marc Schwartz. Thanks again Marc. Best Patrick | | On 9/10/07, Wensui Liu [EMAIL PROTECTED] wrote: | Good morning, everyone, | I am sorry for this off-topic post but think I can get great answer | from this list. | My question is what is the best OS on PC (laptop) for statistical | computing and why. | I really appreciate your insight. | Have a nice day. | | __ | 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. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_Middle minds discuss events (:_~*~_:)Small minds discuss people (_)-(_) . Anon ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ 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] Generating Replicate Datasets (using loops or other means)
Hi Jonathan, What exactly do you mean by replication? Do you want to keep a1,b1,c1,... unchanged but have 30 different sets of random numbers? Regards, Moshe. --- VTLT1999 [EMAIL PROTECTED] wrote: Hello All, I have searched many help forums, message boards, etc. and I just can't apply the comments to what I need my program to do. I am running R 2.5.1 on an XP system, and my desire is to produce replicate datasets for a simulation study I am running. Essentially, I have sets of parameters (a's, b's, and c's) that define a function which produces a decimal value. This value is compared to a random uniform value, and is coded a 1 if the function is greater than the uniform value, 0 if it is = to the uniform value. My code thus far works great, but I just need it to run several times.Here we go: library(mvtnorm) library(sm) library(ltm) library(irtoys) k- 5000 set.seed(271828) t - rmvnorm(n=k,mean=c(-1,0,1),sigma=matrix(c(1,.8,.5,.8,1,.8,.5,.8,1),3,3)) #Using mv here because of the likely association of ability (theta = t) across time. t1-as.matrix(t[,1]) t2-as.matrix(t[,2]) t3-as.matrix(t[,3]) set.seed(271828) # Population item parameters (n=54) from which we will select relevant items # These are the parameters that are used in the function a - c(1.18120, 0.92613, 0.96886, 0.80503, 1.12384, 0.84073, 0.85544, 0.86801, 1.01054, 0.82278, 1.10353, 0.78865, 0.98421, 1.76071, 0.89603, 0.84671, 0.89737, 0.74775, 0.32190, 0.69730, 0.72059, 1.16762, 1.29257, 1.32902, 0.59540, 0.51022, 0.59259, 0.93951, 0.68568, 0.55649, 0.88084, 0.52940, 0.45735, 0.57560, 1.11779, 0.96984, 1.19692, 0.99102, 1.25847, 1.62555, 0.63049, 1.07807, 1.04897, 1.23138, 1.14014, 1.25230, 1.14844, 0.59287, 0.83143, 0.81723, 0.52141, 0.61980, 0.49945, 1.02749) b - c(-2.51737, -1.95897, -1.72667, -0.82988, -0.36093, 0.72554, 0.91442, 0.78061, 0.06088, 0.75733, -0.76371, 0.24552, -0.42050, 0.88232, -0.81761, 0.06466, -0.43866, -0.46042, 0.21636, -0.73147, -1.44086, -1.03718, 0.07275, -0.17197, 1.53796, -0.45631, -1.69826, -0.66506, 0.98921, 0.30714, -0.62245, 0.97253, 1.95894, 0.21277, 1.96346, 1.18825, 1.59917, -0.28401, -1.23530, -0.09671, -0.31581, -0.66149, -0.81284, -0.35399, -0.07623, 1.06442, -0.68559, 1.07591, 0.97458, 0.06436, 1.25622, 1.73954, 1.75052, 2.34088) c - c(0.0, 0.0, 0.0, 0.0, 0.19648, 0.31302, 0.26454, 0.19714, 0.06813, 0.21344, 0.0, 0.03371, 0.0, 0.16581, 0.11054, 0.08756, 0.07115, 0.26892, 0.0, 0.06883, 0.0, 0.14815, 0.32389, 0.19616, 0.17597, 0.0, 0.0, 0.04337, 0.19949, 0.20377, 0.0, 0.06243, 0.13639, 0.0, 0.18166, 0.15996, 0.20184, 0.08331, 0.24453, 0.26114, 0.16434, 0.20750, 0.32658, 0.31870, 0.45227, 0.35039, 0.31178, 0.17999, 0.22774, 0.21675, 0.10153, 0.17764, 0.15205, 0.19858) # Item parameters for generating 3PL data for all five testing occasions: # This selects the relevant parameters for a particular data generation run # Only parameters for the first testing occasion are shown to save space a1 - as.matrix(a[c(1:5,15:20,22:24,38:44)]) b1 - as.matrix(b[c(1:5,15:20,22:24,38:44)]) c1 - as.matrix(c[c(1:5,15:20,22:24,38:44)]) # Here is where I would like to begin my replications, but don't know how to make R do it. # The code below produces a matrix of 0's and 1's (which will be used by another program) # I would like to nest this in a do loop such that, say, 30 replicate datasets are produced using the #same parameters. N - nrow(t1) # number of examinees n - nrow(a1) # number of items d - 1.7 theta - t1 response - matrix (0,N,n) uni - matrix (runif(N*n),nrow = N) for (i in 1:N) { for (j in 1:n) { if ( c1[j]+(1-c1[j])/(1+exp(-d*a1[j]*(theta[i]-b1[j]))) uni[i,j] ) response[i,j] = 1 else response[i,j] = 0 } } write.table(response, file=C:/responses.dat, sep= ,row.names=FALSE, col.names=FALSE) I tried earlier nesting this in another for loop, but that indexes elements of matrices and vectors, and doesn't seem to apply to a global loop methodology. I am attempting to use replicate as we speak, but documentation is sparse (help(replicate) is nested in lapply information). Any guidance is greatly appreciated. Thanks in advance, Jonathan Beard -- View this message in context: http://www.nabble.com/Generating-Replicate-Datasets-%28using-loops-or-other-means%29-tf4418768.html#a12603580 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list
Re: [R] finding the minimum positive value of some data
Here are some solutions each of which 1. has only one line, 2. x only occurs once so you can just plug in a complex expression 3. no temporary variables are left min(sapply(x, function(z) if (z 0) z else Inf)) (function(z) min(ifelse(z 0, z, Inf))) (x) with(list(z = x), min(z[z 0])) local({ z - x; min(z[z 0]) }) On 9/10/07, dxc13 [EMAIL PROTECTED] wrote: useRs, I am looking to find the minimum positive value of some data I have. Currently, I am able to find the minimum of data after I apply some other functions to it: x [1] 1 0 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10 sort(x) [1] 0 1 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10 diff(sort(x)) [1] 1 0 1 1 0 1 1 0 0 1 1 1 0 1 0 1 0 min(diff(sort(x))) [1] 0 The minimum is given as zero, which is clearly true, but I am interested in only the positive minimum, which is 1. Can I find this by using only 1 line of code, like I have above? Thanks! dxc13 -- View this message in context: http://www.nabble.com/finding-the-minimum-positive-value-of-some-data-tf4417250.html#a12599319 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] what am I missing
x-seq(-1,1,length=10) y-seq(-1,1,length=10) a-matrix(c(1,2,2,1),2,2) b-matrix(c(2,1,1,2),2,2) fv-function(x,y) { m-x*a+y*b t-m[1,1]+m[2,2]; d-m[1,1]*m[2,2]-m[1,2]^2 return((t-sqrt(t^2-4*d))/2) } gv-function(x,y) { t-x*(a[1,1]+a[2,2])+y*(b[1,1]+b[2,2]) d-(x*a[1,1]+y*b[1,1])*(x*a[2,2]+y*b[2,2])-(x*a[1,2]+y*b[1,2])^2 return((t-sqrt(t^2-4*d))/2) } now outer(x,y,gv) works as expected, outer(x,y,fv) bombs. But z-matrix(0,10,10); for (i in 1:10) for (j in 1:10) z[i,j]-fv(x[i],y [j]) works fine. Must be something in outer(). == Jan de Leeuw, 11667 Steinhoff Rd, Frazier Park, CA 93225, 661-245-1725 .mac: jdeleeuw ++ aim: deleeuwjan ++ skype: j_deleeuw homepages: http://www.cuddyvalley.org and http://gifi.stat.ucla.edu == A bath when you're born, a bath when you die, how stupid. (Issa 1763-1827) [[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] what am I missing
Its a FAQ: http://hermes.sdu.dk/Rdoc/faq.html#Why%20does%20outer()%20behave%20strangely%20with%20my%20function%3f On 9/10/07, Jan de Leeuw [EMAIL PROTECTED] wrote: x-seq(-1,1,length=10) y-seq(-1,1,length=10) a-matrix(c(1,2,2,1),2,2) b-matrix(c(2,1,1,2),2,2) fv-function(x,y) { m-x*a+y*b t-m[1,1]+m[2,2]; d-m[1,1]*m[2,2]-m[1,2]^2 return((t-sqrt(t^2-4*d))/2) } gv-function(x,y) { t-x*(a[1,1]+a[2,2])+y*(b[1,1]+b[2,2]) d-(x*a[1,1]+y*b[1,1])*(x*a[2,2]+y*b[2,2])-(x*a[1,2]+y*b[1,2])^2 return((t-sqrt(t^2-4*d))/2) } now outer(x,y,gv) works as expected, outer(x,y,fv) bombs. But z-matrix(0,10,10); for (i in 1:10) for (j in 1:10) z[i,j]-fv(x[i],y [j]) works fine. Must be something in outer(). == Jan de Leeuw, 11667 Steinhoff Rd, Frazier Park, CA 93225, 661-245-1725 .mac: jdeleeuw ++ aim: deleeuwjan ++ skype: j_deleeuw homepages: http://www.cuddyvalley.org and http://gifi.stat.ucla.edu == A bath when you're born, a bath when you die, how stupid. (Issa 1763-1827) [[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] install packages automatically
Dear Listers, I am a little tired of installing all packages I want every time when I instill a new version of R. Say, if I have a list of packages I need to use, is it possible to tell R to install them all for me automatically rather than I install them one by one? Thx. __ 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] install packages automatically
Try ?update.packages Ross Darnell -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wensui Liu Sent: Tuesday, 11 September 2007 11:45 AM To: r-help@stat.math.ethz.ch Subject: [R] install packages automatically Dear Listers, I am a little tired of installing all packages I want every time when I instill a new version of R. Say, if I have a list of packages I need to use, is it possible to tell R to install them all for me automatically rather than I install them one by one? Thx. __ 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] scuba 1.1-8
Version 1.1-8 of package 'scuba' has been uploaded to CRAN. 'scuba' is a package for scuba diving calculations and decompression models. It supports dive profiles (tables, plotting etc), analysis of dive profiles using decompression models, gas toxicity calculations, and gas usage calculations. New features in version 1.1-8: . support for dive profiles uploaded from a dive computer . new dataset: dive profile from a wreck dive on nitrox . bug fix in oxygen toxicity calculations Adrian Baddeley ___ 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.
Re: [R] overlay lattice histograms with goodness-of-fit pdfs
Mange tak! FYI, this is the way it is able to run (I was going to attach station.precip.R, but I read that attaching files is not recommended - let me know if you would like it) x - dget(file=C://Documents and Settings/Bradley/My Documents/Arizona/CourseResources/ATMO529/station.precip.R) histogram(~ data | month * station, data = sta.stack, subset = type==precip month %in% c(Dec,Jan,Feb), xlab = Precipitation (mm), type = density, panel = function(x, ...) { panel.histogram(x, ...) panel.mathdensity(dmath = dnorm, col = black, args = list(mean = mean(sta.stack$data), sd = sd(sta.stack$data))) panel.mathdensity(dmath = dgamma, col = black, args = list(shape = (mean(sta.stack$data))^2 / (stdev(sta.stack$data))^2, scale = (stdev(sta.stack$data))^2 / mean(sta.stack$data))) }) Now, what would be great is to be able to reference the different calls to panel.mathdensity() so that the corresponding probability * histogram area ( = counts) in each bin can be used to compute a simple chi-square goodness-of-fit. I tried calling panel.mathdensity() outside of histogram(), but I don't think this is right - it returns NULL. I also looked at chisq.test, but this doesn't support trellis formulas. Any thoughts or leads? Thanks, Brad Christoffersen Quoting Frede Aakmann Tøgersen [EMAIL PROTECTED]: The following is one of the examples in the help page for histogram: histogram( ~ height | voice.part, data = singer, xlab = Height (inches), type = density, panel = function(x, ...) { panel.histogram(x, ...) panel.mathdensity(dmath = dnorm, col = black, args = list(mean=mean(x),sd=sd(x))) } ) This should give you some thing to start from. Also using the subset argument of the lattice functions will make make your code more readable. Instead of your code histogram(~ data | month * station, data = sta.stack[sta.stack[,type]==precip (sta.stack[,month]==Dec | sta.stack[,month]==Jan | sta.stack[,month]==Feb),], xlab = Precipitation (mm)) you can use (not tested because you didn't supply a reproducable example) histogram(~ data | month * station, data = sta.stack subset = type==precip month %in% c(Dec, Jan, Feb), xlab = Precipitation (mm)) Med venlig hilsen Frede Aakmann Tøgersen -Oprindelig meddelelse- Fra: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] På vegne af Brad Christoffersen Sendt: 10. september 2007 12:08 Til: R-help@stat.math.ethz.ch Emne: [R] overlay lattice histograms with goodness-of-fit pdfs Hello, I am new to R exploratory data analysis and plotting. Is anyone aware of a way to overlay a set of conditional histograms with conditional PDFs? Below, I generate a lattice plot of precipitation histograms based on different months and stations, given a subset of the dataset: histogram(~ data | month * station, data = sta.stack[sta.stack[,type]==precip (sta.stack[,month]==Dec | sta.stack[,month]==Jan | sta.stack[,month]==Feb),], xlab = Precipitation (mm)) I previously used a combination of the low-level 'lines()' and 'dgamma()' functions to overlay a gamma PDF onto a single histogram. Now what I would like to do is to do the same thing, but with a function that allows me to specify a formula similar to that in the histogram function above [SomeKindOfPDF] ~ [x-range] | month * station which will plot the PDF with the appropriate factors (month and station). All I'm looking for is for someone to get me going in the right direction with a useful package or function to use. Any help is much appreciated! Brad Christoffersen __ 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] POSIXct dates on x-axis using xyplot
I am using 'xyplot' in lattice to plot some data where the x-axis is a POSIXct date. I have data which spans a 6 month period, but when I plot it, only the last month is printed on the right hand side of the axis. I would have expected that at least I would have a beginning and an ending point so that I have a point of reference as to the time that the data spans. Here is some test data. # create test data dates - seq(as.POSIXct('2006-01-03'), as.POSIXct('2006-06-26'), by='1 week') my.data - seq(1, length=length(dates)) require(lattice) [1] TRUE # plot only shows a single month (Jul on the right). Would have # expected at least the beginning and the ending month since this spans # a 6 month period pdf('/test.pdf') xyplot(my.data ~ dates) dev.off() windows 2 sessionInfo() R version 2.5.1 (2007-06-27) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods [7] base other attached packages: lattice 0.16-5 Sys.info() sysname release Windows NT 5.1 version nodename (build 2600) Service Pack 2 JIM-LAPTOP machine login x86 jim holtman user jim holtman -- 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 minimum positive value of some data
Either min(diff(sort(x))[diff(sort(x))0]) or min(diff(sort(unique(x --- dxc13 [EMAIL PROTECTED] wrote: useRs, I am looking to find the minimum positive value of some data I have. Currently, I am able to find the minimum of data after I apply some other functions to it: x [1] 1 0 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10 sort(x) [1] 0 1 1 2 3 3 4 5 5 5 6 7 8 8 9 9 10 10 diff(sort(x)) [1] 1 0 1 1 0 1 1 0 0 1 1 1 0 1 0 1 0 min(diff(sort(x))) [1] 0 The minimum is given as zero, which is clearly true, but I am interested in only the positive minimum, which is 1. Can I find this by using only 1 line of code, like I have above? Thanks! dxc13 -- View this message in context: http://www.nabble.com/finding-the-minimum-positive-value-of-some-data-tf4417250.html#a12599319 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.
Re: [R] using bootstrap for tree selection step in rpart
Fiona Callaghan wrote: I was wondering if someone could help me with an rpart problem. I can see that cross-validation is the default for tree selection in rpart -- has a bootstrap method been implemented anywhere? I think this is a different thing to 'bagging' or 'boosting' -- I still want 'one' tree at the end, I just would like it chosen using a bootstrap method. Any ideas??? Hi Fiona, I'm not sure if I understand you correctly. To get one single rpart tree trained on one bootstrap sample, try bagging() from the 'ipred' package and set nbagg=1. Bye, Chris __ 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.