cov.gmnl: Functions for Correlated Random Parameters

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/gmnl.methods.R

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

1
2
3
4
5
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'=Σ.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## 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)

Example output

Loading required package: maxLik
Loading required package: miscTools

Please cite the 'maxLik' package as:
Henningsen, Arne and Toomet, Ott (2011). maxLik: A package for maximum likelihood estimation in R. Computational Statistics 26(3), 443-458. DOI 10.1007/s00180-010-0217-1.

If you have questions, suggestions, or comments regarding the 'maxLik' package, please use a forum or 'tracker' at maxLik's R-Forge site:
https://r-forge.r-project.org/projects/maxlik/
Loading required package: Formula
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: lmtest
Estimating MIXL model 
             cl       loc        wk        tod      seas
cl    0.1785209 0.1395737 0.1922443 -0.2325927 0.1388156
loc   0.1395737 3.2259440 2.4657155  0.6451716 0.5565644
wk    0.1922443 2.4657155 1.9280988  0.3323425 0.4351544
tod  -0.2325927 0.6451716 0.3323425  6.1191489 4.9316035
seas  0.1388156 0.5565644 0.4351544  4.9316035 5.1163775

Elements of the variance-covariance matrix 

             Estimate Std. Error z-value  Pr(>|z|)    
v.cl.cl      0.178521   0.041807  4.2702 1.953e-05 ***
v.cl.loc     0.139574   0.086394  1.6156 0.1061901    
v.cl.wk      0.192244   0.081660  2.3542 0.0185624 *  
v.cl.tod    -0.232593   0.092809 -2.5061 0.0122058 *  
v.cl.seas    0.138816   0.082503  1.6826 0.0924601 .  
v.loc.loc    3.225944   0.755094  4.2722 1.935e-05 ***
v.loc.wk     2.465716   0.598854  4.1174 3.832e-05 ***
v.loc.tod    0.645172   0.355977  1.8124 0.0699252 .  
v.loc.seas   0.556564   0.325295  1.7110 0.0870897 .  
v.wk.wk      1.928099   0.544154  3.5433 0.0003952 ***
v.wk.tod     0.332343   0.310159  1.0715 0.2839343    
v.wk.seas    0.435154   0.284970  1.5270 0.1267559    
v.tod.tod    6.119149   1.430113  4.2788 1.879e-05 ***
v.tod.seas   4.931604   1.113928  4.4272 9.546e-06 ***
v.seas.seas  5.116378   1.191171  4.2953 1.745e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Standard deviations of the random parameters 

     Estimate Std. Error z-value  Pr(>|z|)    
cl   0.422517   0.049473  8.5403 < 2.2e-16 ***
loc  1.796091   0.210205  8.5445 < 2.2e-16 ***
wk   1.388560   0.195942  7.0866 1.375e-12 ***
tod  2.473691   0.289065  8.5576 < 2.2e-16 ***
seas 2.261941   0.263307  8.5905 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
             cl       loc         wk         tod      seas
cl    1.0000000 0.1839208 0.32767575 -0.22253890 0.1452487
loc   0.1839208 1.0000000 0.98866673  0.14521159 0.1369953
wk    0.3276757 0.9886667 1.00000000  0.09675553 0.1385471
tod  -0.2225389 0.1452116 0.09675553  1.00000000 0.8813763
seas  0.1452487 0.1369953 0.13854709  0.88137626 1.0000000

gmnl documentation built on July 1, 2020, 6:01 p.m.

Related to cov.gmnl in gmnl...