title: How to extract fitted splines from a GAM (`mgcv::gam`)
body: <p>I am using GAM to model time trends in a logistic regression. Yet I would like to extract the the fitted spline from it to add it to another model, that cannot be fitted in GAM or GAMM.</p>
  
  <p>Thus I have 2 questions:</p>
  
  <ol>
  <li><p>How can I fit a smoother over time so that I force one knot to be at a particular location while letting the model to find the other knots?</p></li>
  <li><p>How can I extract the matrix from the fitted GAM so that I can use it in as an impute for a different model?</p></li>
  </ol>
  
  <p>The types of models I am running are to the following form:</p>
  
  <pre><code>gam &lt;- gam(mortality.under.2~ maternal_age_c+ I(maternal_age_c^2)+
             s(birth_year,by=wealth2) + wealth2 + sex +
             residence + maternal_educ + birth_order,
             data=colombia2, family="binomial")
  </code></pre>
  
  <p>I've read the extensive documentation for the GAM but I am not sure still.
  Any suggestion is really appreciated.</p>