title: How to add_regressor when forecasting multiple timeseries with Prophet using R?
body: <p>I am using Prophet for a multi-channel leads forecast. I've been able to make the prediction using the method described by @RLave in this post <a href="https://stackoverflow.com/questions/52070501/prophet-forecasting-using-r-for-multiple-items">Prophet Forecasting using R for multiple items</a>. I would like to add regressors to my forecast. Below is the example given by @RLave along with an example of how I have tried to add regressor and the results. How do I make add_regressor work with my leads list?</p>
  <pre><code># also contains the purrr package
  library(tidyverse) 
  set.seed(123)
  
  tb1 &lt;- tibble(
    ds = seq(as.Date(&quot;2018-01-01&quot;), as.Date(&quot;2018-12-31&quot;), by = &quot;day&quot;),
    y = sample(365)
    regressor = rnorm(365, mean = 0, sd = 1)
  )
  
  tb2 &lt;- tibble(
    ds = seq(as.Date(&quot;2018-01-01&quot;), as.Date(&quot;2018-12-31&quot;), by = &quot;day&quot;),
    y = sample(365)
    regressor = rnorm(365, mean = 0, sd = 1)
  )
  
  # two separate time series
  ts_list &lt;- list(tb1, tb2) 
  </code></pre>
  <p><strong>Build and prediction</strong>:</p>
  <pre><code>library(prophet)
  
  # prophet call
  m_list &lt;- map(ts_list, prophet) 
  
  # makes future obs
  future_list &lt;- map(m_list, make_future_dataframe, periods = 40) 
  
  # map2 because we have two inputs
  forecast_list &lt;- map2(m_list, future_list, predict) 
  </code></pre>
  <p><strong>Attempt to Add Regressor</strong></p>
  <pre><code>m &lt;- prophet()
  m &lt;- add_regressor(m, &quot;regressor&quot;)
  
  # prophet call
  m_list2 &lt;- map2(m, ts_list, fit.prophet ) 
  </code></pre>
  <blockquote>
  <p>Error: Mapped vectors must have consistent lengths:<br />
  <code>.x</code> has length 31<br />
  <code>.y</code> has length 14</p>
  </blockquote>