Learn R Programming

maxLik (version 0.8-0)

nParam.maxim: Number of model parameters

Description

This function returns the number of model parameters.

Usage

## S3 method for class 'maxim':
nParam(x, free=FALSE, \dots)

Arguments

x
a model returned by a maximisation method from the maxLik package.
free
logical, whether to report only the free parameters or the total number of parameters (default)
...
other arguments for methods

Value

  • Number of parameters in the model

Details

Free parameters are the parameters with no equality restrictions. Some parameters may be restricted (e.g. sum of two probabilities may be restricted to equal unity). In this case the total number of parameters may depend on the normalisation.

See Also

nObs for number of observations

Examples

Run this code
## fit a normal distribution by ML
# generate a variable from normally distributed random numbers
x <- rnorm( 100, 1, 2 )
# log likelihood function (for individual observations)
llf <- function( param ) {
   return( dnorm( x, mean = param[ 1 ], sd = param[ 2 ], log = TRUE ) )
}
## ML method
ml <- maxLik( llf, start = c( mu = 0, sigma = 1 ) )
# return number of parameters
nParam( ml )

Run the code above in your browser using DataLab