简体   繁体   中英

Why does using cluster= argument in mgcv::bam() result in an error?

I am trying to reproduce the example given in here:

https://stat.ethz.ch/R-manual/R-devel/library/mgcv/html/mgcv-parallel.html

Specifically, the use of the cluster= argument in mgcv::bam().

Reproducible example:

require(mgcv)
require(parallel) 

    k <- 13;bs <- "cr"; set.seed(9)
    dat <- gamSim(1,n=6000,dist="poisson",scale=.1)

    nc <- 2   ## cluster size, set for example portability
    if (detectCores()>1) { ## no point otherwise
      cl <- makeCluster(nc) 
    } else cl <- NULL

    system.time(b3 <- bam(y ~ s(x0,bs=bs,k=7)+s(x1,bs=bs,k=7)+s(x2,bs=bs,k=k)
                ,data=dat,family=poisson(),chunk.size=5000,cluster=cl))

This results in the following error on my machine:

Error in checkForRemoteErrors(val) : 2 nodes produced errors; first error: no applicable method for 'predict' applied to an object of class "gam" Timing stopped at: 0.31 0 0.37

Other information which may be of use:

R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

My machine has 4 cores and 16 GB RAM.

Thank you.

I couldn't reproduce the error & got this output.

> b3

Family: poisson 
Link function: log 

Formula:
y ~ s(x0, bs = bs, k = 7) + s(x1, bs = bs, k = 7) + s(x2, bs = bs, 
    k = k)

Estimated degrees of freedom:
3.64 4.05 9.95  total = 18.64 

fREML score: 8563.705     

Try updating the packages and see if that helps. Otherwise some more insight would be useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM