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)
> On 05 Feb 2017, at 20:44 , James Henson <jfhenson1 at gmail.com> wrote: > > 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.I have no specific knowledge of this, but Thompson's document refers to MPH.FIT, and if you google that, you get to http://homepage.stat.uiowa.edu/~jblang/mph.fitting/mph.fit.documentation.2.0.htm which tells you that to get the software, you should contact the author. And "please do not distribute", etc. You could try that, but the document is from 2007, so there is some risk that you will experience an example of the "bitrot" that CRAN was designed to avoid... -pd> > 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) > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
It is not part of "R". You can dig through all of the packages that the author mentions, or send an email to the author. -- Sent from my phone. Please excuse my brevity. On February 5, 2017 11:44:40 AM PST, James Henson <jfhenson1 at gmail.com> wrote:>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) > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.
Greetings Peter and Jeff, Thanks for this information. Will try these type of analyses in SAS. Sure they are doable in R, but developing a procedure is difficult. Alan Agresti gives a cookbook SAS method in An Introduction to Categorical Analysis. Thanks, James On Sun, Feb 5, 2017 at 3:47 PM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:> It is not part of "R". You can dig through all of the packages that the author mentions, or send an email to the author. > -- > Sent from my phone. Please excuse my brevity. > > On February 5, 2017 11:44:40 AM PST, James Henson <jfhenson1 at gmail.com> wrote: >>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) >> >>______________________________________________ >>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>https://stat.ethz.ch/mailman/listinfo/r-help >>PLEASE do read the posting guide >>http://www.R-project.org/posting-guide.html >>and provide commented, minimal, self-contained, reproducible code.