How to add trendline (i.e. straight line passing through maximum points) in graph. I have worked on the data given below. Please tell me how to add trendline in the graph. The script is as follows =================================== start =================================================== # The data is as follows data <- c( 0.01, 0.02, 0.04, 0.13, 0.17 , 0.19 , 0.21 , 0.27 , 0.27 , 0.28, 0.29, 0.37, 0.41, 0.49, 0.51, 0.52, 0.54, 0.57, 0.62, 0.63, 0.68, 0.73, 0.74, 0.79, 0.81, 0.81, 0.82, 0.86, 0.94, 0.96, 1.02, 1.10, 1.10, 1.20, 1.29, 1.36, 1.40, 1.41, 1.44, 1.45, 1.62, 1.67, 1.69, 1.78, 1.82, 2.11, 2.13, 2.14, 2.24, 2.29, 2.34, 2.40, 2.46, 2.70, 2.83, 2.98, 3.00, 3.30, 3.53, 3.70, 3.86, 3.90, 3.91, 3.98, 5.01, 5.23, 6.05, 6.12, 10.41, 10.73) # P-P plot average <- mean(data) lambda <- (1/average) e <- c(1:70) f <- c((e-.5)/70) Fx <- c(1 - exp(-lambda*data)) g <- sort(Fx) plot(f,g) ===================================== end =================================================== Awaiting your positive reply. Regards. Priti.
Hi maybe abline(0,1) HTH Petr On 19 Jun 2006 at 16:22, priti desai wrote: Date sent: Mon, 19 Jun 2006 16:22:24 +0530 From: "priti desai" <priti.desai at kalyptorisk.com> To: <r-help at stat.math.ethz.ch> Subject: [R] Qurey : How to add trendline( st. line) in Graph> How to add trendline (i.e. straight line passing through maximum > points) in graph. I have worked on the data given below. Please tell > me how to add trendline in the graph. > > The script is as follows > > =================================== start > ===================================================> > # The data is as follows > > data <- c( 0.01, 0.02, 0.04, 0.13, 0.17 , 0.19 , 0.21 , 0.27 , 0.27 > , 0.28, 0.29, 0.37, > 0.41, 0.49, 0.51, 0.52, 0.54, 0.57, 0.62, 0.63, > 0.68, > 0.73, 0.74, 0.79, > 0.81, 0.81, 0.82, 0.86, 0.94, 0.96, 1.02, 1.10, > 1.10, > 1.20, 1.29, 1.36, > 1.40, 1.41, 1.44, 1.45, 1.62, 1.67, 1.69, 1.78, > 1.82, > 2.11, 2.13, 2.14, > 2.24, 2.29, 2.34, 2.40, 2.46, 2.70, 2.83, 2.98, > 3.00, > 3.30, 3.53, 3.70, > 3.86, 3.90, 3.91, 3.98, 5.01, 5.23, 6.05, 6.12, > 10.41, > 10.73) > > # P-P plot > average <- mean(data) > lambda <- (1/average) > e <- c(1:70) > f <- c((e-.5)/70) > Fx <- c(1 - exp(-lambda*data)) > g <- sort(Fx) > plot(f,g) > > ===================================== end > ===================================================> > Awaiting your positive reply. > > Regards. > Priti. > > ______________________________________________ > R-help at 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.htmlPetr Pikal petr.pikal at precheza.cz
Gabor Grothendieck
2006-Jun-19 11:58 UTC
[R] Qurey : How to add trendline( st. line) in Graph
Try: library(quantreg) abline(rq(g ~ f, tau = .999)) On 6/19/06, priti desai <priti.desai at kalyptorisk.com> wrote:> How to add trendline (i.e. straight line passing through maximum points) > in graph. > I have worked on the data given below. > Please tell me how to add trendline in the graph. > > The script is as follows > > =================================== start > ===================================================> > # The data is as follows > > data <- c( 0.01, 0.02, 0.04, 0.13, 0.17 , 0.19 , 0.21 , 0.27 , 0.27 , > 0.28, 0.29, 0.37, > 0.41, 0.49, 0.51, 0.52, 0.54, 0.57, 0.62, 0.63, 0.68, > 0.73, 0.74, 0.79, > 0.81, 0.81, 0.82, 0.86, 0.94, 0.96, 1.02, 1.10, 1.10, > 1.20, 1.29, 1.36, > 1.40, 1.41, 1.44, 1.45, 1.62, 1.67, 1.69, 1.78, 1.82, > 2.11, 2.13, 2.14, > 2.24, 2.29, 2.34, 2.40, 2.46, 2.70, 2.83, 2.98, 3.00, > 3.30, 3.53, 3.70, > 3.86, 3.90, 3.91, 3.98, 5.01, 5.23, 6.05, 6.12, 10.41, > 10.73) > > # P-P plot > average <- mean(data) > lambda <- (1/average) > e <- c(1:70) > f <- c((e-.5)/70) > Fx <- c(1 - exp(-lambda*data)) > g <- sort(Fx) > plot(f,g) > > ===================================== end > ===================================================> > Awaiting your positive reply. > > Regards. > Priti. > > ______________________________________________ > R-help at 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 >
Sean O'Riordain
2006-Jun-19 12:10 UTC
[R] Qurey : How to add trendline( st. line) in Graph
lines(predict(lm(g~f))~f,lty=2) or if its a curvy line you're looking for... lines(predict(loess(g~f))~f,lty=3) On 19/06/06, priti desai <priti.desai at kalyptorisk.com> wrote:> How to add trendline (i.e. straight line passing through maximum points) > in graph. > I have worked on the data given below. > Please tell me how to add trendline in the graph. > > The script is as follows > > =================================== start > ===================================================> > # The data is as follows > > data <- c( 0.01, 0.02, 0.04, 0.13, 0.17 , 0.19 , 0.21 , 0.27 , 0.27 , > 0.28, 0.29, 0.37, > 0.41, 0.49, 0.51, 0.52, 0.54, 0.57, 0.62, 0.63, 0.68, > 0.73, 0.74, 0.79, > 0.81, 0.81, 0.82, 0.86, 0.94, 0.96, 1.02, 1.10, 1.10, > 1.20, 1.29, 1.36, > 1.40, 1.41, 1.44, 1.45, 1.62, 1.67, 1.69, 1.78, 1.82, > 2.11, 2.13, 2.14, > 2.24, 2.29, 2.34, 2.40, 2.46, 2.70, 2.83, 2.98, 3.00, > 3.30, 3.53, 3.70, > 3.86, 3.90, 3.91, 3.98, 5.01, 5.23, 6.05, 6.12, 10.41, > 10.73) > > # P-P plot > average <- mean(data) > lambda <- (1/average) > e <- c(1:70) > f <- c((e-.5)/70) > Fx <- c(1 - exp(-lambda*data)) > g <- sort(Fx) > plot(f,g) > > ===================================== end > ===================================================> > Awaiting your positive reply. > > Regards. > Priti. > > ______________________________________________ > R-help at 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 >
Gabor Grothendieck
2006-Jun-19 12:33 UTC
[R] Qurey : How to add trendline( st. line) in Graph
One other item. You had asked for the trendline passing through the maximum points, which is what my prior answer gives, but others interpreted your question as just as ordinary trendline so if that is what you are looking for try this: abline(lm(g ~ f)) On 6/19/06, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:> Try: > > library(quantreg) > abline(rq(g ~ f, tau = .999)) > > On 6/19/06, priti desai <priti.desai at kalyptorisk.com> wrote: > > How to add trendline (i.e. straight line passing through maximum points) > > in graph. > > I have worked on the data given below. > > Please tell me how to add trendline in the graph. > > > > The script is as follows > > > > =================================== start > > ===================================================> > > > # The data is as follows > > > > data <- c( 0.01, 0.02, 0.04, 0.13, 0.17 , 0.19 , 0.21 , 0.27 , 0.27 , > > 0.28, 0.29, 0.37, > > 0.41, 0.49, 0.51, 0.52, 0.54, 0.57, 0.62, 0.63, 0.68, > > 0.73, 0.74, 0.79, > > 0.81, 0.81, 0.82, 0.86, 0.94, 0.96, 1.02, 1.10, 1.10, > > 1.20, 1.29, 1.36, > > 1.40, 1.41, 1.44, 1.45, 1.62, 1.67, 1.69, 1.78, 1.82, > > 2.11, 2.13, 2.14, > > 2.24, 2.29, 2.34, 2.40, 2.46, 2.70, 2.83, 2.98, 3.00, > > 3.30, 3.53, 3.70, > > 3.86, 3.90, 3.91, 3.98, 5.01, 5.23, 6.05, 6.12, 10.41, > > 10.73) > > > > # P-P plot > > average <- mean(data) > > lambda <- (1/average) > > e <- c(1:70) > > f <- c((e-.5)/70) > > Fx <- c(1 - exp(-lambda*data)) > > g <- sort(Fx) > > plot(f,g) > > > > ===================================== end > > ===================================================> > > > Awaiting your positive reply. > > > > Regards. > > Priti. > > > > ______________________________________________ > > R-help at 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 > > >