Fit an R Expression based Maximum Likelihood Model to Data
ml_fit(expr, start, data)
expr | A string of R code that evaluates to the log-likelihood. |
---|---|
start | An named list of the starting values for the parameter terms (coerced to an nlist object). Missing values are fixed at 0. |
data | An named list or data frame of the data (coerced to an nlist object). |
A fitted ml_analysis object.
expr <- "sum(dnorm(len, mu, sigma, log = TRUE))" start <- list(mu = 20, sigma = 8) data <- datasets::ToothGrowth analysis <- ml_fit(expr, start = start, data = data)#> Error in UseMethod("pars"): no applicable method for 'pars' applied to an object of class "nlist"analysis#> Error in eval(expr, envir, enclos): object 'analysis' not found