title: How can I calculate Residual Standard Error in R for Test Data set?
body: <p>I have split the Boston dataset into training and test sets as below:</p>
  
  <pre><code>  library(MASS)
    smp_size &lt;- floor(.7 * nrow(Boston))
    set.seed(133)
    train_boston &lt;- sample(seq_len(nrow(Boston)), size = smp_size)
    train_ind &lt;- sample(seq_len(nrow(Boston)), size = smp_size)
    train_boston &lt;- Boston[train_ind, ]
    test_boston &lt;- Boston[-train_ind,]
    nrow(train_boston)
    # [1] 354
    nrow(test_boston)
    # [1] 152
  </code></pre>
  
  <p>Now I get the RSE using lm function as below:</p>
  
  <pre><code>  train_boston.lm &lt;- lm(lstat~medv, train_boston)
    summary(train_boston.lm)
    summary(train_boston.lm)$sigma
  </code></pre>
  
  <p>How can I calculate Residual Standard error for the test data set? I can't use lm function on the test data set. Is there any method to calculate RSE on test data set?</p>