Re: [R] panel.levelplot() for 2D histograms
-Original Message- From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] Sent: Monday, February 06, 2006 9:52 PM To: Vermeiren, Hans [VRCBE] Cc: [EMAIL PROTECTED] Subject: Re: panel.levelplot() for 2D histograms On 2/6/06, Vermeiren, Hans [VRCBE] [EMAIL PROTECTED] wrote: Dear R-wizards, I'm trying to plot binned scatterplots, or 2d histograms, if you wish, for a number of groups by using the lattice functionality it works fine for one group at a time, and probably I could find a work-around, but I prefer to do it the elegant way here's an example of what I want, what I tried and where it goes wrong: If you are doing this for fun, read on. Otherwise, I suggest that you look at the hexbin package (available from bioconductor) for a better solution. The development version (to be released after R 2.3.0) already has a lattice-ified interface called 'hexbinplot'. for fun ? yes and no, I really need this for my job, but otoh, working with R is always fun thanks a lot for the pointer to hexbin, that's really what I was looking for, but i did read on and I'll try the grid.rect hint as well (just for fun) thanks again, Hans __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] panel.levelplot() for 2D histograms
Dear R-wizards, I'm trying to plot binned scatterplots, or 2d histograms, if you wish, for a number of groups by using the lattice functionality it works fine for one group at a time, and probably I could find a work-around, but I prefer to do it the elegant way here's an example of what I want, what I tried and where it goes wrong: require(gregmisc) require(lattice) #toy dataset: ds-data.frame(x=rnorm(3000),y=rnorm(3000),group=rep(factor(c(A,B,C)), 1000)) # this binscatter-function shows what I want, # I just would like to have it as a panel function binscatter-function(x,y){ col-rev(gray.colors(5)) breaks=c(1,5,10,100,500,10) h2d-hist2d(x=x,y=y,nbins=10,same.scale=T,show=F) image(h2d$x,h2d$y,h2d$counts,breaks=breaks,col=col,axes=T) } # for one group, this works fine A-subset(ds,group==A) binscatter(A$x,A$y) # simple xyplot does too (of course) xyplot(y~x|group,data=ds) # but my lattice-ified version of binscatter does not: # 1st attempt panel.binscatter-function(x,y,subscripts,...){ col-gray.colors(5) breaks=c(1,5,10,100,500,10) h2d-hist2d(x=x,y=y,nbins=10,same.scale=T,show=F) panel.levelplot(h2d$x,h2d$y,h2d$counts,subscripts=1:length(h2d$x),at=breaks, col.regions=col,region=T) } xyplot(y~x|group,data=ds,panel=panel.binscatter) # but, this doesnt work either for one group using levelplot() : Ah2d-hist2d(A$x,A$y,nbins=10,same.scale=T,show=F) levelplot(Ah2d$counts~Ah2d$x*Ah2d$y) # but this DOES: grid-expand.grid(x=Ah2d$x,y=Ah2d$y) levelplot(Ah2d$counts~grid$x*grid$y) #2nd attempt doesn't work, I give up.. panel.binscatter-function(x,y,subscripts,...){ col-gray.colors(5) breaks=c(1,5,10,100,500,10) h2d-hist2d(x=x,y=y,nbins=10,same.scale=T,show=F) grid-expand.grid(x=h2d$x,y=h2d$y) panel.levelplot(grid$x,grid$y,h2d$counts,subscripts=1:length(h2d$x),at=break s,col.regions=col) } xyplot(y~x|group,data=ds,panel=panel.binscatter) all suggestions welcome, thanks a lot Hans __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] e1071::SVM calculate distance to separating hyperplane
Hi, I know this question has been posed before, but I didnt find the answer in the R-help archive, so please accept my sincere apologies for being repetitive: How can one (elegantly) calculate the distance between data points (in the transformed space, I suppose) and the hyperplane that separates the 2 categories when using svm() from the e1071 library? thanks a lot, Hans __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] obtaining a ROC curve
Hello, I have a classification tree. I want to obtain a ROC curve for this test. What is the easiest way to obtain one? -Anjali did you try the ROCR package ? regards, Hans Vermeiren __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Robust Non-linear Regression
thank you all for the valuable suggestions rnls() is indeed what I was looking for I've to apologize to Roger Koenker for not mentioning that I did try quantile regression (saw his answer in a previous post with a similar question, yes i did my homework) however, least medians regression gave not always satisfying results, I now understand that this is in fact due to variability in the concentrations (x-axis) (thanks to Martin Maechlers remark), my example dataset was in that sense a bit unfortunate regards Hans Vermeiren -Original Message- From: Martin Maechler [mailto:[EMAIL PROTECTED] Sent: Monday, November 14, 2005 12:41 PM To: Vermeiren, Hans [VRCBE] Cc: 'r-help@stat.math.ethz.ch'; [EMAIL PROTECTED] Subject: Re: [R] Robust Non-linear Regression Package 'sfsmisc' has had a function 'rnls()' for a while which does robust non-linear regression via M-estimation. Since you have only outliers in 'y' and none in 'x', you could use the 'nlrq' (nonlinear regression quantiles) package that Roger Koenker mentioned. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Robust Non-linear Regression
Hi, I'm trying to use Robust non-linear regression to fit dose response curves. Maybe I didnt look good enough, but I dind't find robust methods for NON linear regression implemented in R. A method that looked good to me but is unfortunately not (yet) implemented in R is described in http://www.graphpad.com/articles/RobustNonlinearRegression_files/frame.htm http://www.graphpad.com/articles/RobustNonlinearRegression_files/frame.htm in short: instead of using the premise that the residuals are gaussian they propose a Lorentzian distribution, in stead of minimizing the squared residus SUM (Y-Yhat)^2, the objective function is now SUM log(1+(Y-Yhat)^2/ RobustSD) where RobustSD is the 68th percentile of the absolute value of the residues my question is: is there a smart and elegant way to change to objective function from squared Distance to log(1+D^2/Rsd^2) ? or alternatively to write this as a weighted non-linear regression where the weights are recalculated during the iterations in nlme it is possible to specify weights, possibly that is the way to do it, but I didn't manage to get it working the weights should then be something like: SUM (log(1+(resid(.)/quantile(all_residuals,0.68))^2)) / SUM (resid(.)) the test data I use : x-seq(-5,-2,length=50) x-rep(x,4) y-SSfpl(x,0,100,-3.5,1) y-y+rnorm(length(y),sd=5) y[sample(1:length(y),floor(length(y)/50))]-200 # add 2% outliers at 200 thanks a lot Hans Vermeiren [[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