For a project that I'm working on we consider a cohort a set of people who installed our app on any given day. The cumulative revenue from a cohort is logarithmic in shape and I'd like to use this fact to build a predictive model.
I'm aware that time series might be appropriate here, but for this project I really want to try this using a logarithmic model along the lines of what follows.
I'm struggling in how I should predict on a new cohort of data. Here's an example:
exampledf <- data.frame(
tenure = 1:11,
cumulative_revenue = c(142, 149, 154, 155, 159, 161, 163, 164, 164, 166, 167)
)
exampledf %>% ggplot(aes(x = tenure, y = cumulative_revenue)) + geom_point()
exampledf %>% ggplot(aes(x = log(tenure),y = cumulative_revenue)) + geom_point()
These charts look like this: Logarithmic curve:
When log transforming the predictor, it's linear:
Pretend the data above is based on historic data. Suppose I used data for the 30 cohorts/days in the month of April 2020 and monitored the cumulative revenue for each then grouped by days of tenure 1:11 per the above sample and then took the cumulative revenue on each additional day.
Based on this I fit a log model in R:
model <- lm(cumulative_revenue ~ log(tenure), data = exampledf)
summary(model)
mod_coeffs <- model %>% coefficients
predict(model, newdata = data.frame(tenure = 16)) # 170.8961 # a prediction for cumulative revenue after 16 days of tenure
Here's the summary of the model:
Call:
lm(formula = cumulative_revenue ~ log(tenure), data = exampledf)
Residuals:
Min 1Q Median 3Q Max
-1.40429 -0.07062 0.08757 0.35345 0.74568
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 141.9124 0.4943 287.08 < 2e-16 ***
log(tenure) 10.4537 0.2837 36.85 3.96e-11 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.6684 on 9 degrees of freedom
Multiple R-squared: 0.9934, Adjusted R-squared: 0.9927
F-statistic: 1358 on 1 and 9 DF, p-value: 3.956e-11
Now here's my question. Using this model based on historic data, I can predict what cumulative revenue will be after n days using predict(model, newdata = data.frame(tenure = 16))
. But if I have genuine new data, my starting point will always be different. E.g. say that the growth curve looks the same as the examples above for a new cohort, but that they have a smaller initial starting value. Maybe there's variation from cohort to cohort. In the example data, the cumulative revenue on day 1 is 142. But what if for another cohort it's 200, then for another it's only 50.
Is there something I can do here? I almost want to change the intercept when predicting, or just use the models growth rates as opposed to actual to predict on new data.
How can I wield my model to fit new data that takes into account not only tenure in days, but also the initial revenue after day 1 to make a prediction?