mphcrm.callback: Default callback function for mphcrm

Description Usage Arguments Details Note Examples

Description

The default callback function prints a line whenever estimation with a masspoint is completed.

Usage

1
mphcrm.callback(fromwhere, opt, dataset, control, ...)

Arguments

fromwhere

a string which identifies which step in the algorithm it is called from. fromwhere=='full' means that it is a full estimation of all the parameters. There are also other codes, when adding a point, when removing duplicate points. When some optimization is completed it is called with the return status from optim (and in some occasions from nloptr).

opt

Typically the result of a call to optim.

dataset

The dataset in a structured form.

control

The control argument given to mphcrm

...

other arguments

Details

If you write your own callback function it will replace the default function, but you can of course call the default callback from your own callback function, and in addition print your own diagnostics, or save the intermediate opt in a file, or whatever. You can even stop the estimation by doing a stop('<some message>'), and mphcrm will return with the estimates done so far, provided the control parameter trap.interrupt=TRUE.

Note

Beware that control contains a reference to the callback function, which may contain a reference to the top-level environment, which may contain the full dataset. So if you save control to file, you may end up saving the entire dataset.

Examples

1
2
3
4
5
6
7
8
9
callback <- function(fromwhere, opt, dataset, control, ...) {
  # call the standard callback to print a diagnostic line
  mphcrm.callback(fromwhere, opt, dataset, control, ...)
  # print the distribution and two coefficients
  if(fromwhere == 'full') {
    print(round(mphdist(opt),6))
    print(summary(opt)$coefs[c('job.alpha','job.x1'),])
  }
}

durmod documentation built on March 31, 2020, 5:23 p.m.