title: How to generate a prediction interval from a regression tree rpart object?
body: <p>How do you generate a prediction interval from a regression tree that is fit using rpart? </p>
  
  <p>It is my understanding that a regression tree models the response conditional on the mean of the leaf nodes. I don't know how to get the variance for a leaf node from the model, but what I would like to do is simulate using the mean and variance for a leaf node to obtain a prediction interval.</p>
  
  <p><a href="http://cran.r-project.org/web/packages/rpart/vignettes/longintro.pdf" rel="noreferrer">Predict.rpart()</a> doesn't give an option for interval. </p>
  
  <p><strong>Example:</strong> I fit a tree with iris data, but predict doesn't have an option, "interval"</p>
  
  <pre><code>&gt; r1 &lt;- rpart(Sepal.Length ~ ., cp = 0.001, data = iris[1:nrow(iris)-1,])
  &gt; predict(r1,newdata=iris[nrow(iris),],type = "interval")
  Error in match.arg(type) : 
    'arg' should be one of “vector”, “prob”, “class”, “matrix”
  </code></pre>