Suppose the vector *(x_1, …, x_n)* is such that *x_i* is drawn independently from
a normal distribution with mean *θ_i* and variance 1.
The prior distribution of the *theta_i* is a mixture with probability *1-w*
of zero and probability *w* of a given symmetric heavy-tailed distribution.
This routine finds the marginal maximum likelihood estimate of the parameter *w*.

1 | ```
wfromx(x, prior = "laplace", a = 0.5)
``` |

`x` |
vector of data |

`prior` |
specification of prior to be used; can be |

`a` |
scale factor if Laplace prior is used. Ignored if Cauchy prior is used. |

The weight is found by marginal maximum likelihood. The search is over weights corresponding to thresholds
in the range
*[0, √{2 \log n}]*,
where *n* is the length of the data vector.

The search is by binary search for a solution to the equation
*S(w)=0*, where *S* is the derivative of the log likelihood.
The binary search is on a logarithmic scale in *w*.

If the Laplace prior is used, the scale parameter is fixed at the value given for `a`

, and
defaults to 0.5 if no value is provided. To estimate `a`

as well as `w`

by marginal
maximum likelihood, use the routine `wandafromx`

.

The numerical value of the estimated weight.

Bernard Silverman

See `ebayesthresh`

and http://www.bernardsilverman.com

`wandafromx`

, `tfromx`

, `tfromw`

, `wfromt`

1 |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.