bgw_mle_setup {bgw} | R Documentation |

## bgw_mle_setup

### Description

Sets up R-level storage for bgw_mle.

This function replaces multiple Fortran subroutines from the BGW Fortran code due at least in part to the prohibition against using Fortran write statements in R packages. The current design produces two vectors (iv_r and v_r) that mirror the main vectors required by the Fortran code. For the moment, the idea is to create named vectors to facilitate coding in bgw_mle. It may be that these could be deleted (or overwritten by an as.numeric() conversion) prior to the main Fortran calls.

### Usage

```
bgw_mle_setup(p, n, hasAnalyticModelDeriv, control = NULL)
```

### Arguments

`p` |
Number of parameters (components of x) being estimated. (Determined in bgw_mle from size of 'start' vector. |

`n` |
Number of model residuals (in vector r). (Determined in bgw_mle by the size of the output vector from CalcR.) |

`hasAnalyticModelDeriv` |
Logical. TRUE if CalcRJ has been provided. FALSE means that bgw_mle must employ finite-difference gradients (which has implications for storage allocation). |

`control` |
List of bgw_mle control parameters (optional). If not provided, BGW default parameters will be used. If provided, default parameters will be overwritten by those corresponding parameters provided by the caller (but these must also be checked). |

### Value

iv and v vectors used by BGW Fortran.

*bgw*version 0.1.3 Index]