SAP: Define a two-dimensional penalised tensor-product of marginal...

Description Usage Arguments Details References See Also Examples

View source: R/SAP.R

Description

Auxiliary function used for modelling the spatial or environmental effect as a two-dimensional penalised tensor-product of marginal B-spline basis functions with anisotropic penalties. The approach implemented here corresponds to the Separation of Anisotropic Penalties (SAP) algorithm introduced by Rodriguez-Alvarez et al. (2015).

Usage

1
2
SAP(..., nseg = c(10,10), pord = c(2,2), degree = c(3,3), nest.div = c(1,1), 
ANOVA = FALSE)

Arguments

...

a list of the covariates that this smooth component is a function of. Currently, only two-dimensional tensor-product smoothers are implemented: the first covariate is assumed to define the x-spatial coordinate (e.g., column position) of each plot in the field, and the second argument the y-spatial coordinate (i.e., the row position). Both covariates should be numerical.

nseg

numerical vector of length 2 containing the number of segments for each marginal (strictly nseg - 1 is the number of internal knots in the domain of the covariate). Atomic values are also valid, being recycled. Default set to 10.

pord

numerical vector of length 2 containing the penalty order for each marginal. Atomic values are also valid, being recycled. Default set to 2 (second order).

degree

numerical vector of length 2 containing the order of the polynomial of the B-spline basis for each marginal. Atomic values are also valid, being recycled. Default set to 3 (cubic B-splines).

nest.div

numerical vector of length 2 containing the divisor of the number of segments (nseg) to be used for the construction of the nested B-spline basis for the smooth-by-smooth interaction component. In this case, the nested B-spline basis will be constructed assuming a total of nseg/nest.div segments. Default set to 1, which implies that nested basis are not used. See details.

ANOVA

logical. If TRUE, four different smoothing parameters are considered: two for the main effects and two for the smooth interaction. See details.

Details

Within the P-spline framework, anisotropic low-rank tensor-product smoothers have become the general approach for modelling multidimensional surfaces (Eilers and Marx 2003; Wood 2006). In this package, we propose to model the spatial or environmental effect by means of the tensor-product of B-splines basis functions. In other words, we propose to model the spatial trend as a smooth bivariate surface jointly defined over the the spatial coordinates. Accordingly, the current function has been designed to allow the user to specify the spatial coordinates that the spatial trend is a function of. There is no restriction about how the spatial coordinates shall be specified: these can be the longitude and latitude of the position of the plot on the field or the column and row numbers. The only restriction is that the variables defining the spatial coordinates should be numeric (in contrast to factors).

As far as estimation is concerned, we have used in this package the equivalence between P-splines and linear mixed models (Currie and Durban, 2002). Under this approach, the smoothing parameters are expressed as the ratio between variance components. Moreover, the smooth components are decomposed in two parts: one which is not penalised (and treated as fixed) and one with is penalised (and treated as random). For the two-dimensional case, the mixed model representation leads also to a very interesting decomposition of the penalised part of the bivariate surface in three different components (Lee and Durban, 2011): (a) a component that contains the smooth main effect (smooth trend) along one of the covariates that the surface is a function of (as, e.g, the x-spatial coordinate or column position of the plot in the field), (b) a component that contains the smooth main effect (smooth trend) along the other covariate (i.e., the y-spatial coordinate or row position); and (c) a smooth interaction component (sum of the linear-by-smooth interaction components and the smooth-by-smooth interaction component). The default implementation used in this function (ANOVA = FALSE) assumes two different smoothing parameters, i.e., one for each covariate in the smooth component. Accordingly, the same smoothing parameters are used for both, the main effects and the smooth interaction. However, this approach can be extended to deal with the ANOVA-type decomposition presented in Lee and Durban (2011). In their approach, four different smoothing parameters are considered for the smooth surface, that are in concordance with the aforementioned decomposition: (a) two smoothing parameter, one for each of the main effects; and (b) two smoothing parameter for the smooth interaction component. Here, this decomposition can be obtained by specifying the argument ANOVA = TRUE.

It should be noted that, the computational burden associated with the estimation of the two-dimensional tensor-product smoother might be prohibitive if the dimension of the marginal bases is large. In these cases, Lee et al. (2013) propose to reduce the computational cost by using nested bases. The idea is to reduce the dimension of the marginal bases (and therefore the associated number of parameters to be estimated), but only for the smooth-by-smooth interaction component. As pointed out by the authors, this simplification can be justified by the fact that the main effects would in fact explain most of the structure (or spatial trend) presented in the data, and so a less rich representation of the smooth-by-smooth interaction component could be needed. In order to ensure that the reduced bivariate surface is in fact nested to the model including only the main effects, Lee et al. (2013) show that the number of segments used for the nested basis should be a divisor of the number of segments used in the original basis (nseg argument). In the present function, the divisor of the number of segments is specified through the argument nest.div. For a more detailed review on this topic, see Lee (2010) and Lee et al. (2013).

References

Currie, I., and Durban, M. (2002). Flexible smoothing with P-splines: a unified approach. Statistical Modelling, 4, 333 - 349.

Eilers, P.H.C., and Marx, B.D. (2003). Multivariate calibration with temperature interaction using two-dimensional penalised signal regression. Chemometrics and Intelligent Laboratory Systems, 66, 159 - 174.

Gilmour, A.R., Cullis, B.R., and Verbyla, A.P. (1997). Accounting for Natural and Extraneous Variation in the Analysis of Field Experiments. Journal of Agricultural, Biological, and Environmental Statistics, 2, 269 - 293.

Lee, D.-J., 2010. Smothing mixed model for spatial and spatio-temporal data. Ph.D. Thesis, Department of Statistics, Universidad Carlos III de Madrid, Spain.

Lee, D.-J., and Durban, M. (2011). P-spline ANOVA-type interaction models for spatio-temporal smoothing. Statistical Modelling 11, 49 - 69.

Lee, D.-J., Durban, M., and Eilers, P.H.C. (2013). Efficient two-dimensional smoothing with P-spline ANOVA mixed models and nested bases. Computational Statistics and Data Analysis, 61, 22 - 37.

Rodriguez-Alvarez, M.X., Lee, D.-J., Kneib, T., Durban, M., and Eilers, P.H.C. (2015). Fast smoothing parameter separation in multidimensional generalized P-splines: the SAP algorithm. Statistics and Computing, 25, 941 - 957.

Wood, S.N. (2006). Low-rank scale-invariant tensor product smooths for generalized additive models. Journal of the Royal Statistical Society: Series B, 70, 495 - 518.

See Also

SpATS, PSANOVA

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
library(SpATS)
data(wheatdata)
wheatdata$R <- as.factor(wheatdata$row)
wheatdata$C <- as.factor(wheatdata$col)

# Original anisotropic approach: two smoothing parameters
m0 <- SpATS(response = "yield", spatial = ~ SAP(col, row, nseg = c(10,20)), 
 genotype = "geno", fixed = ~ colcode + rowcode, random = ~ R + C, 
 data = wheatdata, control =  list(tolerance = 1e-03))
summary(m0)

# ANOVA decomposition: four smoothing parameters
## Not run: 
m1 <- SpATS(response = "yield", spatial = ~ SAP(col, row, nseg = c(10,20), ANOVA = TRUE), 
 genotype = "geno", fixed = ~ colcode + rowcode, random = ~ R + C, data = wheatdata, 
 control =  list(tolerance = 1e-03))
summary(m1)

## End(Not run)

Example output

Effective dimensions
-------------------------
It.     Deviance           R           Cf(col,row)|colf(col,row)|row
  1 686384.843129       1.196       0.962      11.769      15.563
  2  2107.446777       1.234       3.922      12.391      15.060
  3  2079.185180       1.722       6.767      11.306      13.853
  4  2072.650074       2.628       7.316      10.554      12.547
  5  2069.709184       3.827       7.264      10.199      11.474
  6  2067.893125       5.141       7.153      10.046      10.721
  7  2066.842352       6.330       7.061       9.992      10.215
  8  2066.299268       7.234       6.989       9.987       9.886
  9  2066.044505       7.834       6.933      10.006       9.678
 10  2065.929488       8.199       6.889      10.035       9.552
 11  2065.876579       8.411       6.855      10.066       9.477
 12  2065.851059       8.531       6.829      10.095       9.435
 13  2065.838130       8.600       6.809      10.120       9.411
 14  2065.831319       8.639       6.793      10.142       9.400
 15  2065.827632       8.663       6.782      10.160       9.395
 16  2065.825598       8.678       6.773      10.175       9.393
 17  2065.824460       8.688       6.766      10.187       9.394
 18  2065.823818       8.694       6.761      10.196       9.396
Timings:
SpATS 0.728 seconds
All process 1.311 seconds

Spatial analysis of trials with splines 

Response:                   yield     
Genotypes (as fixed):       geno      
Spatial:                    ~SAP(col, row, nseg = c(10, 20))
Fixed:                      ~colcode + rowcode
Random:                     ~R + C    


Number of observations:        330
Number of missing data:        0
Effective dimension:           149.05
Deviance:                      2065.824

Dimensions:
                      Effective     Model     Nominal     Ratio     Type
geno                      106.0       106         106      1.00        F
Intercept                   1.0         1           1      1.00        F
colcode                     3.0         3           3      1.00        F
rowcode                     1.0         1           1      1.00        F
R                           8.7        22          21      0.41        R
C                           6.8        15          14      0.48        R
col                         1.0         1           1      1.00        S
row                         1.0         1           1      1.00        S
rowcol                      1.0         1           1      1.00        S
f(col,row)|col             10.2        NA          NA        NA        S
f(col,row)|row              9.4        NA          NA        NA        S
f(col,row) Global          19.6       295         295      0.07        S
                                                                        
Total                     149.0       446         444      0.34         
Residual                  181.0                                         
Nobs                        330                                         

Type codes: F 'Fixed'    R 'Random'    S 'Smooth/Semiparametric'

Effective dimensions
-------------------------
It.     Deviance           R           C      f(col)      f(row)f(col,row)|colf(col,row)|row
  1 686384.843129       1.196       0.962       2.201       5.158       9.568      10.406
  2  2095.711706       1.217       3.309       3.784       4.479       6.569       7.333
  3  2073.494039       1.634       5.970       3.098       4.101       5.346       5.969
  4  2070.811806       2.312       6.749       2.624       3.740       4.863       5.377
  5  2069.785763       3.175       6.805       2.589       3.335       4.643       5.083
  6  2068.821277       4.179       6.809       2.588       2.892       4.556       4.948
  7  2067.909347       5.237       6.813       2.588       2.430       4.544       4.907
  8  2067.121096       6.238       6.818       2.587       1.976       4.574       4.921
  9  2066.556954       7.081       6.822       2.587       1.579       4.624       4.962
 10  2066.265077       7.702       6.825       2.587       1.296       4.674       5.005
 11  2066.154462       8.105       6.828       2.587       1.138       4.715       5.040
 12  2066.112910       8.347       6.829       2.587       1.060       4.748       5.066
 13  2066.092795       8.489       6.830       2.587       1.022       4.778       5.090
 14  2066.080014       8.571       6.831       2.587       1.003       4.805       5.112
 15  2066.070367       8.618       6.831       2.587       0.992       4.831       5.134
 16  2066.062439       8.646       6.831       2.587       0.986       4.857       5.156
 17  2066.055660       8.663       6.831       2.587       0.982       4.882       5.178
 18  2066.049739       8.674       6.831       2.587       0.979       4.907       5.200
 19  2066.044498       8.682       6.832       2.587       0.977       4.930       5.221
 20  2066.039809       8.688       6.832       2.587       0.975       4.953       5.242
 21  2066.035576       8.692       6.832       2.587       0.973       4.975       5.262
 22  2066.031724       8.696       6.832       2.587       0.972       4.997       5.282
 23  2066.028191       8.699       6.832       2.587       0.970       5.018       5.301
 24  2066.024929       8.702       6.832       2.588       0.969       5.038       5.320
 25  2066.021897       8.705       6.832       2.588       0.968       5.058       5.338
 26  2066.019060       8.707       6.832       2.588       0.966       5.077       5.357
 27  2066.016390       8.710       6.832       2.588       0.965       5.096       5.374
 28  2066.013864       8.712       6.832       2.588       0.964       5.114       5.392
 29  2066.011460       8.714       6.832       2.588       0.963       5.132       5.409
 30  2066.009160       8.717       6.832       2.588       0.961       5.150       5.425
 31  2066.006951       8.719       6.832       2.588       0.960       5.167       5.442
 32  2066.004817       8.721       6.832       2.588       0.959       5.185       5.458
 33  2066.002748       8.723       6.832       2.588       0.958       5.202       5.475
 34  2066.000732       8.725       6.832       2.588       0.956       5.218       5.491
 35  2065.998760       8.727       6.832       2.588       0.955       5.235       5.507
 36  2065.996824       8.729       6.833       2.589       0.954       5.252       5.523
 37  2065.994915       8.730       6.833       2.589       0.953       5.268       5.539
 38  2065.993026       8.732       6.833       2.589       0.952       5.285       5.555
 39  2065.991151       8.734       6.833       2.589       0.950       5.301       5.570
 40  2065.989282       8.736       6.833       2.589       0.949       5.318       5.586
 41  2065.987414       8.738       6.833       2.589       0.948       5.334       5.602
 42  2065.985540       8.740       6.833       2.589       0.946       5.351       5.619
 43  2065.983655       8.741       6.833       2.589       0.945       5.367       5.635
 44  2065.981753       8.743       6.833       2.589       0.944       5.384       5.651
 45  2065.979827       8.745       6.833       2.589       0.943       5.401       5.668
 46  2065.977873       8.747       6.833       2.590       0.941       5.418       5.684
 47  2065.975885       8.749       6.833       2.590       0.940       5.435       5.701
 48  2065.973856       8.751       6.833       2.590       0.938       5.453       5.719
 49  2065.971781       8.753       6.833       2.590       0.937       5.470       5.736
 50  2065.969653       8.754       6.833       2.590       0.935       5.488       5.754
 51  2065.967465       8.756       6.833       2.590       0.934       5.506       5.772
 52  2065.965212       8.758       6.833       2.590       0.932       5.525       5.790
 53  2065.962886       8.760       6.833       2.590       0.931       5.543       5.809
 54  2065.960479       8.762       6.833       2.590       0.929       5.563       5.828
 55  2065.957985       8.764       6.833       2.591       0.927       5.582       5.848
 56  2065.955394       8.767       6.833       2.591       0.926       5.602       5.868
 57  2065.952699       8.769       6.833       2.591       0.924       5.622       5.888
 58  2065.949891       8.771       6.833       2.591       0.922       5.643       5.909
 59  2065.946960       8.773       6.833       2.591       0.920       5.664       5.931
 60  2065.943897       8.776       6.833       2.591       0.918       5.686       5.953
 61  2065.940691       8.778       6.833       2.592       0.916       5.708       5.976
 62  2065.937332       8.780       6.833       2.592       0.914       5.731       5.999
 63  2065.933808       8.783       6.833       2.592       0.912       5.754       6.023
 64  2065.930108       8.786       6.833       2.592       0.910       5.779       6.048
 65  2065.926220       8.788       6.833       2.592       0.907       5.803       6.073
 66  2065.922132       8.791       6.833       2.592       0.905       5.828       6.100
 67  2065.917830       8.794       6.833       2.593       0.902       5.854       6.127
 68  2065.913303       8.797       6.833       2.593       0.900       5.881       6.155
 69  2065.908536       8.800       6.833       2.593       0.897       5.908       6.184
 70  2065.903517       8.803       6.833       2.593       0.894       5.937       6.213
 71  2065.898232       8.807       6.833       2.594       0.891       5.966       6.244
 72  2065.892669       8.810       6.833       2.594       0.888       5.995       6.276
 73  2065.886814       8.814       6.833       2.594       0.885       6.026       6.308
 74  2065.880656       8.817       6.832       2.594       0.882       6.057       6.342
 75  2065.874181       8.821       6.832       2.595       0.878       6.089       6.377
 76  2065.867381       8.825       6.832       2.595       0.875       6.122       6.412
 77  2065.860243       8.830       6.832       2.595       0.871       6.156       6.449
 78  2065.852758       8.834       6.832       2.596       0.867       6.190       6.487
 79  2065.844918       8.839       6.832       2.596       0.863       6.226       6.527
 80  2065.836716       8.844       6.832       2.596       0.859       6.262       6.567
 81  2065.828144       8.849       6.832       2.597       0.855       6.299       6.608
 82  2065.819199       8.854       6.832       2.597       0.850       6.337       6.651
 83  2065.809875       8.859       6.832       2.597       0.846       6.375       6.695
 84  2065.800169       8.865       6.832       2.598       0.841       6.415       6.740
 85  2065.790079       8.871       6.832       2.598       0.836       6.455       6.786
 86  2065.779602       8.877       6.832       2.598       0.831       6.496       6.833
 87  2065.768736       8.884       6.832       2.599       0.825       6.537       6.882
 88  2065.757479       8.891       6.832       2.599       0.820       6.580       6.932
 89  2065.745830       8.898       6.832       2.600       0.814       6.623       6.983
 90  2065.733785       8.906       6.832       2.600       0.808       6.666       7.035
 91  2065.721341       8.913       6.831       2.601       0.802       6.711       7.088
 92  2065.708492       8.922       6.831       2.601       0.796       6.756       7.143
 93  2065.695231       8.930       6.831       2.601       0.789       6.801       7.199
 94  2065.681549       8.939       6.831       2.602       0.782       6.847       7.256
 95  2065.667436       8.949       6.831       2.602       0.776       6.894       7.314
 96  2065.652879       8.958       6.831       2.603       0.768       6.941       7.373
 97  2065.637860       8.968       6.831       2.603       0.761       6.989       7.434
 98  2065.622364       8.979       6.831       2.604       0.753       7.037       7.496
 99  2065.606368       8.990       6.831       2.604       0.746       7.086       7.559
100  2065.589851       9.002       6.831       2.605       0.737       7.135       7.624
101  2065.572790       9.014       6.831       2.605       0.729       7.185       7.690
102  2065.555159       9.027       6.831       2.606       0.721       7.235       7.758
103  2065.536934       9.040       6.831       2.607       0.712       7.286       7.827
104  2065.518092       9.054       6.831       2.607       0.703       7.338       7.898
105  2065.498614       9.068       6.831       2.608       0.693       7.390       7.970
106  2065.478483       9.083       6.831       2.608       0.683       7.442       8.043
107  2065.457694       9.098       6.831       2.609       0.673       7.495       8.119
108  2065.436248       9.115       6.831       2.609       0.663       7.548       8.195
109  2065.414162       9.132       6.831       2.610       0.652       7.601       8.274
110  2065.391469       9.149       6.831       2.611       0.641       7.655       8.353
111  2065.368223       9.167       6.831       2.611       0.630       7.709       8.434
112  2065.344502       9.186       6.831       2.612       0.619       7.762       8.516
113  2065.320412       9.205       6.831       2.612       0.607       7.816       8.599
114  2065.296085       9.225       6.831       2.613       0.595       7.869       8.683
115  2065.271687       9.245       6.831       2.614       0.583       7.922       8.768
116  2065.247407       9.266       6.831       2.614       0.571       7.974       8.853
117  2065.223461       9.287       6.831       2.615       0.558       8.025       8.937
118  2065.200078       9.309       6.831       2.615       0.546       8.074       9.021
119  2065.177496       9.330       6.831       2.616       0.533       8.123       9.104
120  2065.155946       9.352       6.831       2.617       0.521       8.169       9.185
121  2065.135641       9.373       6.831       2.617       0.508       8.214       9.264
122  2065.116765       9.395       6.831       2.618       0.496       8.256       9.341
123  2065.099459       9.415       6.831       2.618       0.484       8.296       9.414
124  2065.083816       9.436       6.831       2.619       0.472       8.334       9.484
125  2065.069876       9.455       6.831       2.619       0.461       8.369       9.551
126  2065.057629       9.474       6.831       2.620       0.450       8.401       9.613
127  2065.047016       9.492       6.831       2.620       0.440       8.431       9.671
128  2065.037943       9.509       6.831       2.620       0.430       8.459       9.725
129  2065.030283       9.525       6.831       2.621       0.421       8.483       9.775
130  2065.023894       9.539       6.831       2.621       0.412       8.506       9.820
131  2065.018625       9.553       6.831       2.621       0.404       8.526       9.861
132  2065.014324       9.566       6.831       2.622       0.396       8.544       9.898
133  2065.010846       9.578       6.831       2.622       0.389       8.560       9.932
134  2065.008057       9.588       6.831       2.622       0.382       8.574       9.962
135  2065.005839       9.598       6.831       2.622       0.376       8.586       9.988
136  2065.004085       9.607       6.831       2.623       0.371       8.597      10.012
137  2065.002708       9.615       6.831       2.623       0.366       8.607      10.033
138  2065.001632       9.622       6.831       2.623       0.361       8.616      10.051
139  2065.000795       9.628       6.831       2.623       0.357       8.623      10.067
Timings:
SpATS 4.308 seconds
All process 4.716 seconds

Spatial analysis of trials with splines 

Response:                   yield     
Genotypes (as fixed):       geno      
Spatial:                    ~SAP(col, row, nseg = c(10, 20), ANOVA = TRUE)
Fixed:                      ~colcode + rowcode
Random:                     ~R + C    


Number of observations:        330
Number of missing data:        0
Effective dimension:           152.13
Deviance:                      2065.001

Dimensions:
                      Effective     Model     Nominal     Ratio     Type
geno                      106.0       106         106      1.00        F
Intercept                   1.0         1           1      1.00        F
colcode                     3.0         3           3      1.00        F
rowcode                     1.0         1           1      1.00        F
R                           9.6        22          21      0.46        R
C                           6.8        15          14      0.49        R
col                         1.0         1           1      1.00        S
row                         1.0         1           1      1.00        S
rowcol                      1.0         1           1      1.00        S
f(col)                      2.6        11          11      0.24        S
f(row)                      0.4        21          21      0.02        S
f(col,row)|col              8.6        NA          NA        NA        S
f(col,row)|row             10.1        NA          NA        NA        S
f(col,row) Global          18.7       263         263      0.07        S
                                                                        
Total                     152.1       446         444      0.34         
Residual                  177.9                                         
Nobs                        330                                         

Type codes: F 'Fixed'    R 'Random'    S 'Smooth/Semiparametric'

SpATS documentation built on March 18, 2018, 2:18 p.m.