Post
Topic
Board Economics
Re: Monthly average USD/bitcoin price & trend
by
tonico
on 20/11/2013, 13:11:22 UTC
I'm a R n00b, is this a correct way to get the trendline in R? (just for fun)

Code:
prices <- c(
      0.005,   0.005,   0.005,   0.005,   0.005,   0.005,
      0.005,   0.005,   0.005,   0.005,   0.005,   0.005,
      0.005,   0.005,   0.005,   0.005,   0.005,   0.008,
      0.06,    0.065,   0.062,   0.106,   0.27,    0.24,
      0.39,    0.90,    0.85,    1.50,    6.38,   18.55,
     14.10,    9.75,    5.76,    3.30,    2.60,    3.51,
      6.11,    5.06,    4.88,    4.98,    5.06,    6.03,
      8.04,   10.88,   11.46,   11.58,   11.51,   13.33,
     16.31,   25.93,   58.14,  115.09,  112.81,  108.39,
     83.80,  105.80,  124.33,  156.50
)

months <- 1:length(prices)
result <- lm(log10(prices) ~ months)

plot(months, log10(prices))
abline(result, col="red")

a <- coef(result)[1]
b <- coef(result)[2]
r2 <- summary(result)$r.squared

http://i.imgur.com/DUYs1k8.png