mnl_pred_ova: Multinomial Prediction Function (Observed Value Approach)

Description Usage Arguments Value Examples

View source: R/mnl_pred_ova.R

Description

This function predicts probabilities for all choices of a multinomial logit model over a specified span of values.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
mnl_pred_ova(
  model,
  data,
  x,
  by = NULL,
  z = NULL,
  z_value = NULL,
  xvari,
  scenname,
  scenvalue,
  nsim = 1000,
  seed = "random",
  probs = c(0.025, 0.975)
)

Arguments

model

the multinomial model, from a multinom()-function call (see the nnet package)

data

the data with which the model was estimated

x

the name of the variable that should be varied (the x-axis variable in prediction plots)

by

define the steps of x.

z

if you want to hold a specific variable stable over all scenarios, you can name it here (optional).

z_value

determine at which value you want to fix the z.

xvari

former argument for x (deprecated).

scenname

former argument for z (deprecated).

scenvalue

former argument for z_value (deprecated).

nsim

numbers of simulations

seed

set a seed for replication purposes.

probs

a vector with two numbers, defining the significance levels. Default to 5% significance level: c(0.025, 0.975)

Value

The function returns a list with several elements. Most importantly the list includes the simulated draws 'S', the simulated predictions 'P', and a data set for plotting 'plotdata'.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library(nnet)
library(MASS)

dataset <- data.frame(y = c(rep("a", 10), rep("b", 10), rep("c", 10)),
                      x1 = rnorm(30),
                      x2 = rnorm(30, mean = 1),
                      x3 = sample(1:10, 30, replace = TRUE))

mod <- multinom(y ~ x1 + x2 + x3, data = dataset, Hess = TRUE)

pred <- mnl_pred_ova(model = mod, data = dataset,
                     x = "x1",
                     nsim = 10)

ManuelNeumann/MNLpred documentation built on July 17, 2021, 10:48 a.m.