Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem with @ndoogan's answer is that logarithm is not a linear transformation. Which means that E[exp(y)] != exp(E[y]). <a href="http://en.wikipedia.org/wiki/Jensen%27s_inequality">Jensen's inequality</a> gives actually that E[exp(y)] >= exp(E[y]). Here's a simple demonstration:</p> <pre><code>set.seed(1) x&lt;-rnorm(1000) mean(exp(x)) [1] 1.685356 exp(mean(x)) [1] 0.9884194 </code></pre> <p>Here's a case concerning the prediction:</p> <pre><code># Simulate AR(1) process set.seed(1) y&lt;-10+arima.sim(model=list(ar=0.9),n=100) # Fit on logarithmic scale fit&lt;-arima(log(y),c(1,0,0)) #Simulate one step ahead set.seed(123) y_101_log &lt;- fit$coef[2]*(1-fit$coef[1]) + fit$coef[1]*log(y[100]) + rnorm(n=1000,sd=sqrt(fit$sigma2)) y_101&lt;-exp(y_101_log) #transform to natural scale exp(mean(y_101_log)) # This is exp(E(log(y_101))) [1] 5.86717 # Same as exp(predict(fit,n.ahead=1)$pred) # differs bit because simulation mean(y_101) # This is E(exp(log(y_101)))=E(y_101) [1] 5.904633 # 95% Prediction intervals: #Naive way: pred&lt;-predict(fit,n.ahead=1) c(exp(pred$pred-1.96*pred$se),exp(pred$pred+1.96*pred$se)) pred$pred pred$pred 4.762880 7.268523 # Correct ones: quantile(y_101,probs=c(0.025,0.975)) 2.5% 97.5% 4.772363 7.329826 </code></pre> <p>This also provides a solution to your problem in general sense:</p> <ol> <li>Fit your model</li> <li>Simulate multiple samples from that model (for example one step ahead predictions as above)</li> <li>For each simulated sample, make the inverse transformation to get the values in original scale</li> <li>From these simulated samples you can compute the expected value as a ordinary mean, or if you need confidence intervals, compute empirical quantiles.</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload