title: Fitting a market unit sales S-Curve with R
body: <p>I have been tasked with fitting some market sales curves base on macro-economic data using several independent variables; I have 14 years of history.  Sample data would be:</p>
  
  <pre><code>UnitSales,GDP,GDPPerCap,CPI,PropInvIndex,DispIncTopDecile,TransCommSecDecile,CivilVehOwn,Urban,AutoFin
  " 2,833 ",1198243.4,949,81.62,4984,10643,618,1609,36.22,0
  " 7,607 ",1324337.8,1042,81.38,6344,14219,782,1802,37.66,0
  " 10,098 ",1453827.558,1135,80.8,7790.9223,18995.9,991.2,2053.17,39.08978381,0
  " 18,649 ",1640958.735,1274,81.83,10153.8009,21837.3,1106,2382.93,40.53022975,0
  " 14,525 ",1931644.33,1409,85.02,13158.2516,25377.2,1274.2,2693.71,41.76000862,0
  " 19,149 ",2256902.591,1731,86.56,15909.2471,28773.1,1590.3,3160,42.98999663,0
  " 22,474 ",2712950.885,2069,87.83,19422.9174,31967.3,1801,3697.3531,44.34301016,0
  " 32,573 ",3494055.942,2651,92.02,25288.8373,36784.5,2467.7,4358.355,45.8892446,0.1
  " 42,186 ",4521827.271,3414,97.45,31203.1942,43613.8,2632.9,5099.6094,46.98950317,0.12
  " 52,765 ",4990233.519,3749,96.76,36241.808,46826.1,3181.9,6280.6086,48.34170101,0.14
  " 140,855 ",5930502.27,4433,100,48259.403,51431.6,3630.6,7801.8259,49.94966105,0.16
  " 88,873 ",7321891.955,5447,105.45,61796.8858,58841.9,3963,9356.3163,51.27027127,0.18
  " 161,082 ",8229490.03,6093,108.22,71803.7869,63824.2,4304.1,10933.0912,52.57008656,0.22
  " 149,197 ",9240270.452,6807,111.07,86013.3826,68874.37491,4748.669569,12670.1435,53.73,0.26
  </code></pre>
  
  <p>Of the macroeconomic variables I have, I can use just a subset if degrees of freedom become an issue. Since the data are products that follow a lifecycle and have market saturation effects the curves should be S-curves or sigmoidal.  In my attempts in R I have only been able to fit exponential (J-curve) curves; I have tried tslm (from fpp package) to fit the model.</p>
  
  <p>My current R code is</p>
  
  <pre><code># rm(list=ls())
  ds &lt;- read.csv(file='c:/RCode/Output/PremM.csv', header=T, sep=',')
  tsdata &lt;-ts(ds, s=2000)
  results&lt;- tslm(UnitSales~GDP+GPDPerCap+CPI+trend, data=tsdata)
  
  write.csv(coef(results), file = "c:/Rcode/Output/CoefPremM.csv")
  
  sink('C:/RCode/Output/PremMSummary2.txt',append=F,type="output")
  summary(results)
  sink(NULL)
  </code></pre>
  
  <p>The tslm package isn't working.  I'm at the very edge of my competence and have only learned R for this project, so am a newbie.  If someone could point me to an appropriate R package and sample code I would be eternally grateful.  The examples I've seen have all been with logistic curves for binary data which don't seem appropriate to my task.</p>
  
  <p>Your help is appreciated at year's end.</p>