naiveMLE: Naive MLE

Description Usage Arguments Value Examples

View source: R/naiveMLE.R

Description

This function computes a Maximum Likelihood Estimate by using optim() to optimize the joint log-likelihood.

Usage

1
naiveMLE(data, dist, initial, returnOptim = FALSE)

Arguments

data

A matrix of data. If univariate, data should have 1 column. If multivariate, data should have one column for each dimension.

dist

A distribution object (essentially a list with functions defining the distribution, but see the distribution class defined in this package). See getNormalDistribution and the functions it loads for examples of how to define this distribution object and the corresponding functions.

initial

Initial estimate for the parameters. This should be a list of parameters such that it could be passed to the paramList2Vec function in the distribution object.

returnOptim

Logical. If FALSE (default) the function returns the numeric estimates of the parameters, converted back into a list object. If TRUE, the function returns a list with the results of the call to optim (named "optim" in the output) as well as the parameters (named "solution")

Value

See the returnOptim argument description.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Not run: 
data = rnorm(100)
uniNorm = list(dev = devUN, grad = gradDevUN,
               paramList2Vec = paramList2VecUN,
               paramVec2List = paramVec2ListUN)
initial = list(mu = 0, sigma = 1)
naiveMLE(data, dist = uniNorm, initial)
naiveMLE(data, dist = uniNorm, initial, returnOptim = TRUE)
mean(data)
sd(data)

ust = list(dev = devUST, grad = gradDevUST,
           paramList2Vec = paramList2VecUST,
           paramVec2List = paramVec2ListUST)
initial = list(xi = 0, omega = 1, alpha = 0, nu = 100)
naiveMLE(data, dist = ust, initial)

data = matrix(rnorm(200), nrow = 100)
mst = list(dev = devMST, grad = gradDevMST,
           paramList2Vec = paramList2VecMST,
           paramVec2List = paramVec2ListMST)
initial = list(beta = c(0, 0), Omega = diag(c(1, 1)),
               alpha = c(0, 0), nu = 100)
naiveMLE(data, dist = mst, initial)
naiveMLE(data, dist = mst, initial, returnOptim = TRUE)

data = rpois(30, lambda = 4.7)
data = c(data, 100)
dist = list(dev = devPsn, grad = gradDevPsn,
           paramList2Vec = paramList2VecPsn,
           paramVec2List = paramVec2ListPsn)
initial = list(lambda = 1)
naiveMLE(data, dist = dist, initial)
mean(data)

## End(Not run)

rockclimber112358/MCLE documentation built on May 27, 2019, 12:15 p.m.