'R: mgcv function bam: use multiple kernels from jupyter notebook

I use R in a jupyter notebook as described in this article. It work's perfectly fine. However, when I fit a GAM using the mgcv library and bam, e.g.:

dat <- gamSim(1,n=25000,dist="normal",scale=20)
bs <- "cr"; k <- 12
b <- bam(y ~ s(x0,bs=bs)+s(x1,bs=bs)+s(x2,bs=bs,k=k)+
           s(x3,bs=bs), data=dat, discrete=TRUE, nthreads=4)

the jupyter notebook does not utilize multiple cpu's at once. This is problematic as work with big data. Any ideas how to fix this?



Solution 1:[1]

You need to use discrete = TRUE to be able to use the nthreads argument. Read ?bam for ways to do the computation in parallel if you don’t want to use the discretisation option.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1