GetConstIdx: Whether a hyper-prior distribution is set constant

Description Usage Arguments Value Examples

View source: R/RcppExports.R

Description

Check if a prior distribution for a location and scale parameter is set constant. testHyper checks if the parameter names in location and in scale match.

Usage

1
GetConstIdx(ppprior)

Arguments

ppprior

hyper-parameter prior distributions. First element is a location prior and second is a scale prior.

Value

isConstant gives a npar x 2 matrix;

Examples

 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
27
28
29
30
31
32
33
34
35
36
37
38
39
model <- BuildModel(p.map = list(A = "1", B = "R", t0 = "1",
  mean_v = c("F", "M"), sd_v = "M", st0 = "1"),
  match.map = list(M = list(s1=1, s2=2)),
  factors   = list(S = c("s1", "s2"),F = c("f1", "f2")),
    constants = c(sd_v.false = 1, st0 = 0),
    responses = c("r1", "r2"),
    type      = "norm")
  npar <- length(GetPNames(model))

## Population distribution, rate effect on F
  pop.mean <- c(A=.4, B.r1=.6, B.r2=.8, t0=.3, mean_v.f1.true=1.5,
    mean_v.f2.true=1, mean_v.f1.false=0, mean_v.f2.false=0,
    sd_v.true = .25)
    pop.scale <-c(A=.1, B.r1=.1, B.r2=.1, t0=.05, mean_v.f1.true=.2,
      mean_v.f2.true=.2, mean_v.f1.false=.2, mean_v.f2.false=.2,
      sd_v.true = .1)
    p.prior <- BuildPrior(
        dists = rep("tnorm", npar),
        p1    = pop.mean,
        p2    = pop.scale*5,
        lower = c(0,0,0,.1,NA,NA,NA,NA,0),
        upper = c(NA,NA,NA,NA,NA,NA,NA,NA,NA))
    mu.prior <- BuildPrior(
        dists = rep("tnorm", npar),
        p1    = pop.mean,
        p2    = c(1,1,1,1,2,2,2,2,1),
        lower = c(0,0,0,.1,NA,NA,NA,NA,0),
        upper = c(NA,NA,NA,NA,NA,NA,NA,NA,NA))
    sigma.prior <- BuildPrior(
        dists = rep("beta", npar),
        p1    = c(A=1, B.r1=1, B.r2=1, t0=1, mean_v.f1.true=1,
          mean_v.f2.true=1, mean_v.f1.false=1, mean_v.f2.false=1,
          sd_v.true = 1),
          p2    = rep(1, npar))
    pp.prior <- list(mu.prior, sigma.prior)

    test1 <- GetConstIdx(pp.prior)
    test2 <- lapply(pp.prior,function(x){
      lapply(x,function(y){attr(y,"dist") == "constant"})})

ggdmc documentation built on Sept. 2, 2018, 1:03 a.m.