Repository for the CopulaModel
R package by Harry Joe and Pavel Krupskii.
The content in this repository is originally located at https://copula.stat.ubc.ca/, under the heading "CopulaModel software". It's made available on GitHub in an effort to improve accessibility.
The files you see here integrate the 2015.09.03 "patches and additions" with the original CopulaModel
package.
If you have the prerequisite software installed (see below), executing the following R code should install the CopulaModel
package:
devtools::install_github("vincenzocoia/CopulaModel")
You'll need a couple things installed before installing CopulaModel
from this GitHub repo:
- gcc
- devtools
For Mac OS, you can use HomeBrew:
- Open Terminal
- Check that you have HomeBrew installed by typing
which brew
.
- If it returns a path, such as
/usr/local/bin/brew
, then it's installed. - If it says
brew not found
, you'll have to install HomeBrew.
- Install gcc by typing
brew install gcc
- If you get an error, hopefully HomeBrew will tell you how to fix it.
- You can check that gcc is successfully isntalled by typing
which gcc
.
Sorry, I don't have Windows instructions yet. I think Linux should work the same way as Mac OS here.
Run the following R code to install the devtools
package:
install.packages("devtools")
When tested on a Mac, the installation tries to look for "libraries" in the wrong place. You can tell if this is the case if you find the message "Library not loaded" somewhere in the error message. For example, halfway through the error message, you might see something like:
Library not loaded: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
That's the directory R is looking for the file libRblas.dylib
, yet this file is not in that location.
I figured out how to solve the problem, thanks to this Stack Overflow post.
Here's what you'll need to do:
- Find the actual location of the file R is looking for (
libRblas.dylib
in the above cases)- The above Stack Overflow post suggests using
locate
to find the file, but that didn't work for me. YMMV. - If that doesn't work, try checking below for a list of files I ended up having to find, and where I found them.
- If that doesn't work, try navigating to a path similar to the one that R is looking.
- The above Stack Overflow post suggests using
- Link the actual location of the file to the place R is looking, with the command
ln actual/path/to/file path/where/R/is/looking
- This may involve creating folders to get to the place where R is looking.
- You may need
sudo ln
instead of justln
.
- Try to install the package again. If you get another
Library not loaded
error, repeat (I had to do this three times).
The libraries that were missing on my mac were:
libgfortran.3.dylib
, although was present on my mac aslibgfortran.5.dylib
(a newer version?)- R was looking for it at
/usr/local/gfortran/lib/libgfortran.3.dylib
- I found the file at
/usr/local/Cellar/gcc/10.2.0/lib/gcc/10/libgfortran.5.dylib
- R was looking for it at
libquadmath.0.dylib
- R was looking for it at
/usr/local/gfortran/lib/libquadmath.0.dylib
- I found the file at
/usr/local/Cellar/gcc/10.2.0/lib/gcc/10/libquadmath.0.dylib
- R was looking for it at
libR.dylib
- R was looking for it at
/Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libR.dylib
- I found the file at
/Library/Frameworks/R.framework/Versions/Current/Resources/lib/libR.dylib
- I had to make the directory
3.5/Resources/lib/
in/Library/Frameworks/R.framework/Versions/
usingmkdir
.
- R was looking for it at
So, all in all:
sudo ln /usr/local/Cellar/gcc/10.2.0/lib/gcc/10/libgfortran.5.dylib /usr/local/gfortran/lib/libgfortran.3.dylib
ln /usr/local/Cellar/gcc/10.2.0/lib/gcc/10/libquadmath.0.dylib /usr/local/gfortran/lib/libquadmath.0.dylib
mkdir -p /Library/Frameworks/R.framework/Versions/3.5/Resources/lib
ln /Library/Frameworks/R.framework/Versions/Current/Resources/lib/libR.dylib /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libR.dylib
Sometimes when I tried to install the package, I wouldn't get the "Library not loaded" error, but would get a "Rank mismatch" error in a Fortran script. You can see the error message below.
To elicit the more desirable "library not loaded" error, I downloaded this very CopulaModel
repository as a zip file, unzipped it, and called install.packages("~/Downloads/CopulaModel-master", type = "source", repos = NULL)
> devtools::install_github("vincenzocoia/CopulaModel")
Downloading GitHub repo vincenzocoia/CopulaModel@HEAD
✓ checking for file ‘/private/var/folders/dx/zr_sf92j4t95y6z16w_j6b780000gn/T/RtmpGaNFDT/remotes3fda601e7e12/vincenzocoia-CopulaModel-c0c2150/DESCRIPTION’ ...
─ preparing ‘CopulaModel’:
✓ checking DESCRIPTION meta-information ...
─ cleaning src
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ looking to see if a ‘data/datalist’ file should be added
─ building ‘CopulaModel_0.6.tar.gz’
* installing *source* package ‘CopulaModel’ ...
** using staged installation
** libs
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c R_exchmvn.c -o R_exchmvn.o
gfortran -mmacosx-version-min=10.13 -fno-optimize-sibling-calls -fPIC -Wall -g -O2 -c Rgauss-trvine-nonuniq.f90 -o Rgauss-trvine-nonuniq.o
Rgauss-trvine-nonuniq.f90:107:43:
103 | call intpr("within eps for ",15,j,1)
| 2
......
107 | call intpr("next row",8, A2(i,:),d)
| 1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)
Rgauss-trvine-nonuniq.f90:124:34:
103 | call intpr("within eps for ",15,j,1)
| 2
......
124 | call intpr("perm",4,aperm,d)
| 1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)
Rgauss-trvine-nonuniq.f90:154:33:
103 | call intpr("within eps for ",15,j,1)
| 2
......
154 | call intpr("next row",8, A1(i,:),d)
| 1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)
Rgauss-trvine-nonuniq.f90:164:51:
103 | call intpr("within eps for ",15,j,1)
| 2
......
164 | call intpr("approx nonunique for j=1,...,d-2",32,nonuniq,d-2)
| 1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)
make: *** [Rgauss-trvine-nonuniq.o] Error 1
ERROR: compilation failed for package ‘CopulaModel’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/CopulaModel’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/CopulaModel’
Error: Failed to install 'CopulaModel' from GitHub:
(converted from warning) installation of package ‘/var/folders/dx/zr_sf92j4t95y6z16w_j6b780000gn/T//RtmpGaNFDT/file3fda74f571f1/CopulaModel_0.6.tar.gz’ had non-zero exit status