plot.gmnl: Plot of the Distribution of the Conditional Expectation of...

Description Usage Arguments Author(s) References See Also Examples

View source: R/gmnl.methods.R

Description

Methods for gmnl objects which provide a plot of the distribution of the conditional expectation of the random parameters or the distribution of the conditional willigness-to-pay.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## S3 method for class 'gmnl'
plot(
  x,
  par = NULL,
  effect = c("ce", "wtp"),
  wrt = NULL,
  type = c("density", "histogram"),
  adjust = 1,
  main = NULL,
  col = "indianred1",
  breaks = 10,
  ylab = NULL,
  xlab = NULL,
  ind = FALSE,
  id = NULL,
  ...
)

Arguments

x

an object of class gmnl.

par

a string giving the name of the variable with random parameter.

effect

a string indicating whether the conditional expectation, "ce", or the WTP, "wtp" should be plotted.

wrt

a string indicating with respect to which variable the WTP should be computed if effect = "wtp".

type

a string indicating the type of distribution: it can be a histogram or a density of the conditional expectation of the random coefficients or WTP.

adjust

bandwidth for the kernel density.

main

an overall title for the plot.

col

color for the graph.

breaks

number of breaks for the histrogram if type = "histogram".

ylab

a title for the y axis.

xlab

a title for the x axis.

ind

a boolean. If TRUE, a 95% interval of conditional distribution for each individual is plotted. As default, the conditional expectation of par for the first 10 individual is plotted.

id

only relevant if ind is not NULL. This is a vector indicating the individuals for whom the user want to plot the conditional coefficients.

...

further arguments to be passed to plot or plotCI.

Author(s)

Mauricio Sarrias

References

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Not run: 
## Examples using the Electricity data set from the 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)
                 
## Plot the density of the conditional expectation distribution of loc
plot(Elec.cor, par = "loc", effect = "ce", type = "density", col = "grey")

## Plot the conditional expectation of loc for each individual
plot(Elec.cor, par = "loc", effect = "ce", ind = TRUE, id = 1:30)

## Plot the WTP for cl
plot(Elec.cor, par = "loc", effect = "wtp", wrt = "pf")                  

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

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

Related to plot.gmnl in gmnl...