printModel <- function(coefs) {
  (raw <- paste0("e ^ ",formnumb(coefs[["(Intercept)"]], selfRound=TRUE), " + e ^ (", formnumb(coefs[[2]], selfRound=TRUE), " * x )" ))
  (form2 <- paste0(formnumb(exp(coefs[["(Intercept)"]]), selfRound=TRUE), " + e ^ (", formnumb(coefs[[2]], selfRound=TRUE), " * x )" ))
  return(form2)
}

Log Transforms:

     y = a * b^x
log(y) = A + B * x

http://msenux.redwoods.edu/math/R/TransformingData.php

When I execute 
  lm( log(y) ~ x )
The relationship I am assuming is: 
   y = a*b^x
But lm gives me the values for 
   log(a) & log(b)

Note:  taking log of both sides of 
   y = a*b^x
log(y) = log(a*b^x) 
       = log(a) + log(b^x) 
       = log(a) + x *log(b) 
       = log(a) + log(b) * x
Thus
log(y) = log(a) + log(b) * x

Working backwards, if we have:
log(y) = A + B*x
Then, we can solve for y as follows
10^log(y) = 10^(A + B*x)        ## REMEMBER:  e^..  NOT 10^ 
   y      = 10^(A + B*x)
   y      = 10^A * 10^(B*x)

y.calc.exp <- function(x, coefs) 
  exp(coefs[[2]]*x + coefs[["(Intercept)"]])

Look at : 
  
  x <- seq(2, 7, by=0.5)
  y <- 3 * 2^x

  lin.mod <- lm( log(y) ~ x )
  coef(lin.mod)
  # (Intercept)           x 
  #    1.098612    0.693147 
  c(log(3),  log(2) )
  # [1] 1.098612 0.693147
  
================================================

http://davegiles.blogspot.com/2011/03/dummies-for-dummies.html

With Dummy Varibales: 

The Cliffs Notes version is that for a model like
ln(Y)=a+b⋅ln(X)+c⋅D+ε,
where X is a continuous regressor, and D is a zero-one dummy variable.

If D switches from 0 to 1, the % impact of D on Y is 100⋅(exp(c)−1).
If D switches from 1 to 0, the % impact of D on Y is 100⋅(exp(−c)−1).


================================================

library(ggplot2)
library(scales)
library(RColorBrewer)

## Add Dummy Variable
DB.using.agg[mkt_priority %in% c("A", "B") , dmkt := ifelse(mkt_priority=="A", 1, 0)]

## Basic Linear model
M <- DB.using.agg[weeks=="total" & mkt_priority!="C"][!is.na(impr1k), lm(total.count.by.upc ~ impr1k + dmkt) ]

outlierMin <- 3e5
## Basic Linear Model, NO OUTLIERS
M.o <- DB.using.agg[weeks=="total" & mkt_priority!="C" & total.count.by.upc < outlierMin][!is.na(impr1k), lm(total.count.by.upc ~ impr1k + dmkt) ]

coef.dts <- data.table(rbind(coef(M), coef(M.o)))
coef.dts <- cbind(coef.dts, CJ(P=c("A", "B"), M=c("All", "No Outlier")))
coef.dts[, I := `(Intercept)` + ifelse(P=="A", dmkt, 0)]
coef.dts[, S := impr1k]
coef.dts[, Group := paste0(M, " - ", P)]
# coef.dts[, Group := factor(Group, levels=Group[order(M)]) ]
coef.dts <- coef.dts[, list(Group, I, S)]

colors.b <-colorRampPalette(brewer.pal(7,"Blues"))(4)[-c(1)]
colors.r <-colorRampPalette(brewer.pal(7,"Reds"))(5)[-c(1, 5)]
colors <- c(colors.b, colors.r)[c(1,3,6,4,2,5)]
ggplot() +  geom_point(aes(x=impr1k, y=total.count.by.upc), alpha=0.5, shape=4, size=2.6, data=DB.using.agg[weeks=="total" & mkt_priority!="C" & !is.na(impr1k) & total.count.by.upc > outlierMin]) + geom_point(aes(x=impr1k, y=total.count.by.upc, color=mkt_priority), data=DB.using.agg[weeks=="total" & mkt_priority!="C" & !is.na(impr1k)]) +  geom_abline(aes(intercept=I, slope=S, color=Group), data=coef.dts) + scale_y_continuous(labels=comma) + scale_color_manual(values=colors, breaks=c("A", "B", "All - A", "All - B", "No Outlier - A", "No Outlier - B")) + labs(x="Impressions (in 1,000's')", y="Total Streams\n(outliers marked with x)", title="First Six Weeks of Release\n(Assuming same intercept for A & B's)") # + scale_x_log10(labels=comma, limits=c(1e2, 1e4))

------

filter <- DB.using.agg[, weeks=="total" & mkt_priority!="C" & !is.na(impr1k) & total.count.by.upc > 0]
M.exp <- DB.using.agg[filter, lm(log(total.count.by.upc) ~ impr1k + dmkt) ]
summary(M.exp)


filter <- DB.using.agg[, weeks=="total" & mkt_priority!="C" & !is.na(impr1k) & total.count.by.upc > 0]
M.pow <- DB.using.agg[filter, lm(log(total.count.by.upc) ~ log(impr1k) + dmkt) ]
summary(M.pow)

-------

M.pow.A <- DB.using.agg[filter][dmkt==1, lm(log(total.count.by.upc) ~ log(impr1k))]
M.pow.B <- DB.using.agg[filter][dmkt==0, lm(log(total.count.by.upc) ~ log(impr1k))]
summary(M.pow.A)
summary(M.pow.B)

-------

filter <- filter.bak
filter <- DB.using.agg[, filter & impr1k < 1500]
M.exp.A <- DB.using.agg[filter][dmkt==1, lm(log(total.count.by.upc) ~ impr1k)]
M.exp.B <- DB.using.agg[filter][dmkt==0, lm(log(total.count.by.upc) ~ impr1k)]
summary(M.exp.A)
summary(M.exp.B)

y.calc.exp <- function(x, coefs) 
  exp(coefs[[2]]*x + coefs[["(Intercept)"]])



yrange <- DB.using.agg[filter & total.count.by.upc >0, range(total.count.by.upc)]
xrange <- DB.using.agg[filter & impr1k >0, range(impr1k)]
xvals <- seq(from=xrange[[1]], to=xrange[[2]], length.out=25)
yvals.A <- y.calc.exp(xvals, coef(M.exp.A))
yvals.B <- y.calc.exp(xvals, coef(M.exp.B))
regr.data.exp <- data.table(x=c(xvals, xvals), y=c(yvals.A, yvals.B), Group=rep(c("A", "B"), each=length(xvals)))
regr.data.exp <- regr.data.exp[y < max(yrange) & x < max(xrange)]

ggplot() + geom_point(aes(x=impr1k, y=total.count.by.upc, color=mkt_priority), data=DB.using.agg[filter]) +  geom_line(aes(x=x, y=y, color=Group), data=regr.data.exp)  + labs(x="Impressions (in 1,000's')", y="Total Streams\n(outliers marked with x)", title="First Six Weeks of Release\n(Assuming same intercept for A & B's)") + scale_y_log10(labels=comma) #, limits=c(1e2, 1e4))

+ scale_color_manual(values=colors, breaks=c("A", "B", "All - A", "All - B", "No Outlier - A", "No Outlier - B"))

geom_abline(aes(intercept=I, slope=S, color=M), data=coef.exp) +