SachaEpskamp / IsingSampler

Sampling methods and distribution functions for the Ising model
4 stars 3 forks source link

Constrain not working for CFTP and direct sampling #1

Open YunyiShen opened 5 years ago

YunyiShen commented 5 years ago

Thanks for the great package!

Here is an issue, when giving constrain to IsingSampler with method='CFTP' or method='direct', the constrain does not really work. One easy example is:

>set.seed(42)
>IsingSampler(10,graph = matrix(0,1,1),thresholds = matrix(1,1,1),constrain = matrix(0,10,1),method ="CFTP" )

will give output (vector version shown here)

[1] 1 0 1 1 1 1 1 1 1 1

which is exactly the same when give all NAs as constrain but supposed to be all 0s (MH works well).

Seems in the inner function IsingEx does not use the argument when running the algorithm while IsingMet has. May be fixed by add the constrain in the normal chain within CFTP or by using the fact that mathematically it can be viewed as another Ising model with smaller graph and some extra external field caused by constrains?

Another small issue, constrain is not checked consistency with responses for all methods, e.g. if run:

>IsingSampler(10,graph = matrix(0,1,1),thresholds = matrix(1,1,1),constrain = matrix(100,10,1) )

we will get:

[1] 100 100 100 100 100 100 100 100 100 100
SachaEpskamp commented 5 years ago

Thanks for reporting! Updating IsingSampler is not an immediate priority now, so I will put this on the todo list for the next time I update the package.