I have a GAM and I want to make an Excel-based calculator to give the predicted value. I have done this for GLMs in the past as: $$\Large \textrm{Predicted value} = e^{\left(\beta_0 + \beta_1 x_1 + \beta_2 x_2 + \ldots\right) }$$ How does this work with a GAM? How do you plug in the smoothing component?

• Whats the problem? It works exactly like for a glm, maybe your problem is that you will need to implement the smooth part (usually a spline) in excel ... – kjetil b halvorsen Feb 14 '17 at 11:17
• I can't plug in the parameter estimates to give the correct predicted value as shown in my SAS output. I thought it was: predicted value = exp(intercept + B1X1 + smoothing parameter), but that doesn't work. – DC2 Feb 14 '17 at 11:29
• The smoothing term is a function, say $s(x)$, so you need to program that function $s$. That function is often represented by a spline. – kjetil b halvorsen Feb 14 '17 at 12:21

To calculate predicted values for future cases you do basically as with a glm. But, you need to understand that the "smooth" term do not have only a coefficient (that is, a number), but it is a function of the explanatory variable, say, $s(x)$. That function is often (but not always) represented as a spline function. If you do not know what that is, you can find some good explanations in this post: Interpreting spline results

So you need to program that spline function in excel (I don't know what exists in excel about splines), lets say the estimated function is $\hat{s}(x)$ and then evaluate it by plugging in your value of $x$. If this looks complicated, a good alternative is to use a glm with spline basis functions. You can find suitable functions in the package obtained by library(splines), look at its documentation.

That will give results similar to the gam, but the treatment to calculate predictions in excel will be exactly the same as with other glm's.

The general form is $g(\mu) = \mathbf{W'\theta} + \mathcal{F}(\mathbf{X}) + \epsilon$ where $\mu$ is the mean of $y$, $\mathbf{W}$ are variables associated with linear slope coefficients and $\mathbf{X}$ is a matrix of variables represented nonparametrically. The function $\mathcal{F}(.)$ is commonly a sum of univariate smooth terms, but can also include smooth functions of more than one variable.

These smooth functions are typically represented by penalized splines; specifying $\mathcal{F}(.)$ terms using some spline basis $b$ such that $$f_p(x) = \displaystyle\sum_k^K \gamma_k b_k(x)$$

The coefficients that you'd apply directly are the $\gamma$ in the above. To implement this in excel, you'd need to build some functionality that computes $b(x)$. Once you have that, it's just like a GLM.

Once you have the fitted model, the penalization is no longer important -- the penalization just comes in in the choosing of the $\gamma$.

You'll want to look into the documentation of your software for what the $b(x)$ is. If you're working with thin-plate regression splines like are implemented in mgcv, you might have some trouble implementing it in excel.