![]() |
|
sets up the estimate structure which outputs from the various regressions and MLEs.
| void apop_draw | ( | double * | out, | |
| gsl_rng * | r, | |||
| apop_model * | m | |||
| ) |
draw from a model. If the model has its own RNG, then you're good to go; if not, use apop_arms_draw to generate random draws.
That function has a lot of caveats: most notably, the input data will be univariate, and your likelihood function must be nonnegative and sum to one. If those aren't appropriate, then don't use this default. [A more forgiving default is on the to-do list.]
| apop_model* apop_estimate | ( | apop_data * | d, | |
| apop_model | m | |||
| ) |
estimate the parameters of a model given data.
This is a brief convenience function, which expands to m.estimate(d,&m). If your model has no estimate method, then I assume apop_maximum_likelihood(d, m), with the default MLE params.
| d | The data | |
| m | The model |
parameters element filled in. | apop_data* apop_expected_value | ( | apop_data * | d, | |
| apop_model * | m | |||
| ) |
Return a matrix of the expected value for each observation or for the model as a whole, as the case may be. This may also be set within the model.
| double apop_log_likelihood | ( | apop_data * | d, | |
| apop_model * | m | |||
| ) |
Find the log likelihood of a data/parametrized model pair.
| d | The data | |
| m | The parametrized model, which must have either a log_likelihood or a p method. |
| apop_model* apop_model_clear | ( | apop_data * | data, | |
| apop_model * | model | |||
| ) |
Allocate an apop_model.
This sets up the output elements of the apop_model: the parameters, covarinace, and expected data sets.
At close, the input model has parameters of the correct size, the covariance and expected elements are NULL, and the status element is zero, indicating no estimation has been done yet.
The input model is modified, so you may want to call this after you call apop_model_copy.
| data | If your params vary with the size of the data set, then the function needs a data set to calibrate against. Otherwise, it's OK to set this to NULL | |
| model | The model whose output elements will be modified. |
| apop_model* apop_model_copy | ( | apop_model | in | ) |
Outputs a copy of the apop_model input.
| in | The model to be copied |
| void apop_model_free | ( | apop_model * | free_me | ) |
Free an apop_model structure.
The parameters, expected, and covariance elements are freed. These are all the things that are completely copied, by apop_model_copy, so the parent model is still safe after this is called. data is not freed, because the odds are you still need it.
The system has no idea what the more element contains, so if they point to other things, they need to be freed before calling this function.
If free_me is NULL, this does nothing.
| free_me | A pointer to the model to be freed. |
| void apop_model_prep | ( | apop_data * | d, | |
| apop_model * | m | |||
| ) |
The default prep is to simply call apop_model_clear. If the function has a prep method, then that gets called instead.
| void apop_model_print | ( | apop_model * | print_me | ) |
Currently an alias for apop_model_show, but when I get around to it, it will conform better with the other apop_..._print fns.
| double apop_p | ( | apop_data * | d, | |
| apop_model * | m | |||
| ) |
Find the probability of a data/parametrized model pair.
| d | The data | |
| m | The parametrized model, which must have either a log_likelihood or a p method. |
| void apop_score | ( | apop_data * | d, | |
| gsl_vector * | out, | |||
| apop_model * | m | |||
| ) |
Find the vector of derivatives of the log likelihood of a data/parametrized model pair.
| d | The data | |
| out | The score to be returned. I expect you to have allocated this already. | |
| m | The parametrized model, which must have either a log_likelihood or a p method. |