09 April 2011

Know your neighbour

by Jaromir Benes

The neighbourhood function is a simple tool for examining and visualising the behaviour of an objective function (such as data likelihood or posterior density) in the neighbourhood of parameter estimates.

After you estimate a set of parameters, you may want to know – and see – how the objective function behaves around the optimum and how informative it is about individual parameters. (Of course, there are more sophisticated tools, but this one is quick, clean, simple, and intuitive.) To run the neighbourhood function, you first fneed to define what the "neighbourhood" is: you do so by entering a vector of numbers (which is the function's third input argument, NEIGH) describing the multiples of parameter estimates at which the objective function will be evaluated. For example, specifying 0.95:0.001:1.05 means that the objective function will be evaluated 101 times for each parameter at points plus minus 5 percent around the estimated value.

The function then returns a database in which each parameter is a cell array with two elements. The first cell is the parameter values, i.e. simply the respective parameter estimate multiplied by the neighbourhood vector. The second cell is a matrix with two column vectors: the first column is the values of the objective function, the second column is the values of the data likelihood component of the objective function (obviously, if you run estimation without any kinds of priors or penalty functions, the data likelihood component will coincide with the overall objective function). Note that whenever the neighbourhood vector runs out of the respective parameter's bounds (if there are any imposed on that parameter) the objective function is not evaluated, and a NaN is returned.

How does the neighbourhood function know what our objective function and our priors were when we ran estimate? Especially when the objective function can have a wide range of forms, such as likelihood, posterior density, plain prediction errors, or any of these combined with different types of priors or penalties? The trick is that we pass in not only a model object (the first input argument), and a neighbourhood vector (the third input argument) but also a posterior object returned from estimate. And this posterior object stores all the information necessary: parameter estimates, data, priors, parameter constraints, etc., and allows therefore the neighbourhood function to compute the local behaviour. By the way – another place where you can use a posterior object is running the IRIS posterior simulator, arwm.

By default, the neighbourhood function also produces a set of graphs visualising the local behaviour by plotting the overall objective function curve, the data likelihood component curve, a star indicating the estimated parameter value, and also the lower or upper bound should either fall within the neighbourhood. Unless an estimate hits its lower or upper bound, you will see the stars sitting in the trough of the objective function. Remember that the data likelihood component is always shifted up or down by an arbitrary constant to make it fit nicely in the graph. This means the vertical locations of the two curves have no meaning – it's only their curvatures that you can infer some information from. Finally, the vertical axes of all graphs are automatically adjusted (unless you say no) and have identical limits. This is helpful for you to be able to see at a glance the relative curvatures of the objective functions across all parameters.

You can learn more by reading the documentation, and checking out the example file estimate_params in Jaromir's "Simple SPBC" mini-tutorial.

No comments:

Post a Comment