# Prior to the tutorial make sure that the script below runs without error on your R installation. | |
# You first need to install the follwoing packages: | |
# install.packages(c("rstanarm", "prophet", "CausalImpact")) | |
library(rstanarm) | |
library(prophet) | |
library(CausalImpact) | |
# This will test that rstanarm works | |
# Don't be alarmed if you get a warning about "divergent transitions " | |
fit <- stan_lm(mpg ~ wt + qsec + am, data = mtcars, prior = R2(0.75)) | |
plot(fit, prob = 0.8) | |
# This tests that prophet is working | |
history <- data.frame(ds = seq(as.Date('2015-01-01'), as.Date('2016-01-01'), by = 'd'), | |
y = sin(1:366/200) + rnorm(366)/10) | |
m <- prophet(history) | |
future <- make_future_dataframe(m, periods = 365) | |
forecast <- predict(m, future) | |
plot(m, forecast) | |
# This tests that CausalImpact is working | |
# First simulating some data | |
x1 <- 100 + arima.sim(model = list(ar = 0.999), n = 52) | |
y <- 1.2 * x1 + rnorm(52) | |
y[41:52] <- y[41:52] + 10 | |
data <- cbind(y, x1) | |
pre.period <- c(1, 40) | |
post.period <- c(41, 52) | |
# Then running CausalImpact | |
impact <- CausalImpact(data, pre.period, post.period) | |
plot(impact) |
This comment has been minimized.
This comment has been minimized.
What error do you get and what platform are you on? Could you perhaps paste in the whole error message as a reply? /Rasmus |
This comment has been minimized.
This comment has been minimized.
Here is the error message I got:
|
This comment has been minimized.
This comment has been minimized.
You are trying to install prophet "from source" which means you need to be able to compile it which requires you to install some stuff firsts (see here: https://support.rstudio.com/hc/en-us/articles/200486498-Package-Development-Prerequisites) . However, when installing I believe you should be given the option to install an older version that is pre-compiled, that is completely fine, and I would go with that option if I were you. :) Let me know how things works out for you! |
This comment has been minimized.
This comment has been minimized.
Thank you! All works out! |
This comment has been minimized.
This comment has been minimized.
I am having trouble to install "prophet". I also tried to installed Xcode, but am not sure whether that was necessary and I was not able to ** package 'prophet' successfully unpacked and MD5 sums checked
Do you have a solution? |
This comment has been minimized.
This comment has been minimized.
Hi @erikgiltay, install.packages("StanHeaders") Otherwise, do you get the option of installing an older version of prophet when you try to intall that does not require compilation from source? Then go for that option! :) /Rasmus |
This comment has been minimized.
This comment has been minimized.
Hi rasmus, I was unable to install package prophet, I also click on the link you shared to get support to install the package. Below is the message I got
|
This comment has been minimized.
This comment has been minimized.
Hi yaoGithub2018 Please how did you go about the instillation? Kindly help out Thanks Please, |
This comment has been minimized.
This comment has been minimized.
Hi all, I have some problems installing When I run
I have tried running I am running R from RStudio, and I have the following system:
Any ideas on what the problem can be? (Installing the other packages worked fine for me). Best, |
This comment has been minimized.
This comment has been minimized.
It seems like it's not /Rasmus |
This comment has been minimized.
This comment has been minimized.
@rasmusab Thanks for your comments! I finally got |
This comment has been minimized.
This comment has been minimized.
@rasmusab Is this the expected output? There is some output regarding "Disabling yearly seasonality." and warnings regarding "Removed 52 rows containing missing values (geom_path)."
|
This comment has been minimized.
This comment has been minimized.
Yeah, that should be fine. As long as it runs! :)
/R
On Thu, 4 Jul 2019 at 13:28, Johan Rex ***@***.***> wrote:
@rasmusab <https://github.com/rasmusab> Is this the expected output?
There is some output regarding "Disabling yearly seasonality." and warnings
regarding "Removed 52 rows containing missing values (geom_path)."
`
library(rstanarm) > library(prophet) > library(CausalImpact) > > # This
will test that rstanarm works > # Don't be alarmed if you get a warning
about "divergent transitions " > fit <- stan_lm(mpg ~ wt + qsec + am, data
= mtcars, prior = R2(0.75)) SAMPLING FOR MODEL 'lm' NOW (CHAIN 1). Chain 1:
Chain 1: Gradient evaluation took 0 seconds Chain 1: 1000 transitions using
10 leapfrog steps per transition would take 0 seconds. Chain 1: Adjust your
expectations accordingly! Chain 1: Chain 1: Chain 1: Iteration: 1 / 2000 [
0%] (Warmup) Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup) Chain 1:
Iteration: 400 / 2000 [ 20%] (Warmup) Chain 1: Iteration: 600 / 2000 [ 30%]
(Warmup) Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup) Chain 1: Iteration:
1000 / 2000 [ 50%] (Warmup) Chain 1: Iteration: 1001 / 2000 [ 50%]
(Sampling) Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling) Chain 1:
Iteration: 1400 / 2000 [ 70%] (Sampling) Chain 1: Iteration: 1600 / 2000 [
80%] (Sampling) Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling) Chain 1:
Iteration: 2000 / 2000 [100%] (Sampling) Chain 1: Chain 1: Elapsed Time:
3.998 seconds (Warm-up) Chain 1: 2.404 seconds (Sampling) Chain 1: 6.402
seconds (Total) Chain 1: SAMPLING FOR MODEL 'lm' NOW (CHAIN 2). Chain 2:
Chain 2: Gradient evaluation took 0 seconds Chain 2: 1000 transitions using
10 leapfrog steps per transition would take 0 seconds. Chain 2: Adjust your
expectations accordingly! Chain 2: Chain 2: Chain 2: Iteration: 1 / 2000 [
0%] (Warmup) Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup) Chain 2:
Iteration: 400 / 2000 [ 20%] (Warmup) Chain 2: Iteration: 600 / 2000 [ 30%]
(Warmup) Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup) Chain 2: Iteration:
1000 / 2000 [ 50%] (Warmup) Chain 2: Iteration: 1001 / 2000 [ 50%]
(Sampling) Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling) Chain 2:
Iteration: 1400 / 2000 [ 70%] (Sampling) Chain 2: Iteration: 1600 / 2000 [
80%] (Sampling) Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling) Chain 2:
Iteration: 2000 / 2000 [100%] (Sampling) Chain 2: Chain 2: Elapsed Time:
4.17 seconds (Warm-up) Chain 2: 5.554 seconds (Sampling) Chain 2: 9.724
seconds (Total) Chain 2: SAMPLING FOR MODEL 'lm' NOW (CHAIN 3). Chain 3:
Chain 3: Gradient evaluation took 0 seconds Chain 3: 1000 transitions using
10 leapfrog steps per transition would take 0 seconds. Chain 3: Adjust your
expectations accordingly! Chain 3: Chain 3: Chain 3: Iteration: 1 / 2000 [
0%] (Warmup) Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup) Chain 3:
Iteration: 400 / 2000 [ 20%] (Warmup) Chain 3: Iteration: 600 / 2000 [ 30%]
(Warmup) Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup) Chain 3: Iteration:
1000 / 2000 [ 50%] (Warmup) Chain 3: Iteration: 1001 / 2000 [ 50%]
(Sampling) Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling) Chain 3:
Iteration: 1400 / 2000 [ 70%] (Sampling) Chain 3: Iteration: 1600 / 2000 [
80%] (Sampling) Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling) Chain 3:
Iteration: 2000 / 2000 [100%] (Sampling) Chain 3: Chain 3: Elapsed Time:
3.83 seconds (Warm-up) Chain 3: 2.556 seconds (Sampling) Chain 3: 6.386
seconds (Total) Chain 3: SAMPLING FOR MODEL 'lm' NOW (CHAIN 4). Chain 4:
Chain 4: Gradient evaluation took 0 seconds Chain 4: 1000 transitions using
10 leapfrog steps per transition would take 0 seconds. Chain 4: Adjust your
expectations accordingly! Chain 4: Chain 4: Chain 4: Iteration: 1 / 2000 [
0%] (Warmup) Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup) Chain 4:
Iteration: 400 / 2000 [ 20%] (Warmup) Chain 4: Iteration: 600 / 2000 [ 30%]
(Warmup) Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup) Chain 4: Iteration:
1000 / 2000 [ 50%] (Warmup) Chain 4: Iteration: 1001 / 2000 [ 50%]
(Sampling) Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling) Chain 4:
Iteration: 1400 / 2000 [ 70%] (Sampling) Chain 4: Iteration: 1600 / 2000 [
80%] (Sampling) Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling) Chain 4:
Iteration: 2000 / 2000 [100%] (Sampling) Chain 4: Chain 4: Elapsed Time: 4
seconds (Warm-up) Chain 4: 5.935 seconds (Sampling) Chain 4: 9.935 seconds
(Total) Chain 4: Warning messages: 1: There were 13 divergent transitions
after warmup. Increasing adapt_delta above 0.99 may help. See
http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
2: Examine the pairs() plot to diagnose sampling problems > plot(fit, prob
= 0.8) > > # This tests that prophet is working > history <- data.frame(ds
= seq(as.Date('2015-01-01'), as.Date('2016-01-01'), by = 'd'), + y =
sin(1:366/200) + rnorm(366)/10) > m <- prophet(history) Disabling yearly
seasonality. Run prophet with yearly.seasonality=TRUE to override this.
Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to
override this. > future <- make_future_dataframe(m, periods = 365) >
forecast <- predict(m, future) > plot(m, forecast) > > # This tests that
CausalImpact is working > # First simulating some data > x1 <- 100 +
arima.sim(model = list(ar = 0.999), n = 52) > y <- 1.2 * x1 + rnorm(52) >
y[41:52] <- y[41:52] + 10 > data <- cbind(y, x1) > pre.period <- c(1, 40) >
post.period <- c(41, 52) > # Then running CausalImpact > impact <-
CausalImpact(data, pre.period, post.period) > plot(impact) Warning
messages: 1: Removed 52 rows containing missing values (geom_path). 2:
Removed 104 rows containing missing values (geom_path).
--
| >
`
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://gist.github.com/cd84b63d13c8280ec91cdf576c8a0f52?email_source=notifications&email_token=AAHVUQFFGPKBXASFEUXDML3P5XNHLA5CNFSM4HOEUWY2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFUY4S#gistcomment-2961865>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAHVUQFU4K3IHGPLMY2T2JTP5XNHLANCNFSM4HOEUWYQ>
.
--
/Rasmus
|
This comment has been minimized.
This comment has been minimized.
Thank you Rasmus, my script is working with graphs plotting fine but i understand what am running can you please explain what we are trying to achieve even if there is a document to study. |
This comment has been minimized.
This comment has been minimized.
@serifatf The only purpose of this script is to see if you have correctly installed the three packages, nothing else :) |
This comment has been minimized.
Having some trouble with the installation of CausalImpact. Boom and BoomSpikeSlab are installed and running but I simply can't make bsts to install, and CausalImpact depends on it. Any new resources? I've seen some discussion about the issue for Windows users, but nothing really for Linux users...