title: How to get confidence interval for smooth.spline?
body: <p>I have used <code>smooth.spline</code> to estimate a cubic spline for my data. But when I calculate the 90% point-wise confidence interval using equation, the results seems to be a little bit off. Can someone please tell me if I did it wrongly? I am just wondering if there is a function that can automatically calculate a <strong>point-wise interval band</strong> associated with <code>smooth.spline</code> function. </p>
  
  <pre><code>boneMaleSmooth = smooth.spline( bone[males,"age"], bone[males,"spnbmd"], cv=FALSE)
  error90_male = qnorm(.95)*sd(boneMaleSmooth$x)/sqrt(length(boneMaleSmooth$x))
  
  plot(boneMaleSmooth, ylim=c(-0.5,0.5), col="blue", lwd=3, type="l", xlab="Age", 
       ylab="Relative Change in Spinal BMD")
  points(bone[males,c(2,4)], col="blue", pch=20)
  lines(boneMaleSmooth$x,boneMaleSmooth$y+error90_male, col="purple",lty=3,lwd=3)
  lines(boneMaleSmooth$x,boneMaleSmooth$y-error90_male, col="purple",lty=3,lwd=3)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/BckhF.jpg" alt="enter image description here"></p>
  
  <p>Because I am not sure if I did it correctly, then I used <code>gam()</code> function from <code>mgcv</code> package. </p>
  
  <p>It instantly gave a confidence band but I am not sure if it is 90% or 95% CI or something else. It would be great if someone can explain.</p>
  
  <pre><code>males=gam(bone[males,c(2,4)]$spnbmd ~s(bone[males,c(2,4)]$age), method = "GCV.Cp")
  plot(males,xlab="Age",ylab="Relative Change in Spinal BMD")
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/khiTF.jpg" alt="enter image description here"></p>