Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
SystemRequirements: JAGS >= 4.3.1 (https://mcmc-jags.sourceforge.io/)
SystemRequirements: JAGS >= 5.0.0 (https://mcmc-jags.sourceforge.io/)
NeedsCompilation: yes
Depends:
R (>= 4.0.0)
Expand Down
18 changes: 6 additions & 12 deletions src/Makevars.ucrt
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@
###
### Note: This windows makefile requires the JAGS_ROOT variable to be set
###
### This file allows compilation with JAGS 4 (or later) without modifying RoBMA.
### This file allows compilation with JAGS 5 (or later) without modifying RoBMA.
### To force the package to compile assuming a given JAGS version is installed, use the
### JAGS_MAJOR_FORCED environmental variable. This might be necessary on windows if you have
### JAGS installed in a non-standard location.
###
######################################################################################################

## Conditionally set the JAGS_ROOT variable (if it is not already set) to a location specified by the CRAN team:
JAGS_ROOT ?= /c/progra~1/JAGS/JAGS-4.3.1

## Use the old ABI to match JAGS 4.x compilation on Windows:
#PKG_CXXFLAGS = -D_GLIBCXX_USE_CXX11_ABI=0
PKG_CXXFLAGS=
## Note: this behaviour will be changed (and RoBMA updated) before JAGS 5 is released
## If you are trying to compile this version of RoBMA against JAGS 5 you may need to remove this PKG_CXXFLAGS line
JAGS_ROOT ?= /c/progra~1/JAGS/JAGS-5.0.0

###############
### Flags
Expand Down Expand Up @@ -52,7 +46,7 @@ JAGS_FULL_VERS = $(word $(words $(JAGS_ROOT_SUB)),$(JAGS_ROOT_SUB))
JAGS_MAJOR_ASSUMED = $(strip $(word 2,$(subst .,$(space),$(subst -,$(space),$(JAGS_FULL_VERS)))))
else
# Otherwise make an assumption about JAGS_MAJOR and give a warning:
JAGS_MAJOR_ASSUMED = $(strip 4)
JAGS_MAJOR_ASSUMED = $(strip 5)
$(warning The major version of JAGS could not be determined from $(JAGS_ROOT) - assuming version $(JAGS_MAJOR_ASSUMED) (otherwise the Makevars.win file may need to be modified))
endif

Expand All @@ -62,14 +56,14 @@ endif

# Set the CPPFLAGS accordingly
# Prepending 0 to JAGS_MAJOR_VERSION prevents it being set as blank (the C++ code requires a number)
JAGS_MAJOR_ASSUMED := 4
JAGS_MAJOR_ASSUMED := 5
PKG_CPPFLAGS=-I"$(JAGS_ROOT)/include" -D JAGS_MAJOR_ASSUMED=$(JAGS_MAJOR_ASSUMED) -D JAGS_MAJOR_FORCED=0$(JAGS_MAJOR_VERSION) -DR_NO_REMAP

PKG_LIBS=-L"$(JAGS_ROOT)/${R_ARCH}/bin" -ljags-$(JAGS_MAJOR) -ljrmath-0 -llapack

###############
### Objects to be compiled
### NB: the objects in distributions/jags are only necessary for JAGS <=3, and are excluded by the sources when compiling against JAGS >= 4
### NB: the objects in distributions/jags are only necessary for JAGS <=3, and are excluded by the sources when compiling against JAGS >= 5
###############

OBJECTS = distributions/DMN.o distributions/DWMN1.o distributions/DWMN2.o distributions/DMNv.o distributions/DWMN1v.o distributions/DWMN2v.o \
Expand All @@ -92,7 +86,7 @@ OBJECTS = distributions/DMN.o distributions/DWMN1.o distributions/DWMN2.o distri
###############

# PKG_CPPFLAGS=-I"$(JAGS_ROOT)/include"
# PKG_LIBS=-L"$(JAGS_ROOT)/${R_ARCH}/bin" -ljags-4 -llapack
# PKG_LIBS=-L"$(JAGS_ROOT)/${R_ARCH}/bin" -ljags-5 -llapack
# OBJECTS = distributions/DMN.o distributions/DWMN1.o distributions/DWMN2.o distributions/DMNv.o distributions/DWMN1v.o distributions/DWMN2v.o \
# distributions/DWN1.o distributions/DWN2.o distributions/DWT1.o distributions/DWT2.o \
# distributions/DWN.o distributions/DWWN1.o distributions/DWWN2.o \
Expand Down
13 changes: 4 additions & 9 deletions src/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
######################################################################################################

## Conditionally set the JAGS_ROOT variable (if it is not already set) to a location specified by the CRAN team:
JAGS_ROOT ?= /c/progra~1/JAGS/JAGS-4.3.1

## Use the old ABI to match JAGS 4.x compilation on Windows:
PKG_CXXFLAGS = -D_GLIBCXX_USE_CXX11_ABI=0
## Note: this behaviour will be changed (and RoBMA updated) before JAGS 5 is released
## If you are trying to compile this version of RoBMA against JAGS 5 you may need to remove this PKG_CXXFLAGS line
JAGS_ROOT ?= /c/progra~1/JAGS/JAGS-5.0.0

###############
### Flags
Expand Down Expand Up @@ -51,7 +46,7 @@ JAGS_FULL_VERS = $(word $(words $(JAGS_ROOT_SUB)),$(JAGS_ROOT_SUB))
JAGS_MAJOR_ASSUMED = $(strip $(word 2,$(subst .,$(space),$(subst -,$(space),$(JAGS_FULL_VERS)))))
else
# Otherwise make an assumption about JAGS_MAJOR and give a warning:
JAGS_MAJOR_ASSUMED = $(strip 4)
JAGS_MAJOR_ASSUMED = $(strip 5)
$(warning The major version of JAGS could not be determined from $(JAGS_ROOT) - assuming version $(JAGS_MAJOR_ASSUMED) (otherwise the Makevars.win file may need to be modified))
endif

Expand All @@ -72,7 +67,7 @@ PKG_LIBS=-L"$(JAGS_ROOT)/${R_ARCH}/bin" -ljags-$(JAGS_MAJOR) -ljrmath-0 -llapack
###############

OBJECTS = distributions/DMN.o distributions/DWMN1.o distributions/DWMN2.o distributions/DMNv.o distributions/DWMN1v.o distributions/DWMN2v.o \
distributions/DWN1.o distributions/DWN2.o distributions/DWT1.o distributions/DWT2.o \
distributions/DWN1.o distributions/DWN2.o distributions/DWT1.o distributions/DWT2.o \
distributions/DWN.o distributions/DWWN1.o distributions/DWWN2.o \
distributions/DWB.o \
distributions/DWNMIX.o distributions/DWWNMIX.o \
Expand All @@ -91,7 +86,7 @@ OBJECTS = distributions/DMN.o distributions/DWMN1.o distributions/DWMN2.o distri
###############

# PKG_CPPFLAGS=-I"$(JAGS_ROOT)/include"
# PKG_LIBS=-L"$(JAGS_ROOT)/${R_ARCH}/bin" -ljags-4 -ljrmath-0 -llapack
# PKG_LIBS=-L"$(JAGS_ROOT)/${R_ARCH}/bin" -ljags-5 -ljrmath-0 -llapack
# OBJECTS = distributions/DMN.o distributions/DWMN1.o distributions/DWMN2.o distributions/DMT2v.o distributions/DWMT1v.o distributions/DWMT2v.o \
# distributions/DWN1.o distributions/DWN2.o distributions/DWT1.o distributions/DWT2.o \
# distributions/DWN.o distributions/DWWN1.o distributions/DWWN2.o \
Expand Down
32 changes: 12 additions & 20 deletions src/distributions/DMN.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
namespace jags {
namespace RoBMA {

std::vector<unsigned int> DMN::dim(std::vector<std::vector<unsigned int> > const &dims) const
std::vector<unsigned long> DMN::dim(std::vector<std::vector<unsigned long> > const &dims) const
{
return std::vector<unsigned int>(1,dims[0][0]);
return std::vector<unsigned long>(1,dims[0][0]);
}

bool DMN::checkParameterDim (std::vector<std::vector<unsigned int> > const &dims) const
bool DMN::checkParameterDim (std::vector<std::vector<unsigned long> > const &dims) const
{
bool sigma_OK = true; // check that sigma and mu dimension matches

Expand All @@ -29,7 +29,7 @@ namespace jags {
return sigma_OK;
}

bool DMN::checkParameterValue(std::vector<double const *> const &par, std::vector<std::vector<unsigned int> > const &dims) const
bool DMN::checkParameterValue(std::vector<double const *> const &par, std::vector<std::vector<unsigned long> > const &dims) const
{
const double *sigma = par[1];

Expand All @@ -49,8 +49,8 @@ namespace jags {

DMN::DMN():ArrayDist("dmnorm", 2) {}

double DMN::logDensity(double const *x, unsigned int length, PDFType type, std::vector<double const *> const &par,
std::vector<std::vector<unsigned int> > const &dims, double const *lower, double const *upper) const
double DMN::logDensity(double const *x, PDFType type, std::vector<double const *> const &par,
std::vector<std::vector<unsigned long> > const &dims) const
{
// reassign the addresses to pointers
const double *mu = par[0];
Expand All @@ -64,33 +64,25 @@ namespace jags {
return log_lik;
}

void DMN::randomSample(double *x, unsigned int length, std::vector<double const *> const &par,
std::vector<std::vector<unsigned int> > const &dims,
double const *lower, double const *upper,
void DMN::randomSample(double *x, std::vector<double const *> const &par,
std::vector<std::vector<unsigned long> > const &dims,
RNG *rng) const
{
// not implemented
}

void DMN::support(double *lower, double *upper, unsigned int length,
void DMN::support(double *lower, double *upper,
std::vector<double const *> const &par,
std::vector<std::vector<unsigned int> > const &dims) const
std::vector<std::vector<unsigned long> > const &dims) const
{
unsigned long length = product(dim(dims));
// no idea whether this is correct
for (unsigned int i = 0; i < length; ++i) {
for (unsigned long i = 0; i < length; ++i) {
lower[i] = JAGS_NEGINF;
upper[i] = JAGS_POSINF;
}
}

void DMN::typicalValue(double *x, unsigned int length,
std::vector<double const *> const &par,
std::vector<std::vector<unsigned int> > const &dims,
double const *lower, double const *upper) const
{
// not implemented
}

bool DMN::isSupportFixed(std::vector<bool> const &fixmask) const
{
return true;
Expand Down
27 changes: 11 additions & 16 deletions src/distributions/DMN.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,21 @@ class DMN : public ArrayDist {
public:
DMN();

double logDensity(double const *x, unsigned int length, PDFType type,
double logDensity(double const *x, PDFType type,
std::vector<double const *> const &parameters,
std::vector<std::vector<unsigned int> > const &dims,
double const *lower, double const *upper) const;
void randomSample(double *x, unsigned int length,
std::vector<std::vector<unsigned long> > const &dims) const override;
void randomSample(double *x,
std::vector<double const *> const &parameters,
std::vector<std::vector<unsigned int> > const &dims,
double const *lower, double const *upper, RNG *rng) const;
void typicalValue(double *x, unsigned int length,
std::vector<double const *> const &parameters,
std::vector<std::vector<unsigned int> > const &dims,
double const *lower, double const *upper) const;
bool checkParameterDim(std::vector<std::vector<unsigned int> > const &dims) const;
std::vector<std::vector<unsigned long> > const &dims,
RNG *rng) const override;
bool checkParameterDim(std::vector<std::vector<unsigned long> > const &dims) const;
bool checkParameterValue(std::vector<double const *> const &parameters,
std::vector<std::vector<unsigned int> > const &dims) const;
std::vector<unsigned int> dim(std::vector<std::vector<unsigned int> > const &dims) const;
void support(double *lower, double *upper, unsigned int length,
std::vector<std::vector<unsigned long> > const &dims) const override;
std::vector<unsigned long> dim(std::vector<std::vector<unsigned long> > const &dims) const override;
void support(double *lower, double *upper,
std::vector<double const *> const &parameters,
std::vector<std::vector<unsigned int> > const &dims) const;
bool isSupportFixed(std::vector<bool> const &fixmask) const;
std::vector<std::vector<unsigned long> > const &dims) const override;
bool isSupportFixed(std::vector<bool> const &fixmask) const override;
};

}}
Expand Down
40 changes: 16 additions & 24 deletions src/distributions/DMNv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
namespace jags {
namespace RoBMA {

std::vector<unsigned int> DMNv::dim(std::vector<std::vector<unsigned int> > const &dims) const
std::vector<unsigned long> DMNv::dim(std::vector<std::vector<unsigned long> > const &dims) const
{
return std::vector<unsigned int>(1,dims[0][0]);
return std::vector<unsigned long>(1,dims[0][0]);
}


bool DMNv::checkParameterDim (std::vector<std::vector<unsigned int> > const &dims) const
bool DMNv::checkParameterDim (std::vector<std::vector<unsigned long> > const &dims) const
{
bool se2_OK = true; // check that standard errors squared and mu dimension matches
bool tau2_OK = true; // check that tau squared is a single double
Expand All @@ -35,7 +35,7 @@ namespace jags {
}


bool DMNv::checkParameterValue(std::vector<double const *> const &par, std::vector<std::vector<unsigned int> > const &dims) const
bool DMNv::checkParameterValue(std::vector<double const *> const &par, std::vector<std::vector<unsigned long> > const &dims) const
{
const double *tau2 = par[2];
const double *rho = par[3];
Expand All @@ -52,8 +52,8 @@ namespace jags {

DMNv::DMNv():ArrayDist("dmnorm_v", 5) {}

double DMNv::logDensity(double const *x, unsigned int length, PDFType type, std::vector<double const *> const &par,
std::vector<std::vector<unsigned int> > const &dims, double const *lower, double const *upper) const
double DMNv::logDensity(double const *x, PDFType type, std::vector<double const *> const &par,
std::vector<std::vector<unsigned long> > const &dims) const
{
// reassign the addresses to pointers
const double *mu = par[0];
Expand Down Expand Up @@ -96,31 +96,23 @@ namespace jags {
return log_lik;
}

void DMNv::randomSample(double *x, unsigned int length, std::vector<double const *> const &par,
std::vector<std::vector<unsigned int> > const &dims,
double const *lower, double const *upper,
void DMNv::randomSample(double *x, std::vector<double const *> const &par,
std::vector<std::vector<unsigned long> > const &dims,
RNG *rng) const
{
// not implemented
}

void DMNv::support(double *lower, double *upper, unsigned int length,
void DMNv::support(double *lower, double *upper,
std::vector<double const *> const &par,
std::vector<std::vector<unsigned int> > const &dims) const
std::vector<std::vector<unsigned long> > const &dims) const
{
// no idea whether this is correct
for (unsigned int i = 0; i < length; ++i) {
lower[i] = JAGS_NEGINF;
upper[i] = JAGS_POSINF;
}
}

void DMNv::typicalValue(double *x, unsigned int length,
std::vector<double const *> const &par,
std::vector<std::vector<unsigned int> > const &dims,
double const *lower, double const *upper) const
{
// not implemented
unsigned long length = product(dim(dims));
// no idea whether this is correct
for (unsigned long i = 0; i < length; ++i) {
lower[i] = JAGS_NEGINF;
upper[i] = JAGS_POSINF;
}
}

bool DMNv::isSupportFixed(std::vector<bool> const &fixmask) const
Expand Down
26 changes: 10 additions & 16 deletions src/distributions/DMNv.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,20 @@ class DMNv : public ArrayDist {
public:
DMNv();

double logDensity(double const *x, unsigned int length, PDFType type,
double logDensity(double const *x, PDFType type,
std::vector<double const *> const &parameters,
std::vector<std::vector<unsigned int> > const &dims,
double const *lower, double const *upper) const;
void randomSample(double *x, unsigned int length,
std::vector<std::vector<unsigned long> > const &dims) const override;
void randomSample(double *x,
std::vector<double const *> const &parameters,
std::vector<std::vector<unsigned int> > const &dims,
double const *lower, double const *upper, RNG *rng) const;
void typicalValue(double *x, unsigned int length,
std::vector<double const *> const &parameters,
std::vector<std::vector<unsigned int> > const &dims,
double const *lower, double const *upper) const;
bool checkParameterDim(std::vector<std::vector<unsigned int> > const &dims) const;
std::vector<std::vector<unsigned long> > const &dims, RNG *rng) const override;
bool checkParameterDim(std::vector<std::vector<unsigned long> > const &dims) const override;
bool checkParameterValue(std::vector<double const *> const &parameters,
std::vector<std::vector<unsigned int> > const &dims) const;
std::vector<unsigned int> dim(std::vector<std::vector<unsigned int> > const &dims) const;
void support(double *lower, double *upper, unsigned int length,
std::vector<std::vector<unsigned long> > const &dims) const override;
std::vector<unsigned long> dim(std::vector<std::vector<unsigned long> > const &dims) const override;
void support(double *lower, double *upper,
std::vector<double const *> const &parameters,
std::vector<std::vector<unsigned int> > const &dims) const;
bool isSupportFixed(std::vector<bool> const &fixmask) const;
std::vector<std::vector<unsigned long> > const &dims) const override;
bool isSupportFixed(std::vector<bool> const &fixmask) const override;
};

}}
Expand Down
Loading