steve-the-bayesian / BOOM

A C++ library for Bayesian modeling, mainly through Markov chain Monte Carlo, but with a few other methods supported. BOOM = "Bayesian Object Oriented Modeling". It is also the sound your computer makes when it crashes.
GNU Lesser General Public License v2.1
35 stars 14 forks source link

DLM prediction crashes R. #37

Closed steve-the-bayesian closed 4 years ago

steve-the-bayesian commented 5 years ago

library(bsts)

Load the data

data(iclaims) train <- window(initial.claims, start = "2004-01-04", end="2010-01-01") test <- window(initial.claims, start="2010-01-02")

Create model

ss <- AddLocalLinearTrend(list(), train$iclaimsNSA) ss <- AddSeasonal(ss, train$iclaimsNSA, nseasons = 52)

Dynamic regression component

ss <- AddDynamicRegression(ss, formula = iclaimsNSA ~ unemployment.office, data = train)

Train it

model <- bsts(train$iclaimsNSA , state.specification = ss, niter = 1000) test_subset <- cbind(test$department.of.unemployment) pred <- predict(model, newdata = test_subset)

caught segfault address 0x20, cause 'memory not mapped'

steve-the-bayesian commented 5 years ago

Commit 9a6db0a9ab75831d839ff2bc59e420366e7bd464 fixes this issue. Pending release to CRAN.

mikekaminsky commented 5 years ago

👋 love the library -- i'm running into this issue right now and would love to be able to make use of this fix. I'm not super familiar with R package management so apologies if this is a dumb question, but is there any way that I can install this from source so that I can get a version with https://github.com/steve-the-bayesian/BOOM/commit/9a6db0a9ab75831d839ff2bc59e420366e7bd464?

tvladeck commented 5 years ago

@steve-the-bayesian echo @mikekaminsky here. I tried to figure out a way to install the package. I ran

devtools::install_git("https://github.com/steve-the-bayesian/BOOM", subdir = "Interfaces/R/bsts", ref = "stable")

and am getting this error on compilation. I got the same error when running on master as well

all -g -O2 -c model_manager.cc -o model_manager.o
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I`/Library/Frameworks/R.framework/Resources/bin/Rscript -e "cat(system.file(package='Boom'))"`/include -DADD_ -DR_NO_REMAP -DRLANGUAGE -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Boom/include" -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include" -I/usr/local/include   -fPIC  -Wall -g -O2 -c multivariate_gaussian_model_manager.cc -o multivariate_gaussian_model_manager.o
multivariate_gaussian_model_manager.cc:126:38: error: no viable conversion from 'Ptr<BOOM::SubordinateModelIoElement>' to 'BOOM::RListIoElement *'
        io_manager->add_list_element(subordinate_model_io);
                                     ^~~~~~~~~~~~~~~~~~~~
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Boom/include/cpputil/Ptr.hpp:124:5: note: candidate function
    operator unspecified_bool_type() const {
    ^
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Boom/include/r_interface/list_io.hpp:84:43: note: passing argument to parameter 'element' here
    void add_list_element(RListIoElement *element);
                                          ^
1 error generated.
make: *** [multivariate_gaussian_model_manager.o] Error 1
ERROR: compilation failed for package ‘bsts’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/bsts’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/bsts’
Error in i.p(...) : 
  (converted from warning) installation of package ‘/var/folders/1x/kmsj0v9s57l4v52tk7vy_gv00000gn/T//RtmpZw1SLa/file174667ecee822/bsts_0.9.1.tar.gz’ had non-zero exit status
steve-the-bayesian commented 5 years ago

Hi Michael, The relevant R packages are available in https://drive.google.com/open?id=1cb_oYvYzxJvnnXgSeQhrnkpwV-XVF-nC Please download each one. Install the "BH" package as you would normally. Then from the command prompt type

  1. R CMD INSTALL Boom_0.9.1.tar.gz
  2. R CMD INSTALL BoomSpikeSlab_1.1.1.tar.gz
  3. R CMD INSTALL bsts_0.9.1.tar.gz

Assuming you have the gnu toolchain (e.g. Gnu make, etc) these will install the development version of bsts. If you're missing a tool either get a friend to help you or wait a couple of weeks for me to post this version to CRAN.

Cheers, Steve

On Sun, Jul 7, 2019 at 10:50 AM Michael notifications@github.com wrote:

👋 love the library -- i'm running into this issue right now and would love to be able to make use of this fix. I'm not super familiar with R package management so apologies if this is a dumb question, but is there any way that I can install this from source so that I can get a version with 9a6db0a https://github.com/steve-the-bayesian/BOOM/commit/9a6db0a9ab75831d839ff2bc59e420366e7bd464 ?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/steve-the-bayesian/BOOM/issues/37?email_source=notifications&email_token=ABMVDVILYPMSAMFUM7PYSF3P6IUF3A5CNFSM4HVKH72KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZLQCGQ#issuecomment-509018394, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMVDVKOFCSH4IQU67AHUZTP6IUF3ANCNFSM4HVKH72A .

steve-the-bayesian commented 5 years ago

Hi Thomas, You're getting that error because Boom and bsts must be kept in sync. You are trying to compile a version of bsts that needs an equivalent version of Boom. You can get the development versions of Boom, BoomSpikeSlab, and bsts at: https://drive.google.com/open?id=1cb_oYvYzxJvnnXgSeQhrnkpwV-XVF-nC

On Sun, Jul 7, 2019 at 12:11 PM Thomas Vladeck notifications@github.com wrote:

@steve-the-bayesian https://github.com/steve-the-bayesian echo @mikekaminsky https://github.com/mikekaminsky here. I tried to figure out a way to install the package. I ran

devtools::install_git("https://github.com/steve-the-bayesian/BOOM", subdir = "Interfaces/R/bsts", ref = "stable")

and am getting this error on compilation. I got the same error when running on master as well

all -g -O2 -c model_manager.cc -o modelmanager.o clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/Library/Frameworks/R.framework/Resources/bin/Rscript -e "cat(system.file(package='Boom'))"/include -DADD -DR_NO_REMAP -DRLANGUAGE -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Boom/include" -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include" -I/usr/local/include -fPIC -Wall -g -O2 -c multivariate_gaussian_model_manager.cc -o multivariate_gaussian_model_manager.o multivariate_gaussian_model_manager.cc:126:38: error: no viable conversion from 'Ptr' to 'BOOM::RListIoElement *'

    io_manager->add_list_element(subordinate_model_io);

                                 ^~~~~~~~~~~~~~~~~~~~

/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Boom/include/cpputil/Ptr.hpp:124:5: note: candidate function

operator unspecified_bool_type() const {

^

/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Boom/include/r_interface/list_io.hpp:84:43: note: passing argument to parameter 'element' here

void add_list_element(RListIoElement *element);

                                      ^

1 error generated. make: *** [multivariate_gaussian_model_manager.o] Error 1 ERROR: compilation failed for package ‘bsts’

  • removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/bsts’
  • restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/bsts’ Error in i.p(...) :

    (converted from warning) installation of package ‘/var/folders/1x/kmsj0v9s57l4v52tk7vy_gv00000gn/T//RtmpZw1SLa/file174667ecee822/bsts_0.9.1.tar.gz’ had non-zero exit status

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/steve-the-bayesian/BOOM/issues/37?email_source=notifications&email_token=ABMVDVISOUJVI6XS33S2SILP6I5WLA5CNFSM4HVKH72KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZLRKFY#issuecomment-509023511, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMVDVJUGU2Q2GGHOPXSYLTP6I5WLANCNFSM4HVKH72A .

tvladeck commented 5 years ago

​that makes complete sense. i naively thought that that would install everything (including Boom), but clearly not. thank you!!!!​

On Mon, Jul 8, 2019 4:14 AM, steve-the-bayesian notifications@github.com wrote: Hi Thomas, You're getting that error because Boom and bsts must be kept in sync. You are trying to compile a version of bsts that needs an equivalent version of Boom. You can get the development versions of Boom, BoomSpikeSlab, and bsts at: https://drive.google.com/open?id=1cb_oYvYzxJvnnXgSeQhrnkpwV-XVF-nC

On Sun, Jul 7, 2019 at 12:11 PM Thomas Vladeck notifications@github.com wrote:

@steve-the-bayesian https://github.com/steve-the-bayesian echo @mikekaminsky https://github.com/mikekaminsky here. I tried to figure out a way to install the package. I ran

devtools::install_git("https://github.com/steve-the-bayesian/BOOM", subdir = "Interfaces/R/bsts", ref = "stable")

and am getting this error on compilation. I got the same error when running on master as well

all -g -O2 -c model_manager.cc -o modelmanager.o clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/Library/Frameworks/R.framework/Resources/bin/Rscript -e "cat(system.file(package='Boom'))"/include -DADD -DR_NO_REMAP -DRLANGUAGE -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Boom/include" -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include" -I/usr/local/include -fPIC -Wall -g -O2 -c multivariate_gaussian_model_manager.cc -o multivariate_gaussian_model_manager.o multivariate_gaussian_model_manager.cc:126:38: error: no viable conversion from 'Ptr' to 'BOOM::RListIoElement *'

io_manager->add_list_element(subordinate_model_io);

^~~~~~~~

/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Boom/include/cpputil/Ptr.hpp:124:5: note: candidate function

operator unspecified_bool_type() const {

^

/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Boom/include/r_interface/list_io.hpp:84:43: note: passing argument to parameter 'element' here

void add_list_element(RListIoElement *element);

^ 1 error generated. make: *** [multivariate_gaussian_model_manager.o] Error 1 ERROR: compilation failed for package ‘bsts’

  • removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/bsts’
  • restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/bsts’ Error in i.p(...) :

(converted from warning) installation of package ‘/var/folders/1x/kmsj0v9s57l4v52tk7vy_gv00000gn/T//RtmpZw1SLa/file174667ecee822/bsts_0.9.1.tar.gz’ had non-zero exit status

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

https://github.com/steve-the-bayesian/BOOM/issues/37?email_source=notifications&email_token=ABMVDVISOUJVI6XS33S2SILP6I5WLA5CNFSM4HVKH72KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZLRKFY#issuecomment-509023511, or mute the thread

https://github.com/notifications/unsubscribe-auth/ABMVDVJUGU2Q2GGHOPXSYLTP6I5WLANCNFSM4HVKH72A .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

steve-the-bayesian commented 5 years ago

The 'install.packages' workflow works as you expect. Installing manually does not.

On Mon, Jul 8, 2019 at 7:37 AM Thomas Vladeck notifications@github.com wrote:

​that makes complete sense. i naively thought that that would install everything (including Boom), but clearly not. thank you!!!!​

On Mon, Jul 8, 2019 4:14 AM, steve-the-bayesian notifications@github.com wrote: Hi Thomas, You're getting that error because Boom and bsts must be kept in sync. You are trying to compile a version of bsts that needs an equivalent version of Boom. You can get the development versions of Boom, BoomSpikeSlab, and bsts at: https://drive.google.com/open?id=1cb_oYvYzxJvnnXgSeQhrnkpwV-XVF-nC

On Sun, Jul 7, 2019 at 12:11 PM Thomas Vladeck notifications@github.com wrote:

@steve-the-bayesian https://github.com/steve-the-bayesian echo @mikekaminsky https://github.com/mikekaminsky here. I tried to figure out a way to install the package. I ran

devtools::install_git("https://github.com/steve-the-bayesian/BOOM", subdir = "Interfaces/R/bsts", ref = "stable")

and am getting this error on compilation. I got the same error when running on master as well

all -g -O2 -c model_manager.cc -o modelmanager.o clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/Library/Frameworks/R.framework/Resources/bin/Rscript -e "cat(system.file(package='Boom'))"/include -DADD -DR_NO_REMAP -DRLANGUAGE

-I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Boom/include"

-I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include" -I/usr/local/include -fPIC -Wall -g -O2 -c multivariate_gaussian_model_manager.cc -o multivariate_gaussian_model_manager.o

multivariate_gaussian_model_manager.cc:126:38: error: no viable conversion from 'Ptr' to 'BOOM::RListIoElement *'

io_manager->add_list_element(subordinate_model_io);

^~~~~~~~

/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Boom/include/cpputil/Ptr.hpp:124:5: note: candidate function

operator unspecified_bool_type() const {

^

/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Boom/include/r_interface/list_io.hpp:84:43: note: passing argument to parameter 'element' here

void add_list_element(RListIoElement *element);

^ 1 error generated. make: *** [multivariate_gaussian_model_manager.o] Error 1 ERROR: compilation failed for package ‘bsts’

  • removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/bsts’
  • restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/bsts’ Error in i.p(...) :

(converted from warning) installation of package

‘/var/folders/1x/kmsj0v9s57l4v52tk7vy_gv00000gn/T//RtmpZw1SLa/file174667ecee822/bsts_0.9.1.tar.gz’ had non-zero exit status

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

< https://github.com/steve-the-bayesian/BOOM/issues/37?email_source=notifications&email_token=ABMVDVISOUJVI6XS33S2SILP6I5WLA5CNFSM4HVKH72KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZLRKFY#issuecomment-509023511 , or mute the thread

< https://github.com/notifications/unsubscribe-auth/ABMVDVJUGU2Q2GGHOPXSYLTP6I5WLANCNFSM4HVKH72A

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/steve-the-bayesian/BOOM/issues/37?email_source=notifications&email_token=ABMVDVKMKBDI73WPNBH6QQ3P6NGMNA5CNFSM4HVKH72KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZNJHLI#issuecomment-509252525, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMVDVNHVKPO3G3UKXIFMSLP6NGMNANCNFSM4HVKH72A .