Hi R Users, I am very new to R and would like to do something quick if possible, please help! Suppose I have a data set of y versus x, how can I generate a smoothing line of y versus x (for example, using loess) and at the same time, generate a pair of confidence intervals for the smoothing or mean plus/minus standard deviation? Yi Zhu Golder Associates Inc. USA -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello R Users, I am very new to R and would like to do something quick if possible, please help! Suppose I have a data set of y versus x, how can I generate a smoothing line of y versus x (for example, using loess) and at the same time, generate a pair of confidence intervals for the smoothing or mean plus/minus standard deviation? Best regards, Yi Zhu -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Also, the sm library has a nice function for doing a kernel smooth: sm.regression(x, y, h = <bandwidth>, display="se") does three things: plot the points, draw the smooth line, draw the confidence intervals (dotted lines). You supply the bandwidth, of course. -roger _______________________________ UCLA Department of Statistics rpeng at stat.ucla.edu http://www.stat.ucla.edu/~rpeng On Mon, 17 Dec 2001, Zhu, Yi wrote:> > Hello R Users, > > I am very new to R and would like to do something quick if possible, please > help! > > Suppose I have a data set of y versus x, how can I generate a smoothing line > of y versus x (for example, using loess) > and at the same time, generate a pair of confidence intervals for the > smoothing or mean plus/minus standard deviation? > > Best regards, > > Yi Zhu > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Suppose I have a data set of y versus x, how can I generate a smoothing line > of y versus x (for example, using loess) > and at the same time, generate a pair of confidence intervals for the > smoothing or mean plus/minus standard deviation?- You could use library mgcv: library(mgcv) g.m<-gam(y~s(x)) plot(g.m) # plot of centred smooth # or alternatively..... p.d<-data.frame(x=seq(min(x),max(x),length=100)) b<-predict.gam(g.m,p.d,se=TRUE) range<-c(min(b$fit-2*b$se.fit),max(b$fit+2*b$se.fit)) plot(p.d$x,b$fit,ylim=range,xlab="x",ylab="y",type="l") lines(p.d$x,b$fit+b$se.fit*2,col=2) lines(p.d$x,b$fit-b$se.fit*2,col=2) cheers, 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._