Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

nParam

Number of model parameters


Description

This function returns the number of model parameters.

Usage

## S3 method for class 'maxim'
nParam(x, free=FALSE, ...)

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

Details

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

Value

Number of parameters in the model

Author(s)

Ott Toomet

See Also

nObs for number of observations

Examples

## 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 )

maxLik

Maximum Likelihood Estimation and Related Tools

v1.4-8
GPL (>= 2)
Authors
Ott Toomet <otoomet@gmail.com>, Arne Henningsen <arne.henningsen@gmail.com>, with contributions from Spencer Graves and Yves Croissant
Initial release
2021-03-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.