Description Usage Arguments Details Value Author(s) See Also Examples
Returns the number of observations for statistical models,
estimated by Maximum Likelihood using maxLik
.
1 2 | ## S3 method for class 'maxLik'
nObs(x, ...)
|
x |
a statistical model estimated by Maximum Likelihood
using |
... |
further arguments (currently ignored). |
The nObs
method for “maxLik” objects
can return the number of observations only if log-likelihood function
(or the gradient) returns values by individual observation.
numeric, number of observations
Arne Henningsen, Ott Toomet
1 2 3 4 5 6 7 8 9 10 11 | ## 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 onservations
nObs( ml )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.