cov.gmnl {gmnl}R Documentation

Functions for Correlated Random Parameters

Description

These are a set of functions that help to extract the variance-covariance matrix, the correlation matrix, and the standard error of the random parameters for models of class gmnl.

Usage

cov.gmnl(x, Q = NULL)

cor.gmnl(x, Q = NULL)

se.cov.gmnl(x, sd = FALSE, Q = NULL, digits = max(3, getOption("digits") - 2))

Arguments

x

an object of class gmnl where ranp is not NULL.

Q

this argument is only valid if the "mm" (MM-MNL) model is estimated. It indicates the class for which the variance-covariance matrix is computed.

sd

if TRUE, then the standard deviations of the random parameters along with their standard errors are computed.

digits

the number of digits.

Details

The variance-covariance matrix is computed using the Cholesky decomposition LL'=\Sigma.

se.cov.gmnl function is a wrapper for the deltamethod function of the msm package.

Value

cov.gmnl returns a matrix with the variance of the random parameters if the model is fitted with random coefficients. If the model is fitted with correlation = TRUE, then the variance-covariance matrix is returned.

If correlation = TRUE in the fitted model, then se.cov.gmnl returns a coefficient matrix for the elements of the variance-covariance matrix or the standard deviations if sd = TRUE.

Author(s)

Mauricio Sarrias msarrias86@gmail.com

References

See Also

gmnl for the estimation of different multinomial models with individual heterogeneity.

Examples

## Not run: 
## Examples using Electricity data set from mlogit package
library(mlogit)
data("Electricity", package = "mlogit")
Electr <- mlogit.data(Electricity, id.var = "id", choice = "choice",
                     varying = 3:26, shape = "wide", sep = "")
                     
## Estimate a MIXL model with correlated random parameters
Elec.cor <- gmnl(choice ~ pf + cl + loc + wk + tod + seas| 0, data = Electr,
                 subset = 1:3000,
                 model = 'mixl',
                 R = 10,
                 panel = TRUE,
                 ranp = c(cl = "n", loc = "n", wk = "n", tod = "n", seas = "n"),
                 correlation = TRUE)
                 
## Use functions for correlated random parameters
cov.gmnl(Elec.cor)
se.cov.gmnl(Elec.cor)
se.cov.gmnl(Elec.cor, sd = TRUE)
cor.gmnl(Elec.cor)

## End(Not run)

[Package gmnl version 1.1-3.2 Index]