# [R] Marg.fct function

James Henson jfhenson1 at gmail.com
Sun Feb 5 20:44:40 CET 2017

```Greetings R Community,

An attempt to reproduce the results from code in the source below
fails.  R cannot find the function ‘Marg.fct’. An Internet search for
the ‘Marg.fct’ function was not fruitful.  I appreciate your help.
Best regards, James F. Henson.

R (and S-PLUS) Manual to Accompany Agresti’s Categorical Data Analysis
(2002) 2nd edition Laura A. Thompson, 2009©

http://www.stat.ufl.edu/~aa/cda/Thompson_manual.pdf  page 181

The code is:

# Code from Manual to Accompany Agresti’s Categorical Data Analysis
(2002) 2nd edition Laura A. Thompson, 2009

y <- c(144, 33, 84, 126, 2, 4, 14, 29, 0, 2, 6, 25, 0, 0, 1, 5)

ZF <- Z <- matrix(1,16,1)

#

M1 <- Marg.fct(1,rep(4,2)) # used to get m1+, etc

Error: could not find function "Marg.fct"

M2 <- Marg.fct(2,rep(4,2)) # used to get m+1, etc

#

C.matrix <- matrix(c(

1, 0, 0, 0, -1, 0, 0, 0, # y1+ = y+1

0, 1, 0, 0, 0, -1, 0, 0, # y2+ = y+2

0, 0, 1, 0, 0, 0, -1, 0), # y3+ = y+3

3,8,byrow=T)

h.fct <- function(m) { # constraint function

marg <- rbind(M1%*%m, M2%*%m) # y1+, y2+, y3+, y4+, y+1, y+2, y+3, y+4

C.matrix%*%marg # y1+ = y+1, y2+ = y+2, etc

}

#

a <- mph.fit(y=y,Z=Z,ZF=ZF,h.fct=h.fct)

mph.summary(a)

```