Not an answer .... But note that your several stopifnot() statements can be combined into 1. See ?stopifnot .
Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Feb 12, 2016 at 8:33 AM, Jacob Wegelin <jacobwege...@fastmail.fm> wrote: > To check that a regression object comes from logistic regression, I employ > the following two lines: > > stopifnot(glmObject$family$family=="binomial") > > stopifnot(glmObject$family$link=="logit") > > For instance: > > toyfunction<-function(glmObject) { > stopifnot(inherits(glmObject, "glm")) > stopifnot(glmObject$family$family=="binomial") > stopifnot(glmObject$family$link=="logit") > cat("okay, I guess\n") > glmObject > } > > mydata <- read.csv("http://www.ats.ucla.edu/stat/data/binary.csv") > > someobject<- glm(admit~gre+gpa, data=mydata) > > toyfunction(someobject) > > someobject<- glm(admit~gre+gpa, data=mydata, family="binomial") > > toyfunction(someobject) > > But Doug Bates once stated that it's preferable to use extractor functions > (and perhaps other ready-made functions?) rather than "deconstructing" an > object (his term), as I do here. > > Accordingly, is there a smarter way to perform the check that I perform > inside toyfunction? > > Thanks for any insight > > Jacob A. Wegelin > Assistant Professor > C. Kenneth and Dianne Wright Center for Clinical and Translational Research > Department of Biostatistics > Virginia Commonwealth University > 830 E. Main St., Seventh Floor > P. O. Box 980032 > Richmond VA 23298-0032 > U.S.A. CTSA grant: UL1TR000058 > E-mail: jacobwege...@fastmail.fm URL: http://www.people.vcu.edu/~jwegelin > > ______________________________________________ > R-help@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. ______________________________________________ R-help@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.