I am working with historic nutrient concentration data from a number of monitoring stations along with corresponding historic flows. I am trying to write predictive regression equations for estimating concentrations at stations that are now closed. I have watched a number of tutorials on the MGCV package and have decided that markov random fields would be appropriate for what I am doing. I was not sure how to select certain parameters to build a regression from a larger data frame, so I have tailored data frames to only contain the information needed for each stations regression. Here is an example for Station C9:
Station, Date.x, Month, Year, Day, TP, SWP, CVP
D19, 1975-1-07, 1, 1975, 7, 0.1, 3593, 1071
C9, 1975-1-22, 1, 1975, 22, 0.16, 1914, 3483
D28A, 1975-02-03, 2, 1975, 3, 0.11, 2360, 4506
This is a large Data set that spans for several years...
I attempted to write my regression using the following code:
TP_C9 <- gam(TP ~ s(Date.x)+s(Station,bs="mrf",xt=list(nb=nb))+s(SWP)+s(CVP),data=C9_TP_reg)
I got this error:
Error in names(dat) <- object$term : 'names' attribute  must be the same length as the vector 
If anyone can help me I would be very thankful. I have spent hours watching tutorials on the MGCV package and can't get this to work.
I am assuming that if I just fit for all stations I can rework the equation and solve for C9 to estimate future concentrations...