[R] Modifying the design matrix X in GAMS to suit data assimilation
s.wood at bath.ac.uk
Thu Jul 12 13:59:11 CEST 2012
I think that this should be possible. If your integration allows you to
express the salinity as a weighted sum of evaluated values of the
spatial smooth function (where the weights are known), then you could
use the summation convention for smooths described in
If that is not possible, then it is possible to use mgcv to set up a
smoothing basis in at least 2 ways.
i) You can use the ?smooth.construct functions, to set up model matrices
and penalties, or
ii) You can set up, but not fit, a GAM model using gam(...,fit=FALSE)
Once you have rolled your own model matrix, you can either modify what
was returned by option ii) and get `gam' to proceed with fitting, or use
the paraPen argument to `gam' to fit a model with your model matrix,
penalized according to the contents of `paraPen' (?gam.models has some
example code using paraPen).
On 11/07/12 15:56, Ateljevich, Eli wrote:
> I have a data assimilation problem that might be amenable to the use of GAMS, but I am not sure how feasible it is to implement. I was told the R mailing list was a great resource.
> My observations are spatiotemporal salinity in the San Francisco Bay at a number of instruments over a few days. The thing that I want to fit is the initial condition for a salt transport model at the beginning of this time period. The spline basis functions, parameters and curvature penalties would all be purely spatial, though the cross-validation would be in the space of the data.
> The modification I need to make is as follows:
> 1. evaluate each spatial basis function at every computational point in my mesh (dense, but not part of the GAM)
> 2. use the bases members as individual initial conditions and integrate the PDE.
> 3. evaluate the salinity results at the (sparse) time and locations where I have observations.
> 4. construct a replacement model matrix X that reflects the influence at (x,t) of each spatial basis member. Summing these will works due to the linearity of the PDE.
> 5. The curvature penalty would remain in the spatial, not the spatio-temporal, space.
> My concerns are: whether, say with mgcv, I can halt the process (probably set "fit" to false) and then evaluate at a large number of arbitrary points, then replace the matrix X and continue on. I am also concerned whether this is hopeless in the sense that at the point in the algorithm where I might inject the new X precalculations might have been made using the old matrix X that would be hard to reverse.
> Can anyone give me some advice how to do this?
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
+44 (0)1225 386603 http://people.bath.ac.uk/sw283
More information about the R-help