Running 'demo_cholesky.R' [168s]
  Running 'demo_jss10-example1.R' [163s]
  Running 'demo_jss10-figures-table.R' [169s]
  Running 'demo_jss15-BYM.R' [155s]
  Running 'demo_jss15-Leroux.R' [159s]
  Running 'demo_spam.R' [167s]
  Running 'demo_timing.R' [2s]
  Comparing 'demo_timing.Rout' to 'demo_timing.Rout.save' ... OK
  Running 'jss_areal_counts.R' [161s]
  Running 'testthat.R' [167s]
Running the tests in 'tests/demo_cholesky.R' failed.
Complete output:
  > # HEADER ####################################################
  > # This is file spam/tests/demo_cholesky.R.                  #
  > # It is part of the R package spam,                         #
  > #  --> https://CRAN.R-project.org/package=spam              #
  > #  --> https://CRAN.R-project.org/package=spam64            #
  > #  --> https://git.math.uzh.ch/reinhard.furrer/spam         #
  > # by Reinhard Furrer [aut, cre], Florian Gerber [aut],      #
  > #    Roman Flury [aut], Daniel Gerber [ctb],                #
  > #    Kaspar Moesinger [ctb]                                 #
  > # HEADER END ################################################
  > 
  > 
  > # We illustrate the Cholesky decompostion approaches
  > options( echo=FALSE)
  Spam version 2.10-0 (2023-10-23) is loaded.
  Type 'help( Spam)' or 'demo( spam)' for a short introduction 
  and overview of this package.
  Help for individual functions is also obtained by adding the
  suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
  > 
  > proc.time()
     user  system elapsed 
     0.79    0.10    0.89 
Running the tests in 'tests/demo_jss10-example1.R' failed.
Complete output:
  > # HEADER ####################################################
  > # This is file spam/tests/demo_jss10-example1.R.      #
  > # It is part of the R package spam,                         #
  > #  --> https://CRAN.R-project.org/package=spam              #
  > #  --> https://CRAN.R-project.org/package=spam64            #
  > #  --> https://git.math.uzh.ch/reinhard.furrer/spam         #
  > # by Reinhard Furrer [aut, cre], Florian Gerber [aut],      #
  > #    Roman Flury [aut], Daniel Gerber [ctb],                #
  > #    Kaspar Moesinger [ctb]                                 #
  > # HEADER END ################################################
  > 
  > 
  > # JSS article:
  > #     "spam: A Sparse Matrix R Package with Emphasis on
  > #            MCMC Methods for Gaussian Markov Random Fields"
  > #
  > # Compared to the R code given in the article, here we give:
  > # - improved formatting
  > # - more comments
  > # - the R code to construct the figures
  > 
  > 
  > 
  > # SETUP:
  > library("spam")
  Spam version 2.10-0 (2023-10-23) is loaded.
  Type 'help( Spam)' or 'demo( spam)' for a short introduction 
  and overview of this package.
  Help for individual functions is also obtained by adding the
  suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
  
  Attaching package: 'spam'
  
  The following objects are masked from 'package:base':
  
      backsolve, forwardsolve
  
  > options(spam.structurebased=TRUE)
  > data("UKDriverDeaths")
  > 
  > y <- sqrt(c(UKDriverDeaths))       # square root counts
  > 
  > n <- length(y)                     # n=192
  > m <- 12                            # We want to predict for one season.
  > nm <- n+m                          # Total length of s and t
  > 
  > 
  > priorshape <-  c(4, 1, 1)          # alpha's, as in Rue & Held (2005)
  > priorinvscale <- c(4, 0.1, 0.0005) # beta's
  > 
  > # Construct the individual block precisions
  > # (based on unit precision parameters kappa, denoted with k):
  > 
  > # Qsy, Qty are trivial:
  > Qsy <- diag.spam(n)
  > pad(Qsy) <- c(n+m, n)  # previously:  dim(Qsy) <- c(n+m, n)
  > 
  > Qty <- Qsy
  > 
  > Qst <- spam(0, nm, nm)
  > Qst[cbind(1:n, 1:n)] <- rep(1, n)
  > 
  > 
  > # The form of Qss is given by (Rue and Held equation 3.59).
  > # Qss can be constructed with a loop:
  > Qss <- spam(0, nm, nm)
  > for (i in 0:(nm-m)) {
  +     Qss[i+1:m,i+1:m] <- Qss[i+1:m, i+1:m] + matrix(1,m,m)
  + #    Qss[i+1:m,i+1:m] <- Qss[i+1:m, i+1:m]+1  # previously...
  + }
  > 
  > # Note that for the final version we need:
  > # Qss <- k_s * Qss + k_y * diag.spam(nm)
  > 
  > 
  > 
  > 
  > # The form of Qtt is given by (Rue and Held equation 3.40).
  > # Similar approaches to construct Qtt:
  > 
  > Qtt <- spam(0,nm,nm)
  > Qtt[cbind(1:(nm-1),2:nm)] <- -c(2,rep(4,nm-3),2)
  > Qtt[cbind(1:(nm-2),3:nm)] <- rep(1,nm-2)
  > Qtt <- Qtt + t( Qtt)
  > diag(Qtt) <- c(1,5,rep(6,nm-4),5,1)
  > 
  > 
  > 
  > # Create temporary kappa and precision matrix to illustrate
  > # adjacency matrix and ordering.
  > k <- c(1,1,1)
  > Qst_yk <- rbind(cbind(k[2]*Qss + k[1]*diag.spam(nm), k[1]*Qst),
  +        	        cbind(k[1]*Qst, k[3]*Qtt + k[1]*diag.spam(nm)))
  > 
  > struct <- chol(Qst_yk)
  > 
  > 
  > 
  > # Note that we do not provide the exactly the same ordering
  > # algorithms. Hence, the following is sightly different than
  > # Figure RH4.2.
  > cholQst_yk <- chol(Qst_yk,pivot="RCM")
  > P <- ordering(cholQst_yk)
  > display(Qst_yk)
  Warning message:
  default value for 'cex' in 'display' might not be the optimal choice 
  > display(Qst_yk[P,P])
  Warning message:
  default value for 'cex' in 'display' might not be the optimal choice 
  > 
  > 
  > 
  > # Recall:
  > # k=( kappa_y, kappa_s, kappa_t)'
  > 
  > # Gibbs sampler
  > ngibbs <- 100   # In the original version is 500!
  > burnin <- 10    # > 0
  > totalg <- ngibbs+burnin
  > set.seed(14)
  > 
  > # Initialize parameters:
  > spost <- tpost <- array(0, c(totalg, nm))
  > kpost <- array(0, c(totalg, 3))
  > 
  > # Starting values:
  > kpost[1,] <- c(.5,28,500)
  > tpost[1,] <- 40
  > 
  > # calculation of a few variables:
  > postshape <- priorshape + c(	n/2, (n+1)/2, (n+m-2)/2)
  > 
  > 
  > for (ig in 2:totalg) {
  + 
  +   Q <- rbind(cbind(kpost[ig-1,2]*Qss + kpost[ig-1,1]*Qst,
  +                    kpost[ig-1,1]*Qst),
  +              cbind(kpost[ig-1,1]*Qst,
  +                    kpost[ig-1,3]*Qtt + kpost[ig-1,1]*Qst))
  + 
  +   b <- c(kpost[ig-1,1]*Qsy %*% y, kpost[ig-1,1]*Qsy %*% y)
  + 
  +   tmp <- rmvnorm.canonical(1, b, Q, Lstruct=struct)
  + 
  + 
  +   spost[ig,] <- tmp[1:nm]
  + 
  +   tpost[ig,] <- tmp[1:nm+nm]
  + 
  + 
  +   tmp <- y-spost[ig,1:n]-tpost[ig,1:n]
  + 
  +   postinvscale <- priorinvscale + # prior contribution
  +     c( sum( tmp^2)/2,     # Qyy_st is the identity
  +       t(spost[ig,]) %*% (Qss %*% spost[ig,])/2,
  +       t(tpost[ig,]) %*% (Qtt %*% tpost[ig,])/2)
  + 
  + 
  +   kpost[ig,] <- rgamma(3, postshape, postinvscale)
  + 
  +   if( (ig%%10)==0) cat('.')
  + 
  + }
  ...........> 
  > 
  > 
  > # Eliminate burn-in:
  > kpost <- kpost[-c(1:burnin),]
  > spost <- spost[-c(1:burnin),]
  > tpost <- tpost[-c(1:burnin),]
  > 
  > postquant <- apply(spost+tpost, 2, quantile,c(.025,.975))
  > postmean  <- apply(spost+tpost, 2, mean)
  > postmedi  <- apply(spost+tpost, 2, median)
  > 
  > if (F){
  + 
  + par(mfcol=c(1,1),mai=c(.6,.8,.01,.01))
  + 
  + plot( y^2, ylim=c(800,2900),xlim=c(0,nm),ylab="Counts")
  + #lines( postmean^2, col=2)
  + lines( postmedi^2, col=2)
  + matlines( t(postquant)^2, col=4,lty=1)
  + 
  + legend("topright",legend=c("Posterior median", "Quantiles of posterior sample",
  +                     "Quantiles of predictive distribution"),
  +        bty="n",col=c(2,4,3),lty=1)
  + 
  + 
  + 
  + 
  + # Constructing a predictive distribution:
  + ypred <- rnorm( ngibbs*nm, c(spost+tpost),sd=rep( 1/sqrt(kpost[,1]), nm))
  + dim(ypred) <- c(ngibbs,nm)
  + postpredquant <- apply(ypred, 2, quantile,c(.025,.975))
  + matlines( t(postpredquant)^2, col=3,lty=1)
  + points(y^2)
  + dev.off()
  + 
  + kpostmedian <- apply(kpost,2,median)
  + 
  + par(mfcol=c(1,3),mai=c(.65,.65,.01,.01),cex=.85,mgp=c(2.6,1,0))
  + 
  + matplot( log( kpost), lty=1, type="l",xlab="Index")
  + abline(h=log(kpostmedian),col=3)
  + acf( kpost[,3],ylab=expression(kappa[t]))
  + plot(kpost[,2:3],ylab=expression(kappa[t]),xlab=expression(kappa[s]),cex=.8)
  + abline(h=kpostmedian[3],v=kpostmedian[2],col=3)
  + dev.off()
  + 
  + 
  + allkappas <- rbind(apply(kpost,2,mean),
  +                    apply(kpost,2,median),
  +                    apply(1/kpost,2,mean),
  +                    apply(1/kpost,2,median))
  + colnames(allkappas) <- c("kappa_y", "kappa_s", "kappa_t")
  + rownames(allkappas) <- c("Prec (mean)", "Prec (median)",
  +                          "Var (mean)", "Var (median) ")
  + print(allkappas,4)
  + 
  + png("example1_m1.png",width=300,height=300)
  + par(mai=c(.5,.5,.05,.05))
  + display(Qst_yk)
  + dev.off()
  + 
  + png("example1_m2.png",width=300,height=300)
  + par(mai=c(.5,.5,.05,.05))
  + display(struct)
  + dev.off()
  + 
  + 
  + summary(kpost)
  + 
  + 
  + }
  > 
  > proc.time()
     user  system elapsed 
     1.84    0.18    2.01 
Running the tests in 'tests/demo_jss10-figures-table.R' failed.
Complete output:
  > # HEADER ####################################################
  > # This is file spam/tests/demo_jss10-figures-table.R.       #
  > # It is part of the R package spam,                         #
  > #  --> https://CRAN.R-project.org/package=spam              #
  > #  --> https://CRAN.R-project.org/package=spam64            #
  > #  --> https://git.math.uzh.ch/reinhard.furrer/spam         #
  > # by Reinhard Furrer [aut, cre], Florian Gerber [aut],      #
  > #    Roman Flury [aut], Daniel Gerber [ctb],                #
  > #    Kaspar Moesinger [ctb]                                 #
  > # HEADER END ################################################
  > 
  > 
  > # This demo contains the R code to construct the figures and the table of the
  > # article:
  > #     "spam: A Sparse Matrix R Package with Emphasis on
  > #            MCMC Methods for Gaussian Markov Random Fields"
  > # submitted to JSS.
  > 
  > 
  > # The code presented here differs in the following points form the actually used
  > # one:
  > # - Very large grid sizes or very high order neighbor structures are not included
  > #   here;
  > # - Instead of (100+1) factorizations only (10+1) are performed here;
  > # - No figure fine-tuning is done here.
  > # - We had a few additional gc(), just to be sure.
  > 
  > 
  > 
  > # The following are tests specific. Not all computers run with profiling. Instead
  > # of commenting, we define dummies.
  > options( echo=FALSE)
  Spam version 2.10-0 (2023-10-23) is loaded.
  Type 'help( Spam)' or 'demo( spam)' for a short introduction 
  and overview of this package.
  Help for individual functions is also obtained by adding the
  suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
  [1] 3 5 1 2 4
  [1] 1 2 3 3 3
  [1] 1 2 3 6
   [1] 1.0000000 0.5000000 0.8660254 0.5773503 0.8164966 0.6123724 0.6123724
   [8] 0.7905694 0.1581139 0.7745967
  [1] 1 2 2 3 3 4 5
  [1] 1 3 5 8
  [1]  1  3  5  8 10 11
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  NULL
  > 
  > proc.time()
     user  system elapsed 
     5.82    0.53    6.35 
Running the tests in 'tests/demo_jss15-BYM.R' failed.
Complete output:
  > # HEADER ####################################################
  > # This is file spam/tests/demo_jss15-BYM.R.                 #
  > # It is part of the R package spam,                         #
  > #  --> https://CRAN.R-project.org/package=spam              #
  > #  --> https://CRAN.R-project.org/package=spam64            #
  > #  --> https://git.math.uzh.ch/reinhard.furrer/spam         #
  > # by Reinhard Furrer [aut, cre], Florian Gerber [aut],      #
  > #    Roman Flury [aut], Daniel Gerber [ctb],                #
  > #    Kaspar Moesinger [ctb]                                 #
  > # HEADER END ################################################
  >      
  > 
  > options( echo=FALSE)
  Spam version 2.10-0 (2023-10-23) is loaded.
  Type 'help( Spam)' or 'demo( spam)' for a short introduction 
  and overview of this package.
  Help for individual functions is also obtained by adding the
  suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
  [1] -0.45371922  0.17297575  0.02605778 -0.44984751 -0.36053283  0.01309363
  [1] -1.341895 -3.756725 -2.514229 -4.411210 -6.486653 -5.101487
  [1] 15.05715 53.22751 41.15492 13.16245 19.87138 30.27948
  [1] 0 1 1 1 1 0
  [1]  0.255439209 -0.299099415 -0.004660022 -0.392147580 -0.318792450
  [6] -0.344095560
  [1] -0.0152950744  0.0008418105  0.0400659014 -0.0160847172  0.0064331753
  [6] -0.0154282422
  [1] 21
  [1] -780.3814
  > 
  > 
  > proc.time()
     user  system elapsed 
     1.37    0.25    1.60 
Running the tests in 'tests/demo_jss15-Leroux.R' failed.
Complete output:
  > # HEADER ####################################################
  > # This is file spam/tests/demo_jss15-Leroux.R.              #
  > # It is part of the R package spam,                         #
  > #  --> https://CRAN.R-project.org/package=spam              #
  > #  --> https://CRAN.R-project.org/package=spam64            #
  > #  --> https://git.math.uzh.ch/reinhard.furrer/spam         #
  > # by Reinhard Furrer [aut, cre], Florian Gerber [aut],      #
  > #    Roman Flury [aut], Daniel Gerber [ctb],                #
  > #    Kaspar Moesinger [ctb]                                 #
  > # HEADER END ################################################
  > 
  > options( echo=FALSE)
  Spam version 2.10-0 (2023-10-23) is loaded.
  Type 'help( Spam)' or 'demo( spam)' for a short introduction 
  and overview of this package.
  Help for individual functions is also obtained by adding the
  suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
  Loading required package: stats4
  
  Attaching package: 'stats4'
  
  The following object is masked from 'package:spam':
  
      mle
  
  Loading required package: evd
  [1] 0.9890008 0.9836375 0.9836375 0.9941272 0.9941272 0.9941272
  [1] 13.60972 12.22357 14.06278 13.51154 13.66835 12.74985
   [1]  0.115752190 -0.242792156  0.009907357 -0.144865999 -0.000139589
   [6] -0.028916404 -0.032141235 -0.107868843  0.241070191  0.216479530
  [11]  0.215633918  0.121392169  0.132614808  0.087540970  0.009744541
  [16]  0.033720642  0.156237348  0.044155379  0.272346531  0.040463545
  [21]  0.079639678  0.103953125  0.252556753  0.021593753  0.167167125
  [26]  0.164189193  0.100494673 -0.213803862  0.117763888 -0.105802996
  [31]  0.105966646 -0.099242014 -0.273013722 -0.048069002 -0.043229426
  [36] -0.068403094 -0.213240808 -0.168754977 -0.087376979 -0.159318585
  [41] -0.066445680 -0.042490650 -0.225786751 -0.311643655 -0.070018302
  [46] -0.197298513 -0.172498476 -0.252130284  0.059552503  0.001103394
  [51]  0.221565313
  > 
  > proc.time()
     user  system elapsed 
     2.34    0.39    2.71 
Running the tests in 'tests/demo_spam.R' failed.
Complete output:
  > # HEADER ####################################################
  > # This is file spam/tests/demo_spam.R.                      #
  > # It is part of the R package spam,                         #
  > #  --> https://CRAN.R-project.org/package=spam              #
  > #  --> https://CRAN.R-project.org/package=spam64            #
  > #  --> https://git.math.uzh.ch/reinhard.furrer/spam         #
  > # by Reinhard Furrer [aut, cre], Florian Gerber [aut],      #
  > #    Roman Flury [aut], Daniel Gerber [ctb],                #
  > #    Kaspar Moesinger [ctb]                                 #
  > # HEADER END ################################################
  > 
  > 
  > # This is a simple demo, wrapping up the functionality of spam.
  > options( echo=FALSE)
  Spam version 2.10-0 (2023-10-23) is loaded.
  Type 'help( Spam)' or 'demo( spam)' for a short introduction 
  and overview of this package.
  Help for individual functions is also obtained by adding the
  suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
             [,1]     [,2]       [,3]      [,4]      [,5]       [,6]      [,7]
  [1,] -0.6618498 1.231945 -0.3828219 0.8828018 -1.266815 -0.7666105 -1.421992
  Class 'spam' (32-bit)
       [,1]        [,2]       [,3]      [,4]       [,5]       [,6]       [,7]
  [1,]    0  1.23194518 -0.3828219 0.8828018 -1.2668148 -0.7666105 -1.4219925
  [2,]    0 -0.06488077  0.2994216 1.8627490 -0.1985833  1.4433629 -0.3282283
  [3,]    0  1.06899373  0.6742398 1.6117253  0.1388658  0.8448793  0.2845701
  [4,]    0 -0.37696531 -0.2928163 0.1354795 -0.2793360 -0.3993704  0.7193359
  [5,]    0  1.04318309  0.4880534 1.0880860  0.7089194 -1.4277676  0.4324160
  Class 'spam' (32-bit)
  [1] -0.36181804  0.07322929 -0.13634352  0.59605327  0.52252315
  > 
  > proc.time()
     user  system elapsed 
     0.87    0.07    0.95 
Running the tests in 'tests/jss_areal_counts.R' failed.
Complete output:
  > # HEADER ####################################################
  > # This is file spam/tests/jss_areal_counts.R.               #
  > # It is part of the R package spam,                         #
  > #  --> https://CRAN.R-project.org/package=spam              #
  > #  --> https://CRAN.R-project.org/package=spam64            #
  > #  --> https://git.math.uzh.ch/reinhard.furrer/spam         #
  > # by Reinhard Furrer [aut, cre], Florian Gerber [aut],      #
  > #    Roman Flury [aut], Daniel Gerber [ctb],                #
  > #    Kaspar Moesinger [ctb]                                 #
  > # HEADER END ################################################
  > 
  > 
  > # JSS article: 
  > #     "Pitfalls in the implementation of Bayesian
  > #      hierarchical modeling of areal count data.
  > #      An illustration using BYM and Leroux models."
  > #
  > # test the MCMC sampler from the paper with 30 iterations.
  > 
  > 
  > # SETUP:
  > library("spam")
  Spam version 2.10-0 (2023-10-23) is loaded.
  Type 'help( Spam)' or 'demo( spam)' for a short introduction 
  and overview of this package.
  Help for individual functions is also obtained by adding the
  suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
  
  Attaching package: 'spam'
  
  The following objects are masked from 'package:base':
  
      backsolve, forwardsolve
  
  > options(spam.structurebased=TRUE)
  > 
  > # BYM ---------------------------------------------
  > data(Oral); attach(Oral) 
  > path <- system.file("demodata/germany.adjacency", package = "spam")
  > A <- adjacency.landkreis(path); n <- dim(A)[1]
  > 
  > set.seed(2)
  > hyperA <- c(1, 1); hyperB <- c(0.5, .01)  
  > totalg <- 30
  > 
  > upost <- vpost <- array(0, c(totalg, n))  
  > kpost <- array(NA, c(totalg, 2)); accept <- rep(NA, totalg)
  > upost[1,] <- vpost[1,] <- rep(.001, 544); kpost[1,] <- c(10, 100) 
  > 
  > eta <- upost[1,] + vpost[1,]
  > C <- exp(eta) * E; diagC <- diag.spam(c(rep(0, n), C))
  > b <- c( rep(0, n), Y + (eta - 1) * C)
  > Qu <- R <- precmat.IGMRFirreglat(A); pad(Qu) <- c(2 * n, 2 * n)
  > Qv <- as.spam(rbind(cbind( diag(n), -diag(n)),
  +                       cbind(-diag(n),  diag(n))))
  > Q <- kpost[1,1] * Qu + kpost[1,2] * Qv + diagC
  > struct <- chol(Q, memory = list(nnzcolindices = 6467))
  > uRuHalf <- t(upost[1,]) %*% (R %*% upost[1,]) / 2
  > vvHalf <- t(vpost[1,]) %*% vpost[1,] / 2
  > postshape <- hyperA + c(n - 1, n) / 2
  > 
  > for (i in 2:totalg) {
  +      kpost[i,] <- rgamma(2, postshape, hyperB + c(uRuHalf, vvHalf))
  +  
  +      etaTilde <- eta
  +      for(index in 1:2){
  +          C <- E * exp(etaTilde)
  +          diagC <- diag.spam(c(rep(0, n), C))
  +          b <- c(rep(0, 544), Y + (etaTilde - 1) * C)
  +          Q <- kpost[i,1] * Qu + kpost[i,2] * Qv + diagC
  +          etaTilde <- c(solve.spam(Q, b,
  +                                   Rstruct = struct))[1:n + n]
  +      }
  +  
  +      C <- exp(etaTilde) * E; diagC <- diag.spam(c(rep(0, n), C))
  +      b <- c( rep(0, n), Y + (etaTilde - 1) * C)
  +      Q <- kpost[i,1] * Qu + kpost[i,2] * Qv + diagC
  + 
  +      x_ <- c(rmvnorm.canonical(1, b, Q, Rstruct = struct))
  +      upost[i,] <- x_[1:n]; eta_ <- x_[1:n + n]; vpost[i,] <- eta_ - upost[i,]
  +      uRuHalf_ <- t(upost[i,]) %*% (R %*% upost[i,]) / 2
  +      vvHalf_ <- t(vpost[i,]) %*% vpost[i,] / 2
  + 
  +      etaTilde_ <- eta_
  +      for(index in 1:2){
  +        C_ <- E * exp(etaTilde_)
  +        diagC_ <- diag.spam(c(rep(0, n), C_))
  +        b_ <- c(rep(0, 544), Y + (etaTilde_ - 1) * C_)
  +        Q_<- kpost[i,1] * Qu + kpost[i,2] * Qv + diagC_
  +        etaTilde_ <- c(solve.spam(Q_, b_,
  +                                 Rstruct = struct))[1:n + n]
  +      }
  +      
  +      C_ <- exp(etaTilde_) * E; diagC_ <- diag.spam(c(rep(0, n), C_))
  +      b_ <- c( rep(0, n), Y + (etaTilde_ - 1) * C_)
  +      Q_ <- kpost[i,1] * Qu + kpost[i,2] * Qv + diagC_
  + 
  +      logPost_ <- sum(Y * eta_ - E * exp(eta_)) -
  +          kpost[i,1] * uRuHalf_ - kpost[i, 2] * vvHalf_
  +      logPost  <- sum(Y * eta - E * exp(eta)) - kpost[i,1] * uRuHalf -
  +          kpost[i,2] * vvHalf
  +      logApproxX_ <- - kpost[i,1] * uRuHalf_ - kpost[i,2] * vvHalf_ -
  +          sum(.5 * eta_^2 * C) + sum(b * eta_)
  +      logApproxX  <- - kpost[i,1] * uRuHalf  - kpost[i,2] * vvHalf -
  +          sum(.5 * eta^2 * C_) + sum(b_ * eta)
  +      logAlpha <- min(0, logPost_ - logPost + logApproxX - logApproxX_)
  +  
  +      if (log(runif(1)) < logAlpha) {    
  +          uRuHalf <- uRuHalf_;  vvHalf <- vvHalf_
  +          eta <- eta_; b <- b_; C <- C_; accept[i] <- 1
  +      } else{                            
  +        accept[i] <- 0; upost[i,] <- upost[i-1,]; vpost[i,] <- vpost[i-1,]} 
  +  }
  >  
  > # values of  30th iteration
  > head(eta)
  [1] -0.45371922  0.17297575  0.02605778 -0.44984751 -0.36053283  0.01309363
  > tail(b)
  [1] -1.341895 -3.756725 -2.514229 -4.411210 -6.486653 -5.101487
  > head(C)
  [1] 15.05715 53.22751 41.15492 13.16245 19.87138 30.27948
  > tail(accept)
  [1] 0 1 1 1 1 0
  > tail(upost[30,])
  [1]  0.255439209 -0.299099415 -0.004660022 -0.392147580 -0.318792450
  [6] -0.344095560
  > tail(vpost[30,])
  [1] -0.0152950744  0.0008418105  0.0400659014 -0.0160847172  0.0064331753
  [6] -0.0154282422
  > sum(accept[-1])
  [1] 21
  > sum(upost)
  [1] -780.3814
  > 
  > 
  > proc.time()
     user  system elapsed 
     1.53    0.28    1.81 
Running the tests in 'tests/testthat.R' failed.
Complete output:
  > # HEADER ####################################################
  > # This is file spam/tests/testthat.R.                       #
  > # It is part of the R package spam,                         #
  > #  --> https://CRAN.R-project.org/package=spam              #
  > #  --> https://CRAN.R-project.org/package=spam64            #
  > #  --> https://git.math.uzh.ch/reinhard.furrer/spam         #
  > # by Reinhard Furrer [aut, cre], Florian Gerber [aut],      #
  > #    Roman Flury [aut], Daniel Gerber [ctb],                #
  > #    Kaspar Moesinger [ctb]                                 #
  > # HEADER END ################################################
  > 
  > library("testthat")
  > # library("spam")
  > 
  > test_check("spam")
  Loading required package: spam
  Spam version 2.10-0 (2023-10-23) is loaded.
  Type 'help( Spam)' or 'demo( spam)' for a short introduction 
  and overview of this package.
  Help for individual functions is also obtained by adding the
  suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
  
  Attaching package: 'spam'
  
  The following objects are masked from 'package:base':
  
      backsolve, forwardsolve
  
  [ FAIL 0 | WARN 0 | SKIP 0 | PASS 730 ]
  > 
  > proc.time()
     user  system elapsed 
     6.90    1.15    8.03