Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: glm
See also: cumsum genglm glmmultlo

Quantlet: genmultlo
Description: genmultlo generates data according to a multinomial logit model with P( Y = j | Xa , Xi) proportional to exp( Xa * ba + Xi * bi[j] ). Here, Xi denotes the part of the explanatory variables which merely depends on the individuals, Xa covers variables which may vary with the alternatives j. Either part, Xa or Xi, can be omitted.

Link:
Usage: {y,mu} = genmultlo(x,b)
Input:
x n x r matrix, design.
b r x m matrix (m>1, first column equals zero) or r/m x 1 vector or a list containing a p x m matrix (m>1, first column equals zero) and a q x 1 vector and r=p+(q*m).
Output:
y n x 1 vector, multinomial in 0 ... (m-1).
mu n x m vector, response probabilities P(y=j), j=1,...,m.

Example:
library("glm")
n = 100
b =(0|0)~(1|2)~(-1|0)~(1|1)
x = normal(n,rows(b))
{y,mu} = genmultlo(x,b)

Result:
y[i] are pseudo random variables with distribution
P(y[i]=j) = exp(x[i,]*b[,j])/(1+sum(exp(x[i,]*b),2))
(= multinomial logit model).
Example:
library("glm")
n = 100
b = 2
m = 4
id=diag(matrix(m))
x=kron(id,matrix(n/m))
{y,mu} = genmultlo(x,b)

Result:
y[i] are pseudo random variables with distribution
P(y[i]=j) = exp(x[i,j]*b)/(1+sum(exp(x[i,]*b),2))
(= conditional logit model).
Example:
library("glm")
n = 100
b = list(2,(0|0)~(1|2)~(-1|0)~(1|1))
m = 4
id=diag(matrix(m))
x=kron(id,matrix(n/m))~normal(n,2)
{y,mu} = genmultlo(x,b)

Result:
y[i] are pseudo random variables with distribution
P(y[i]=j) = exp(x[i,j]*b{1} + x[i,5:6]*b{1}[,j])
            /(1+sum(exp(x[i,]*b{1}+exp(x[i,5:6]*b),2))
(= mixed multinomial/conditional logit model).



Author: M. Mueller, 20010228
(C) MD*TECH Method and Data Technologies, 05.02.2006