Number of model parameters
nParam.RdThis function returns the number of model parameters. The default
method returns the component x$param$nParam.
Usage
nParam(x, free=FALSE, ...)
# Default S3 method
nParam(x, ...)
# S3 method for class 'lm'
nParam(x, ...)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.
Author
Ott Toomet, otoomet@econ.au.dk
See also
nObs for number of observations
Examples
# Construct a simple OLS regression:
x1 <- runif(100)
x2 <- runif(100)
y <- 3 + 4*x1 + 5*x2 + rnorm(100)
m <- lm(y~x1+x2) # estimate it
summary(m)
#>
#> Call:
#> lm(formula = y ~ x1 + x2)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -2.6465 -0.5734 0.0348 0.6728 2.2277
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 2.8199 0.2539 11.11 <2e-16 ***
#> x1 4.2593 0.3418 12.46 <2e-16 ***
#> x2 5.3668 0.3429 15.65 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 0.994 on 97 degrees of freedom
#> Multiple R-squared: 0.8113, Adjusted R-squared: 0.8074
#> F-statistic: 208.5 on 2 and 97 DF, p-value: < 2.2e-16
#>
nParam(m) # you get 3
#> [1] 3