Running examples in 'SOP-Ex.R' failed
The error most likely occurred in:

> ### Name: sop
> ### Title: Estimation of generalised additive P-spline regression models
> ###   with overlapping penalties.
> ### Aliases: sop
> ### Keywords: regression
> 
> ### ** Examples
> 
> library(SOP)
> ## An example of use of SOP package with tensor product B-splines in 2D
> # Simulate the data
> set.seed(123)
> n <- 1000
> sigma <- 0.1
> x1 <- runif(n, -1, 1)
> x2 <- runif(n, -1, 1)
> f0 <- function(x1, x2) cos(2*pi*sqrt((x1 - 0.5)^2 + (x2 - 0.5)^2))
> f <- f0(x1, x2)
> y <- f + rnorm(n, 0, sigma)
> 
> dat <- data.frame(x1 = x1, x2 = x2, y = y)
> 
> # Theoretical surface
> np <- 50
> x1p <- seq(-1, 1, length = np)  
> x2p <- seq(-1, 1, length = np)
> fp <- cos(2 * pi * sqrt(outer((x1p - 0.5) ^ 2, (x2p - 0.5) ^ 2, '+')))
> 
> image(x1p, x2p, matrix(fp, np, np), main = 'f(x1,x2) - Theor', 
+      col = topo.colors(100))
> 
> # Fit the model
> m0 <- sop(formula = y ~ f(x1, x2, nseg = 10), data = dat, 
+         control = list(trace = FALSE))
> 
> summary(m0)

Family: gaussian 
Link function: identity 


Formula:
sop(formula = y ~ f(x1, x2, nseg = 10), data = dat, control = list(trace = FALSE))


Fixed terms: 
(Intercept)          x1          x2        x2x1 
 -0.1443795  -1.4984684  -1.2584771   2.8554254 


Estimated degrees of freedom:
f(x1,x2)|x1 f(x1,x2)|x2   Total edf       Total 
    50.8501     52.2210    103.0711    107.0711 

R-sq.(adj) =  0.973   Deviance explained = 98.2%  n = 1000
(0 observations deleted due to missingness)

Number of iterations: 1
> plot(m0, col = topo.colors(100))
> 
> ## An example of use of SOP package with several smooth terms and Gamma distribution
> # Simulate the data
> set.seed(123)
> n <- 1000
> alpha <- 0.75
> x0 <- runif(n)
> x1 <- x0*alpha + (1-alpha)*runif(n)
> x2 <- runif(n)
> x3 <- x2*alpha + (1-alpha)*runif(n)
> x4 <- runif(n)
> x5 <- runif(n)
> 
> f0 <- function(x)2*sin(pi*x)
> f1 <- function(x)exp(2*x)
> f2 <- function(x) 0.2*x^11*(10*(1-x))^6+10*(10*x)^3*(1-x)^10
> 
> f <- f0(x0) + f1(x1) + f2(x2)
> y <- rgamma(f,exp(f/4),scale=1.2)
> 
> df <- data.frame(y = y, x0 = x0, x1 = x1, x2 = x2, x3 = x3, x4 = x4, x5 = x5)
> 
> # Fit the model
> m1 <- sop(formula = y ~ f(x0, nseg = 17) + 
+                              f(x1, nseg = 17) + 
+                              f(x2, nseg = 17) + 
+                              f(x3, nseg = 17) + 
+                              f(x4, nseg = 17) + 
+                              f(x5, nseg = 17), family = Gamma(link = log), data = df)
> summary(m1)

Family: Gamma 
Link function: log 


Formula:
sop(formula = y ~ f(x0, nseg = 17) + f(x1, nseg = 17) + f(x2, 
    nseg = 17) + f(x3, nseg = 17) + f(x4, nseg = 17) + f(x5, 
    nseg = 17), data = df, family = Gamma(link = log))


Fixed terms: 
(Intercept)          x0          x1          x2          x3          x4 
 2.10173632  0.20746878 -2.23147696  0.64628614  0.26079104  0.02062742 
         x5 
-0.12841174 


Estimated degrees of freedom:
 f(x0)|x0  f(x1)|x1  f(x2)|x2  f(x3)|x3  f(x4)|x4  f(x5)|x5 Total edf     Total 
   3.1147    3.0595   10.7155    0.1015    0.0000    2.3931   19.3843   26.3843 

R-sq.(adj) =  0.885   Deviance explained = 77.1%  n = 1000
(0 observations deleted due to missingness)

Number of iterations: 4
> plot(m1)
> 
> ## An example of use of SOP package for the analysis of field trials experiments.
> ## Taken from the SpATS package.
> require(SpATS)
Loading required package: SpATS
> data(wheatdata)
> 
> # Create factor variable for row and columns
> wheatdata$R <- as.factor(wheatdata$row)
> wheatdata$C <- as.factor(wheatdata$col)
> 
> # package SOP
> m2 <- sop(formula = yield ~ colcode + rowcode + 
+   f(col, row, nseg = c(10, 10)) + 
+   rae(geno) + rae(R) + rae(C), data = wheatdata)
> summary(m2)

Family: gaussian 
Link function: identity 


Formula:
sop(formula = yield ~ colcode + rowcode + f(col, row, nseg = c(10, 
    10)) + rae(geno) + rae(R) + rae(C), data = wheatdata)


Fixed terms: 
(Intercept)    colcode2    colcode3    colcode4    rowcode2         col 
  503.31387    83.09582    68.27520   140.27198    29.72336  -840.99066 
        row      rowcol 
  323.88177   479.77611 


Estimated degrees of freedom:
          geno              R              C f(col,row)|col f(col,row)|row 
       82.4336         8.2234         6.9429        10.0103         9.1387 
     Total edf          Total 
      116.7489       124.7489 

R-sq.(adj) =   1.48   Deviance explained = 94.8%  n = 330
(0 observations deleted due to missingness)

Number of iterations: 1
> plot(m2, col = topo.colors(100), pages = 1)
> 
> # Package SpATS: more adequate for this analysis.
> # SpATS has been explicitly developed for the analysis field trials experiments. 
> m3 <- SpATS(response = "yield", 
+     spatial = ~ SAP(col, row, nseg = c(10,10), degree = 3, pord = 2, center = TRUE), 
+     genotype = "geno",
+     genotype.as.random = TRUE,
+     fixed = ~ colcode + rowcode, random = ~ R + C, data = wheatdata, 
+     control =  list(tolerance = 1e-06))
Effective dimensions
-------------------------
It.     Deviance        geno           R           Cf(col,row)|colf(col,row)|row
  1 1016752.623395      77.565       1.616       1.015       9.280       9.428
  2  3075.895344      79.028       1.806       4.529       9.887       9.633
  3  3050.314361      80.876       2.534       7.009       9.577       9.812
  4  3048.218796      81.271       3.581       7.279       9.606       9.783
  5  3047.348450      81.476       4.720       7.210       9.731       9.685
  6  3046.779414      81.696       5.774       7.142       9.817       9.573
  7  3046.450993      81.903       6.617       7.093       9.874       9.471
  8  3046.284794      82.074       7.217       7.055       9.913       9.389
  9  3046.207800      82.201       7.609       7.027       9.942       9.326
 10  3046.173342      82.287       7.853       7.006       9.963       9.280
 11  3046.157771      82.344       8.000       6.989       9.978       9.247
 12  3046.150483      82.379       8.088       6.977       9.989       9.222
 13  3046.146923      82.401       8.140       6.968       9.997       9.203
 14  3046.145115      82.414       8.172       6.961      10.002       9.189
 15  3046.144170      82.423       8.191       6.956      10.006       9.178
 16  3046.143665      82.427       8.202       6.953      10.008       9.169
 17  3046.143391      82.430       8.210       6.950      10.010       9.163
 18  3046.143241      82.432       8.214       6.948      10.011       9.158
 19  3046.143158      82.433       8.217       6.946      10.011       9.154
 20  3046.143113      82.434       8.219       6.945      10.012       9.151
 21  3046.143087      82.434       8.221       6.945      10.012       9.148
 22  3046.143073      82.434       8.222       6.944      10.012       9.146
 23  3046.143065      82.435       8.222       6.944      10.012       9.145
 24  3046.143060      82.435       8.223       6.943      10.012       9.144
 25  3046.143058      82.435       8.223       6.943      10.012       9.143
 26  3046.143057      82.435       8.223       6.943      10.012       9.142
 27  3046.143056      82.435       8.224       6.943      10.012       9.142
Timings:
SpATS 0.68 seconds
All process 0.76 seconds
> summary(m3)

Spatial analysis of trials with splines 

Response:                   yield     
Genotypes (as random):      geno      
Spatial:                    ~SAP(col, row, nseg = c(10, 10), degree = 3, pord = 2, center = TRUE)
Fixed:                      ~colcode + rowcode
Random:                     ~R + C    


Number of observations:        330
Number of missing data:        0
Effective dimension:           124.75
Deviance:                      3046.143

Dimensions:
                      Effective     Model     Nominal     Ratio     Type
Intercept                   1.0         1           1      1.00        F
colcode                     3.0         3           3      1.00        F
rowcode                     1.0         1           1      1.00        F
geno                       82.4       107         106      0.78        R
R                           8.2        22          19      0.43        R
C                           6.9        15          10      0.69        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.0        NA          NA        NA        S
f(col,row)|row              9.1        NA          NA        NA        S
f(col,row) Global          19.2       165         165      0.12        S
                                                                        
Total                     124.8       317         308      0.41         
Residual                  205.2                                         
Nobs                        330                                         

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

> plot(m3)
Error in library.dynam(lib, package, package.lib) : 
  DLL 'rlang' not found: maybe not installed for this architecture?
Calls: plot ... loadNamespace -> namespaceImport -> loadNamespace -> library.dynam
Execution halted