imultinom: imultinom S4 object constructor

Description Usage Arguments Value Author(s) Examples

Description

Constructs an imultinom S4 object

Usage

1
imultinom(listInput, matrixInput, a, b, De)

Arguments

listInput

This is a list in the shape of list(a = numeric vector, b = numeric vector, De = 0-1 matrix). If supplied, all subsequent inputs will be ignored.

matrixInput

Input in adjacency matrix format. Precedence is after list input. If supplied, all subsequent inputs will be ignored.

a

Individual input of the complete data exponents as a numeric vector. When using this input, make sure both listInput and matrixInput are not supplied.

b

Individual input of the composite data exponents as a numeric vector. When using this input, make sure both listInput and matrixInput are not supplied.

De

Individual input of the subset pattern indicator matrix as a 0-1 matrix (class matrix, mode numeric). Requires: nrow = length(a), ncol = length(b). When using this input, make sure both listInput and matrixInput are not supplied.

Value

Returns an S4 object having 3 slots: @a, @b, @De

Author(s)

Fanghu Dong <easttiger@gmail.com>

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
obj1_imultinom <- imultinom(a=c(3,3,3),b=c(2,9),De = matrix(c(1,0,1,1,1,0),ncol=2))
mle(obj1_imultinom)

cat ("Press [enter] to continue"); line <- readline()
options(iterrec=T)
cat("\n=================\n")
subject = "MLE of Ford (1957) adjacency matrix format"
cat(c(subject,"\n"))
Ford1957_adjmat = matrix(
	c( 0,15,15, 0,
	  11, 0,10,20,
	  11,10, 0,20,
	   0, 1, 1, 0),
	nrow = 4,
	byrow=TRUE);

Ford1957 <- imultinom(matrixInput = Ford1957_adjmat)
Ford1957_out <- mle(Ford1957)
if(!is.null(getOption("iterrec")) && getOption("iterrec")){
  with(Ford1957_out, print(list(x=x,iterCount=iter$count,lnLik=iter$lnLik[iter$count])))
  plot(Ford1957_out$iter$lnLik, type="b",pch=20,main=subject)
}else{
  print(Ford1957_out)
}

cat ("Press [enter] to continue"); line <- readline()
cat("\n=================\n")
subject = "MLE of Hunter (2004) NASCAR2002 Plackett-Luce Modelling"
cat(c(subject,"\n"))
nascar2002PL <- imultinom(Weaver.Examples.Hunter2004PL.ConvertInput())
nascar2002PL_out = mle(nascar2002PL)
if(!is.null(getOption("iterrec")) && getOption("iterrec")){
  with(nascar2002PL_out, print(list(x=x,iterCount=iter$count,lnLik=iter$lnLik[iter$count])))
  plot(nascar2002PL_out$iter$lnLik, type="b",pch=20,main=subject)
}else{
  print(nascar2002PL_out)
}

cat ("Press [enter] to continue"); line <- readline()
cat("\n=================\n")
subject = "MLE of Hunter (2004) NASCAR2002 Bradley-Terry Modelling"
cat(c(subject,"\n"))
data(nascar2002BT)
nascar2002BT_out = mle(nascar2002BT)
if(!is.null(getOption("iterrec")) && getOption("iterrec")){
  with(nascar2002BT_out, print(list(x=x,iterCount=iter$count,lnLik=iter$lnLik[iter$count])))
  plot(nascar2002BT_out$iter$lnLik, type="b",pch=20,main=subject)
}else{
  print(nascar2002BT_out)
}

cat ("Press [enter] to continue"); line <- readline()
cat("\n=================\n")
subject = "MLE of Hankin (2010) Volleyball dataset";
cat(c(subject,"\n"))
Hankin2010 = imultinom(Weaver.Examples.Hankin2010Volleyball.ConvertInput())
Hankin2010_out = mle(Hankin2010)
if(!is.null(getOption("iterrec")) && getOption("iterrec")){
  with(Hankin2010_out, print(list(x=x,iterCount=iter$count,lnLik=iter$lnLik[iter$count])))
  plot(Hankin2010_out$iter$lnLik, type="b",pch=20,main=subject)
}else{
  print(Hankin2010_out)
}
options(iterrec=F)

easttiger/imultinom documentation built on May 15, 2019, 7:28 p.m.