[R] setting constraints on gam

Alejandra Martínez Blancas alemtzb at ciencias.unam.mx
Thu Jan 11 23:33:42 CET 2018


I am fitting a model in which the response variable y is a function of
two independent, quantitative variables x1 and x2; thus: y = f(x1,
x2). For reasons I do not believe to be important for the purpose of
this post, I find it desirable to find f by means of GAM; also, I
require principal effects and interactions to be specified separately,
so I am using using te and ti tensors. Thus, I am using the following
command:



f = gam(y ~ te(x1) + te(x2) + ti(x1, x2))



This results in a model that corresponds to one of the hypotheses I am
testing. Nevertheless, another hypothesis requires that, when one of
the independent variables (say x2) is zero, the value of y is
unaffected by the other variable (in this example x1). In other words
f(x1, 0) = k for every value of x1, where k is a constant to be
estimated. For x2 values other than zero I would like to let GAM
choose the appropriate function relating x1 and y. Is there a way to
specify such model in mgcv?



More information about the R-help mailing list