Dear R users, Using the library(mgcv) and running R under MacOSX, I have fitted a generalised additive model with binomial errors in order to check the linearity of two continuous variables ap2mm and diffdaysm in a glm:> mymodel.gam <- gam(diedhos~ s(ap2mm) + Dweekm + s(diffdaysm) +Dweekm:diffdaysm + ap2mm:Dweekm, binomial) I would like postscript gam plots for the two smoothed terms to be produced on separate pages, but am having trouble getting these. I can get the two plots output to a single page using> postscript("gams.ps") > plot(mymodel.gam, pages=1, se=T) > dev.off()I don't want this, but when I try replacing pages=1 with pages=2, I still get only one page in the postscript file with the second plot overlaid on the first one:> plot(mymodel.gam, pages=2, se=T)Press return for next page.... I wondered if anyone knows of a way to get each plot on a separate page, i.e. two postscript files? I also noticed that the plot gives tick marks for the values of the variable along the horizontal axis, but I would like a rug of *all* the values (Splus5 produces a rug using jittering to show the density of the observations, but the version of R that I have doesn't do this, as far as I can tell). I would be very grateful if anyone has any suggestions that would help sort this out. Many thanks, Patty -- -------------------------------------------------------------------------------- Assoc Prof Patty Solomon phone: (08) 8303 3033 Department of Applied Mathematics and fax: (08) 8303 3696 Centre for the Molecular Genetics of Development Adelaide University Adelaide SA 5005 AUSTRALIA. email: patty.solomon at adelaide.edu.au http://www.maths.adelaide.edu.au/people/psolomon -------------------------------------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> I would like postscript gam plots for the two smoothed terms to be > produced on separate pages, but am having trouble getting these. I > can get the two plots output to a single page using > > > postscript("gams.ps") > > plot(mymodel.gam, pages=1, se=T) > > dev.off() > > I don't want this, but when I try replacing pages=1 with pages=2, I > still get only one page in the postscript file with the second plot > overlaid on the first one: > > > plot(mymodel.gam, pages=2, se=T) > Press return for next page.... >.... I can't get this to happen, but i don't have access to a mac at the moment [I tried it using R 1.4.0 / mgcv 0.6.* under unix]. I wonder if the problem is Mac specific?> I also noticed that the plot gives tick marks for the values of the > variable along the horizontal axis, but I would like a rug of *all* > the values (Splus5 produces a rug using jittering to show the density > of the observations, but the version of R that I have doesn't do > this, as far as I can tell).- sorry, jittering's not implemented, but it should be easy to get a jittered plot. Your model object will contain all the raw data in mymodel.gam$x (in addition to any dummy variables implied by the model formula). You can jitter these yourself before calling plot.gam(). e.g. to jitter the second covariate: mymodel.gam$x[2,]<-jitter(mymodel.gam$x[2,]) [although you probably want to control the amount of jittering using the `amount' argument]. I'll add adding a jitter option to the mgcv "to do" list. Simon ______________________________________________________________________> Simon Wood snw at st-and.ac.uk http://www.ruwpa.st-and.ac.uk/simon.html > The Mathematical Institute, North Haugh, St. Andrews, Fife KY16 9SS UK > Direct telephone: (0)1334 463799 Indirect fax: (0)1334 463748-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Sat, 22 Dec 2001, Patty Solomon wrote:> Dear R users, > > Using the library(mgcv) and running R under MacOSX, I have fitted a > generalised additive model with binomial errors in order to check the > linearity of two continuous variables ap2mm and diffdaysm in a glm: > > > > mymodel.gam <- gam(diedhos~ s(ap2mm) + Dweekm + s(diffdaysm) + > Dweekm:diffdaysm + ap2mm:Dweekm, binomial) > > I would like postscript gam plots for the two smoothed terms to be > produced on separate pages, but am having trouble getting these. I > can get the two plots output to a single page using > > > postscript("gams.ps") > > plot(mymodel.gam, pages=1, se=T) > > dev.off() > > I don't want this, but when I try replacing pages=1 with pages=2, I > still get only one page in the postscript file with the second plot > overlaid on the first one: > > > plot(mymodel.gam, pages=2, se=T) > Press return for next page.... > > > I wondered if anyone knows of a way to get each plot on a > separate page, i.e. two postscript files?This needs options to postscript(), not to plot() eg postscript("gams%d.ps",onefile=FALSE) You will end up with files gams1.ps and gams2.ps.> I also noticed that the plot gives tick marks for the values of the > variable along the horizontal axis, but I would like a rug of *all* > the values (Splus5 produces a rug using jittering to show the density > of the observations, but the version of R that I have doesn't do > this, as far as I can tell).You can edit plot.gam fairly easily to do this (either with fix(plot.gam) or by saving the code to a file and editing it) There are two calls to rug() in plot.gam() and you want to insert jitter() in each one: ie change rug(as.numeric(x$x[x$nsdf + i, ])) to rug(jitter(as.numeric(x$x[x$nsdf + i, ]))) If you could live with regression splines instead of smoothing splines you could fit a glm() and use termplot(), which does jitter. -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._