I have a set of Monte Carlo simulation results for a Quick Response
Freight Model that I am currently preparing summary graphs. I want to
show three things on the graphs; the model forecast, an approximate
exponential best fit line, and a smooth line through mean+sd and mean-sd
data points.
 
As you can see I can get the first two, but all I can find when
searching the help are references to fitting spline models to the data
points.  I'm old school, so I was used to using a french curve to draw
the smooth lines I'm interested in.  The problem is that I don't
understand how/why of fitting a model to the data points.  
 
Here is an example of the data I am graphing:
    year   mean     sd
1  2010   6738     1721
2  2015   8793     2326
3  2020   11699   3333
4  2025   15951   5232
5  2030   22492   9768
6  2035   33289   24431
7  2040   52917   82341
 
And here is the R code I am currently using:
gr = function (yr,rate,trk)  trk*rate^(yr-2006)
 
plot.results <- function(dfn) {
  dt <- read.table(dfn)
  res.g = nls(dt$mean ~ gr(dt$year, R, T), start=c(R=1.08, T=3700),
data=dt)
  R <- as.numeric(coef(res.g)[1])
  T <- as.numeric(coef(res.g)[2])
  plot(dt$year,dt$mean, pch=1, col="green", main="Truck Forecast",
xlab="Year", ylab="Truck Volume", ylim=c(0,max(dt$year+dt$sd)))
  curve(gr(x, R, T), add=TRUE, col="green")
}

Any help is appreciated!
 

Walter Anderson, GISP
PBS&J
6504 Bridge Point Pkwy, Ste. 200
Austin, TX. 78730
P:512.342.3237
F:512.327.2453
M:512.364.8318

 

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to