I have been trying to reconcile R coefficients with actual coefficients for simulated data which follows the equation:
$$
y = \alpha + \beta \cdot f(x) + \epsilon
$$
where $\alpha$ is intercept and $\beta$ is the slope value.
When I fit the GAM model in R using gam(y~s(x), data = data, method = "REML")
from mgcv package, and I print the summary. I only get the intercept value, that is, $\alpha$.
I want to know: how can I obtain the coefficient for $\beta$ which I multiplied with $x$ in the start?
Best Answer
The model you fitted with {mgcv} is
$$ y_i = \alpha + f(x_i) + \varepsilon_i $$
not
$$ y_i = \alpha + \beta \cdot f(x_i) + \varepsilon_i $$
So that makes me a little unsure as to what $\beta$ you want. In the {mgcv} formulation, the smooth function $f$ is parameterised as a penalised spline and represented as a sum of one or more ($K$) basis functions, each of which has a coefficient $\beta_k$
$$ f(x_i) = \sum_{k=1}^{K} \beta_k b_k(x_i) $$
Hence, if you want those $\beta_k$, use the
coef()
methodThe last line yields: