Description Usage Arguments Details Value See Also

**This function requires data to have been dumped to disk**: see `?dump2dir`

and `?setoutput`

. This function computes the
Monte Carlo Average of a function where data from a run of `lgcpPredict`

has been dumped to disk.

1 2 | ```
## S3 method for class 'lgcpPredict'
expectation(obj, fun, maxit = NULL, ...)
``` |

`obj` |
an object of class lgcpPredict |

`fun` |
a function accepting a single argument that returns a numeric vector, matrix or array object |

`maxit` |
Not used in ordinary circumstances. Defines subset of samples over which to compute expectation. Expectation is computed using information from iterations 1:maxit, where 1 is the first non-burn in iteration dumped to disk. |

`...` |
additional arguments |

A Monte Carlo Average is computed as:

*E_{π(Y_{t_1:t_2}|X_{t_1:t_2})}[g(Y_{t_1:t_2})] \approx \frac1n∑_{i=1}^n g(Y_{t_1:t_2}^{(i)})*

where *g* is a function of interest, *Y_{t_1:t_2}^{(i)}* is the *i*th retained sample from the target
and *n* is the total number of retained iterations. For example, to compute the mean of *Y_{t_1:t_2}* set,

*g(Y_{t_1:t_2}) = Y_{t_1:t_2},*

the output from such a Monte Carlo average would be a set of *t_2-t_1* grids, each cell of which
being equal to the mean over all retained iterations of the algorithm (NOTE: this is just an example computation, in
practice, there is no need to compute the mean on line explicitly, as this is already done by default in `lgcpPredict`

).

the expectated value of that function

lgcpPredict, dump2dir, setoutput

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.