[R] GAMM - error when using spline smoother, only allowed to use tensor product

Hannah Linder hlinder33 at gmail.com
Fri Jun 12 00:05:37 CEST 2015


Hello,

I am familiar with the basics of statistical regression models, including
GAMs, but I am stumped on a particular implementation issue.

I am constructing a GAMM to fit to data that is autocorrelated. On of my
covariates (covariate "4") is a sin function the represents time of day. It
is simply: sin.t <- sin(2*pi*seq(TT)/12), in this case TT is equal to my
number of data points, which is 336.

When I initially created a gamm model for my data, the equation looked as
shown:

gam=gamm(data1~s(covariates[1,],bs="cc")+s(covariates[3,],bs="cs")+s(covariates[4,],bs="cc"),family=gaussian(),correlation
= corARMA(p=2,q=0))

Note: Covariate "1" is a Julian day count, and covariate "3" is tidal range.

No matter how I change anything else about the equation, unless I change
the smoother to a tensor product for covariate 4 (i.e.,
te(covariates[4,])), I receive the following error:

Error in na.fail.default(list(Xr.1 = c(-0.00539071823269798,
0.00735538093451461,  :
  missing values in object
In addition: Warning message:
In sqrt(D) : NaNs produced

Does anyone know what may be going on? In addition, my data fit is much
better when I don't treat the sin covariate as cyclic, but that doesn't
seem appropriate to me, because a sin is naturally cyclic.

Any help is much appreciate, thank-you for your time!

Hannah

	[[alternative HTML version deleted]]



More information about the R-help mailing list