The mgcv error comes from the factor that you are specifying the "interactions" between the spatial smooth and variables income
and housing
. Read ?gam.models
for details on using by
terms. I think for this you need
col.gam <- gam(crime ~s(x,y, k = 5) + s(x,y, by = income, k = 5) +
s(x,y, by = housing, k = 5), data=columbus)
In this example, as there are only 49 observations, you need to restrict the dimensions of the basis functions, which I do here with k = 5
, but you should investigate whether you need to vary these a little, within the constraints of the data.
By the looks of the error from bayesx
, you have the same issue of specifying the model incorrectly. I'm not familiar with bayesx()
, but it looks like it uses the same s()
function as supplied with mgcv, so the model specification should be the same as I show above.
As for 2. can you expand on what you mean here Comparable getween gam()
and bayesx()
or getting both or one of these comparable with the spgwr()
model?