enter image description here

This is a graph of revenues for different products with the Y-axis showing normalized revenues (mean of 3 and SD of 1) and X-axis is weeks. I need do a regression analysis of sorts on this data and am unsure how to find a curve/function in R that fits this data.

The data points can be interpreted as being: Week 0 of product release yield normalized revenues between 2.25 to 3.25, etc.

Any help regarding what kind of statistical analysis I can use to create a regression model (linear and logistic wouldn't work clearly) with the end goal being to do predictive analysis (ie. if a new product is released, what normalized revenues would it yield in the first 6 weeks)



You can fit an OLS to this, it will just fit right through the mean values for each week. You may wish to experiment with polynomial specifications. For example, suppose your dependent variable is $y$ and the explanatory variable week is $x$ then I would try something along the lines of ols.fit = lm(y ~ x+ I(x^2)+I(x^3))+I(x^4). You could cross-validate to see which polynomial specification fits your data best for predictive purposes.

This is a starting point. However, it really depends on what you wish to model/see. I would also regularize (can run using glmnet module), which would prove useful for this few points. Or you can fit non-linear in parameter functions using nls. Namely, nls allows you to fit

$$y = f(\theta, x) + \varepsilon$$ where $\varepsilon \sim N(0,\sigma^2)$.

Using the function in the comments, you could do something along the lines of:

formulaExp <- as.formula(y ~ (a*ln(x)+b)/ (c*x^n))

nls.fit <- nls(formulaExp, start = list(a=1, b=1, c=1), data=data)

You'll have to play around but hope the above helps. Also, check this link out and nls here.

  • $\begingroup$ but doesn't a logarithmic function best fit this type of data? If you graph the y = (aln(x) + b)) / (cx^n) + d function.. you'll see that it is the type of model that would best fit the data.. Is that correct? Any idea what function i would use in R for this? $\endgroup$ – Avenger Jun 17 '16 at 18:54
  • $\begingroup$ Well, remember that we can approximate almost any curve with a polynomial. But check out nls, I added some details about it in the answer. $\endgroup$ – Gene Burinsky Jun 17 '16 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.