rasmusab / bayesian_first_aid

Inside every classical test there is a Bayesian model trying to get out.
326 stars 40 forks source link

Having difficulty installing under R 3.3 #12

Open FarrelBuch opened 8 years ago

FarrelBuch commented 8 years ago

I do not know the source of my problem. Does the following mean anything to you? If so can you suggest a troubleshooting avenue or two that I can go down.

install_github("rasmusab/bayesian_first_aid") has always worked in the past but now I get this

> install_github("rasmusab/bayesian_first_aid") Downloading GitHub repo rasmusab/bayesian_first_aid@master from URL https://api.github.com/repos/rasmusab/bayesian_first_aid/zipball/master Installing BayesianFirstAid "C:/PROGRA~1/R/R-33~1.0/bin/i386/R" --no-site-file --no-environ --no-save \ --no-restore --quiet CMD INSTALL \ "C:/Users/Farrel/AppData/Local/Temp/RtmpWEoqvP/devtools2e9c79894018/rasmusab-bayesian_first_aid-6c7f844" \ --library="G:/Farrel Data/Documents/R/win-library/3.3" --install-tests

* installing *source* package 'BayesianFirstAid' ... ** R Warning: unable to re-encode 'bayes_prop_test.R' line 8 ** inst ** preparing package for lazy loading Error: Command failed (5)

rasmusab commented 8 years ago

The warning "R Warning: unable to re-encode 'bayes_prop_test.R' line 8" should not be the problem, and I would expect there to to be some error message in addition to "Error: Command failed (5)"...

The text you pasted here, is that the full error message?

FarrelBuch commented 8 years ago

Yes, that is the full message.

rasmusab commented 8 years ago

Still, could you just rerun install_github("rasmusab/bayesian_first_aid") and paste the whole output within two backticks (`) so that it formats as code?

FarrelBuch commented 8 years ago

OK here is what I got tonight

> install_github("rasmusab/bayesian_first_aid")
Downloading GitHub repo rasmusab/bayesian_first_aid@master
from URL https://api.github.com/repos/rasmusab/bayesian_first_aid/zipball/master
Installing BayesianFirstAid
"C:/PROGRA~1/R/R-33~1.0/bin/x64/R" --no-site-file  \
  --no-environ --no-save --no-restore --quiet CMD  \
  INSTALL  \
  "C:/Users/Farrel/AppData/Local/Temp/RtmpmSsg5D/devtools73c3266e56/rasmusab-bayesian_first_aid-6c7f844"  \
  --library="G:/Farrel  \
  Data/Documents/R/win-library/3.3"  \
  --install-tests 

* installing *source* package 'BayesianFirstAid' ...
** R
Warning: unable to re-encode 'bayes_prop_test.R' line 8
** inst
** preparing package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** testing if installed package can be loaded
*** arch - i386
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'G:/Farrel Data/Documents/R/win-library/3.3/BayesianFirstAid'
Error: Command failed (1)
rasmusab commented 8 years ago

I still have no clue why this occurs... Similar errors mentions problems with paths on windows:

https://groups.google.com/forum/embed/#!topic/rdevtools/Op_rzDbonW4 https://github.com/hadley/devtools/issues/353

But for your particular problem I still don't know...

jpneto commented 8 years ago

I'm updating my R/RStudio and reinstalling a lot of packages. When I tried to reinstall bayesian_first_aid I was stuck. I'm sending the output log below. In short, the problem, whatever it is, produces: "ERROR: loading failed for 'i386'" which me and google don't understand. Sometimes it crashes after printing "arch - i386". My .libPaths() is ok, according to the links above.

Anyway, at least there's a way to install the basic package (without vignettes, demos, etc.):

devtools::install_github("rasmusab/bayesian_first_aid", quick=TRUE)


The log with the error:

> devtools::install_github("rasmusab/bayesian_first_aid")

Downloading GitHub repo rasmusab/bayesian_first_aid@master
from URL https://api.github.com/repos/rasmusab/bayesian_first_aid/zipball/master
Installing BayesianFirstAid
"C:/PROGRA~1/R/R-33~1.0/bin/x64/R" --no-site-file --no-environ --no-save --no-restore  \
  --quiet CMD INSTALL  \
  "C:/Users/jpn.INFORMATICA/AppData/Local/Temp/RtmpUHgK0T/devtools158410685469/rasmusab-bayesian_first_aid-6c7f844"  \
  --library="C:/Program Files/R/R-3.3.0/library" --install-tests

* installing *source* package 'BayesianFirstAid' ...
** R
Warning: unable to re-encode 'bayes_prop_test.R' line 8
** inst
** preparing package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** testing if installed package can be loaded
*** arch - i386
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Program Files/R/R-3.3.0/library/BayesianFirstAid'
Error: Command failed (1)
rasmusab commented 8 years ago

@jpneto and @FarrelBuch , what operating systems are you on? (I'm guessing windows, from your output)

rasmusab commented 8 years ago

Also, are you able to install other packages from github without using the quick=TRUE argument, for example:

library(devtools)
install_github('ggplot2')
jpneto commented 8 years ago

@rasmusab, yes, I'm using Windows 7, 64bit

I already installed another package using install_github without the quick=TRUE.

rasmusab commented 8 years ago

I changed the source so that you hopefull shouldn't get the warning Warning: unable to re-encode 'bayes_prop_test.R' line 8 . Does this solve the problem?

jpneto commented 8 years ago

I'm afraid not... I forked your project and changed those chars yesterday, but the problem remained :-(

FarrelBuch commented 8 years ago

I'm using Windows 8 on one computer and 10 on another. I have been able to install other packages from github but when I get a chance I am willing to try again to make sure i am not confabulating memories from a few weeks ago. In the meantime I found a workaround. I simply copied the directory from my 3.2 installation into my 3.3 installation. Everything worked just fine after that.

On Wed, May 25, 2016, 07:33 João Pedro Neto notifications@github.com wrote:

I'm afraid not... I forked your project and changed those chars yesterday, but the problem remained :-(

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/rasmusab/bayesian_first_aid/issues/12#issuecomment-221546639

Farrel Buchinsky (412) 567-7870 (gets me everywhere)

FarrelBuch commented 8 years ago

I am able to install ggplot2 from github but alas not bayesian_first_aid. Here is my command and the response.

library(devtools)

install_github('hadley/ggplot2')

Downloading GitHub repo hadley/ggplot2@master from URL https://api.github.com/repos/hadley/ggplot2/zipball/master Installing ggplot2 "C:/PROGRA~1/R/R-33~1.0/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL \ "C:/Users/Farrel/AppData/Local/Temp/RtmpiQCZ7q/devtools27fc6504abe/hadley-ggplot2-b181e9a" --library="D:/Users/Farrel/My \ Documents/R/win-library/3.3" --install-tests

install_github('rasmusab/bayesian_first_aid')

Downloading GitHub repo rasmusab/bayesian_first_aid@master from URL https://api.github.com/repos/rasmusab/bayesian_first_aid/zipball/master Installing BayesianFirstAid "C:/PROGRA~1/R/R-33~1.0/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL \ "C:/Users/Farrel/AppData/Local/Temp/RtmpiQCZ7q/devtools27fc3cc548e2/rasmusab-bayesian_first_aid-01240df" --library="D:/Users/Farrel/My \ Documents/R/win-library/3.3" --install-tests

edb983 commented 7 years ago

Hi. Wondering if this was resolved? I am getting similar Error: Command failed (1)

This error was returned after successfully running these commands: devtools::install_github("vqv/ggbiplot") devtools::install_github("twitter/AnomalyDetection") devtools::install_github("hrbrmstr/taucharts") devtools::install_github("timelyportfolio/parcoords")

FYI: the rjags shows in my installed packages list in R Studio...

Here is the output from Console:

devtools::install_github("rasmusab/bayesian_first_aid") Downloading GitHub repo rasmusab/bayesian_first_aid@master from URL https://api.github.com/repos/rasmusab/bayesian_first_aid/zipball/master Installing BayesianFirstAid "C:/PROGRA~1/MICROS~1/MRO/R-33~1.0/bin/x64/R" --no-site-file --no-environ --no-save --no-restore \ --quiet CMD INSTALL \ "C:/Users/SQLmaster/AppData/Local/Temp/RtmpuCN16U/devtools32304436266f/rasmusab-bayesian_first_aid-d80c0fd" \ --library="C:/Users/SQLmaster/Documents/R/win-library/3.3" --install-tests

  • installing source package 'BayesianFirstAid' ... * R * inst * tests * preparing package for lazy loading Error : .onLoad failed in loadNamespace() for 'rjags', details: call: fun(libname, pkgname) error: Failed to locate any version of JAGS version 4

The rjags package is just an interface to the JAGS library Make sure you have installed JAGS-4.x.y.exe (for any x >=0, y>=0) from http://www.sourceforge.net/projects/mcmc-jags/files

Error : package 'rjags' could not be loaded ERROR: lazy loading failed for package 'BayesianFirstAid'

rasmusab commented 7 years ago

To me it doesn't seem like you have JAGS installed... But let's try it!

library(rjags)

# The model specification
model_string <- "model{
  for(i in 1:length(y)) {
    y[i] ~ dnorm(mu, tau)
  }
  mu ~ dnorm(0, 0.0001)
  sigma ~ dlnorm(0, 0.0625)
  tau <- 1 / pow(sigma, 2)
}"

# Running the model
model <- jags.model(textConnection(model_string), data = list(y = y), n.chains = 3, n.adapt= 10000)
update(model, 10000); # Burnin for 10000 samples
mcmc_samples <- coda.samples(model, variable.names=c("mu", "sigma"), n.iter=20000)

Does this run without problems?

edb983 commented 7 years ago

Thank you for the quick reply! Since posting my comment, I also installed Strawberry PERL and JAGS for Windows. Did not do a full restart ... is that required?

I launched R Studio, setup new script and pasted your suggestion. You may be right - seems to have thrown errors. here is the console output:

R version 3.3.0 (2016-05-03) -- "Supposedly Educational" Copyright (C) 2016 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R.

Microsoft R Open 3.3.0 Default CRAN mirror snapshot taken on 2016-06-01 The enhanced R distribution from Microsoft Visit https://mran.microsoft.com/ for information about additional features.

Multithreaded BLAS/LAPACK libraries detected. Using 2 cores for math algorithms. [Workspace loaded from ~/R/.RData]

library(rjags) Loading required package: coda Linked to JAGS 4.2.0 Loaded modules: basemod,bugs

The model specification

model_string <- "model{

  • for(i in 1:length(y)) {
  • y[i] ~ dnorm(mu, tau)
  • }
  • mu ~ dnorm(0, 0.0001)
  • sigma ~ dlnorm(0, 0.0625)
  • tau <- 1 / pow(sigma, 2)
  • }"

Running the model

model <- jags.model(textConnection(model_string), data = list(y = y), n.chains = 3, n.adapt= 10000) Error in jags.model(textConnection(model_string), data = list(y = y), : object 'y' not found update(model, 10000); # Burnin for 10000 samples Error in update(model, 10000) : object 'model' not found mcmc_samples <- coda.samples(model, variable.names=c("mu", "sigma"), n.iter=20000) Error in coda.samples(model, variable.names = c("mu", "sigma"), n.iter = 20000) : object 'model' not found

edb983 commented 7 years ago

Went back to check PATH to make sure JAGS is in path. Restarted system. Re-installing all CRAN packages... no errors so far... Re-installing github packages ... devtools::install_github("vqv/ggbiplot") devtools::install_github("twitter/AnomalyDetection") devtools::install_github("hrbrmstr/taucharts") devtools::install_github("timelyportfolio/parcoords") devtools::install_github("rasmusab/bayesian_first_aid")

all skipped with message like "Skipping install for github remote, the SHA1 (d80c0fde) has not changed since last install. Use force = TRUE to force installation"

Retrying the script you sent... can't seem to get past the model declaration ...?

Running the model

model <- jags.model(textConnection(model_string), data = list(y = y), n.chains = 3, n.adapt= 10000) Error in jags.model(textConnection(model_string), data = list(y = y), : object 'y' not found update(model, 10000); # Burnin for 10000 samples Error in update(model, 10000) : object 'model' not found mcmc_samples <- coda.samples(model, variable.names=c("mu", "sigma"), n.iter=20000) Error in coda.samples(model, variable.names = c("mu", "sigma"), n.iter = 20000) : object 'model' not found

dicemt commented 7 years ago

I encountered the same issue as @jpneto and @FarrelBuch, but reinstalling JAGS with both 32bit and 64bit versions worked for me. (Win 7 Pro, 64bit; R 3.3.2; Rstudio 1.0.44)

If you are using R 3.3.0 or later, please be sure to install JAGS-4.2.0-Rtools33.exe https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/

Hope this helps rjags

MastaP commented 7 years ago

Not sure if it's the same problem, but I'm unable to install the package on my Mac


Downloading GitHub repo rasmusab/bayesian_first_aid@master
from URL https://api.github.com/repos/rasmusab/bayesian_first_aid/zipball/master
Installing BayesianFirstAid
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ  \
  --no-save --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/cf/kj_wh1td3054dhy1_9qpgz4w0000gn/T/RtmptAWEmj/devtools497d362a2e0c/rasmusab-bayesian_first_aid-d80c0fd'  \
  --library='/Library/Frameworks/R.framework/Versions/3.3/Resources/library'  \
  --install-tests 

During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C" 
2: Setting LC_TIME failed, using "C" 
3: Setting LC_MESSAGES failed, using "C" 
4: Setting LC_MONETARY failed, using "C" 
* installing *source* package 'BayesianFirstAid' ...
** R
** inst
** tests
** preparing package for lazy loading
Error : .onLoad failed in loadNamespace() for 'rjags', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rjags/libs/rjags.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rjags/libs/rjags.so, 10): Library not loaded: /usr/local/lib/libjags.4.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.3/Resources/library/rjags/libs/rjags.so
  Reason: image not found
Error : package 'rjags' could not be loaded
ERROR: lazy loading failed for package 'BayesianFirstAid'
* removing '/Library/Frameworks/R.framework/Versions/3.3/Resources/library/BayesianFirstAid'
Error: Command failed (1)```
rasmusab commented 7 years ago

@MastaP That looks like you have a problem loading the rjags package. If you just run

library(rjags)

Do you get the same error?

MastaP commented 7 years ago

@rasmusab you're right. this helped http://dr-k-lo.blogspot.com.ee/2013/03/problems-loading-jags-into-r.html (I'm new to R)