Skip to content

Do gradient check for parametric families #54

@willwerscheid

Description

@willwerscheid

When mu is fixed, check the gradient at pi0 = 0 and pi0 = 1. This would have the nice side effect of fixing a minimum scale for the slab, which would help stabilize the problem for pi0 near 1.

Example code:

pn_llik_fn = function(x) {
  if (x[1] >= 1) {
    return(sum(dnorm(dat, sd = s, log = TRUE)))
  } else {
    return(sum(
      logscale_add(log(x[1]) + dnorm(dat, sd = s, log = TRUE),
                   log(1 - x[1]) + dnorm(dat, sd = sqrt(s^2 + x[2]), log = TRUE))
    ))
  }
}

numDeriv::grad(pn_llik_fn, x = c(1, min_sigma2))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions