title: How to plot the standard error of linear combination of two variables in Stata
body: <p>I am trying to plot the 95% CI of a spline function in Stata. I can easily plot the fitted values, but am not sure how to calculate the SE here. Can someone please help?</p>
  
  <pre><code>sysuse auto.dta, clear
  
  centile weight, centile(10 50 90)
  
  calcspl weight, nknots(3) knotsat(r(c_1) r(c_2) r(c_3))
  </code></pre>
  
  <p>Or you could use another spline program, for example <code>mkspline</code> which will give you three covariates to include in the model, <code>weight1</code>, <code>weight2</code> and <code>weight3</code></p>
  
  <pre><code>mkspline weight 3 = weight, pctile
  </code></pre>
  
  <p>This example is using the <code>calcspl</code> spline generation</p>
  
  <pre><code>regress mpg weight weight_1 foreign price
  
  gen yfit = _b[weight]*weight + _b[weight_1]*weight_1
  
  sort weight
  
  twoway line yfit weight
  </code></pre>
  
  <p>Note that splines give you non integer values, so you can't use the margins command, and I have other covariates in my model, so I can't use the normal post estimation commands. </p>