# inconsistent randomForest() results in R

I am running randomForest() to fit and evaluate models using randomForest R package. The R-squared values provided by the model do not match the observed relationship between y and predicted, and if I call predict(model, x) on the training data, that provides yet another correlation/R-squared between predicted and observed values.

Here's a minimal working example.

data(iris)
model <- randomForest(Sepal.Width~., data=iris[1:4], ntree=500)
model$$rsq[500] #.5447001 #line3 model$$rsq[500]^.5 #.738038 #line4
cor(model$$y, model$$predicted) #.7391252 #line5

#generate predictions from model on training data
preds <- predict(model, newdata=iris[1:4])
#correlate predictions with observed values