Running examples in ‘glmmrBase-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: Model
> ### Title: A GLMM Model
> ### Aliases: Model
> 
> ### ** Examples
> 
> 
> ## ------------------------------------------------
> ## Method `Model$new`
> ## ------------------------------------------------
> 
> ## Don't show: 
> setParallel(FALSE) 
> ## End(Don't show)
> # For more examples, see the examples for MCML.
> 
> #create a data frame describing a cross-sectional parallel cluster
> #randomised trial
> df <- nelder(~(cl(10)*t(5)) > ind(10))
> df$int <- 0
> df[df$cl > 5, 'int'] <- 1
> mod <- Model$new(
+   formula = ~ factor(t) + int - 1 + (1|gr(cl)) + (1|gr(cl,t)),
+   data = df,
+   family = stats::gaussian()
+ )
> 
> # We can also include the outcome data in the model initialisation. 
> # For example, simulating data and creating a new object:
> df$y <- mod$sim_data()
> 
> mod <- Model$new(
+   formula = y ~ factor(t) + int - 1 + (1|gr(cl)) + (1|gr(cl,t)),
+   data = df,
+   family = stats::gaussian()
+ )
> 
> # Here we will specify a cohort study
> df <- nelder(~ind(20) * t(6))
> df$int <- 0
> df[df$t > 3, 'int'] <- 1
> 
> des <- Model$new(
+   formula = ~ int + (1|gr(ind)),
+   data = df,
+   family = stats::poisson()
+ )
>   
> # or with parameter values specified
>   
> des <- Model$new(
+   formula = ~ int + (1|gr(ind)),
+   covariance = c(0.05),
+   mean = c(1,0.5),
+   data = df,
+   family = stats::poisson()
+ )
> 
> #an example of a spatial grid with two time points
> 
> df <- nelder(~ (x(10)*y(10))*t(2))
> spt_design <- Model$new(formula = ~ 1 + (1|ar0(t)*fexp(x,y)),
+                         data = df,
+                         family = stats::gaussian())
> 
> ## ------------------------------------------------
> ## Method `Model$sim_data`
> ## ------------------------------------------------
> 
> df <- nelder(~(cl(10)*t(5)) > ind(10))
> df$int <- 0
> df[df$cl > 5, 'int'] <- 1
> ## Don't show: 
> setParallel(FALSE) # for the CRAN check
> ## End(Don't show)
> des <- Model$new(
+   formula = ~ factor(t) + int - 1 + (1|gr(cl)*ar0(t)),
+   covariance = c(0.05,0.8),
+   mean = c(rep(0,5),0.6),
+   data = df,
+   family = stats::binomial()
+ )
> ysim <- des$sim_data()
> 
> ## ------------------------------------------------
> ## Method `Model$update_parameters`
> ## ------------------------------------------------
> 
> ## Don't show: 
> setParallel(FALSE) # for the CRAN check
> ## End(Don't show)
> df <- nelder(~(cl(10)*t(5)) > ind(10))
> df$int <- 0
> df[df$cl > 5, 'int'] <- 1
> des <- Model$new(
+   formula = ~ factor(t) + int - 1 + (1|gr(cl)*ar0(t)),
+   data = df,
+   family = stats::binomial()
+ )
> des$update_parameters(cov.pars = c(0.1,0.9))
> 
> ## ------------------------------------------------
> ## Method `Model$power`
> ## ------------------------------------------------
> 
> ## Don't show: 
> setParallel(FALSE) # for the CRAN check
> ## End(Don't show)
> df <- nelder(~(cl(10)*t(5)) > ind(10))
> df$int <- 0
> df[df$cl > 5, 'int'] <- 1
> des <- Model$new(
+   formula = ~ factor(t) + int - 1 + (1|gr(cl)) + (1|gr(cl,t)),
+   covariance = c(0.05,0.1),
+   mean = c(rep(0,5),0.6),
+   data = df,
+   family = stats::gaussian(),
+   var_par = 1
+ )
> des$power() #power of 0.90 for the int parameter
      Value        SE    Power
b_t1    0.0 0.1843909 0.025000
b_t2    0.0 0.1843909 0.025000
b_t3    0.0 0.1843909 0.025000
b_t4    0.0 0.1843909 0.025000
b_t5    0.0 0.1843909 0.025000
b_int   0.6 0.1897367 0.885379
> 
> ## ------------------------------------------------
> ## Method `Model$fit`
> ## ------------------------------------------------
> 
> # Simulated trial data example using REML
> # we set starting values to prevent errors on example checking - these are not strictly necessary
> set.seed(123)
> data(SimTrial,package = "glmmrBase")
> fit1 <- Model$new(
+   formula = y ~ int + factor(t) - 1 + (1|grlog(cl)*ar0log(t)),
+   data = SimTrial,
+   family = gaussian(),
+   covariance = log(c(0.05,0.7))
+ )$fit(reml = TRUE)
> 
> # Salamanders data example
> data(Salamanders,package="glmmrBase")
> model <- Model$new(
+   mating~fpop:mpop-1+(1|grlog(mnum))+(1|grlog(fnum)),
+   data = Salamanders,
+   family = binomial(),
+   covariance = log(c(0.05,0.7))
+ )
> set.seed(125)
> fit2 <- model$fit()
> 
> # Example using simulated data
> #create example data with six clusters, five time periods, and five people per cluster-period
> df <- nelder(~(cl(20)*t(10)) > ind(5))
> # parallel trial design intervention indicator
> df$int <- 0
> df[df$cl > 10, 'int'] <- 1 
> # specify parameter values in the call for the data simulation below
> des <- Model$new(
+   formula= ~ factor(t) + int - 1 +(1|grlog(cl)*ar0log(t)),
+   covariance = log(c(0.15,0.7)),
+   mean = c(rep(0,10),0.2),
+   data = df,
+   family = binomial()
+ )
> ysim <- des$sim_data() # simulate some data from the model
> des$update_y(ysim)
> set.seed(123)
> fit2 <- des$fit() 
> 
> # use of Gaussian process approximations
> # simulate some data - binomial observation on [-1,1] x [-1,1]
> set.seed(123)
> df <- data.frame(
+ x = runif(100, -1, 1),
+ y = runif(100, -1, 1))
> df$z <- rnorm(100)
> 
> df$outcome <- Model$new(
+   ~ z + (1|matern1log(x, y)),
+   data = df,
+    family = binomial(),
+   mean = c(1, 0.1),
+   covariance = c(log(2), log(0.3)),
+   trials = rep(10, nrow(df))
+ )$sim_data()
> 
> # we can fit the SPDE approximation using a mesh built by fmesher
> df_pred <- expand.grid(x= seq(-1,1,by=0.05), y = seq(-1,1,by=0.05))
> df_pred$z <- 0
> mesh_data <- mesh_helper(unique(df[,1:2]), df_pred[,1:2], c(0.15, 0.75), 0.075, c(0.1,0.3))
Loading required namespace: fmesher
Failed with error:  ‘there is no package called ‘fmesher’’
Error in mesh_helper(unique(df[, 1:2]), df_pred[, 1:2], c(0.15, 0.75),  : 
  fmesher required
Execution halted