| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.inference.distribution; |
| 27 |
|
| 28 |
import dr.math.distributions.Distribution; |
| 29 |
import dr.inference.model.Parameter; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public class ModelSpecificPseudoPriorLikelihood extends DistributionLikelihood{ |
| 35 |
|
| 36 |
private int[] models; |
| 37 |
protected Distribution prior; |
| 38 |
protected Distribution pseudoPrior; |
| 39 |
private Parameter modelIndicator; |
| 40 |
|
| 41 |
public ModelSpecificPseudoPriorLikelihood( |
| 42 |
Distribution prior, |
| 43 |
Distribution pseudoPrior, |
| 44 |
Parameter modelIndicator, |
| 45 |
int[] models){ |
| 46 |
super(prior); |
| 47 |
this.prior = prior; |
| 48 |
this.pseudoPrior = pseudoPrior; |
| 49 |
this.models = models; |
| 50 |
this.modelIndicator = modelIndicator; |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
public double calculateLogLikelihood() { |
| 60 |
boolean inModel = false; |
| 61 |
int modelCode = (int)modelIndicator.getParameterValue(0); |
| 62 |
for(int i = 0; i < models.length; i++){ |
| 63 |
if(models[i] == modelCode){ |
| 64 |
inModel = true; |
| 65 |
break; |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
if(inModel){ |
| 70 |
distribution = prior; |
| 71 |
}else{ |
| 72 |
distribution = pseudoPrior; |
| 73 |
} |
| 74 |
double logL = super.calculateLogLikelihood(); |
| 75 |
return logL; |
| 76 |
} |
| 77 |
|
| 78 |
} |