Neither of reduced_model not full_model will ever be NULL. If this fails, they inherit from class "try-error". See ?try.
So you want inherits(reduced_model, "try-error") || inherits(full_model, "try-error") On Thu, 14 Feb 2008, Juliet Hannah wrote: > Dear R Users, > > I have the following glm, which I am running several times in a loop > (I am not including the full code): > > reduced_model <- NULL; > full_model <- NULL; > reduced_model <- try(glm.fit(X4,n,family=poisson(link="log"))) > full_model <- try(glm.fit(X5,n,family=poisson(link="log"))); > > On some occasions, an error is produced, which is why I have attempted > to work around this with try(). > > I then have the following statement, which checks if full_model or > reduced_model are still NULL. > > if (is.null(reduced_model) || is.null(full_model)) p <- NA else p <- > pchisq(reduced_model$deviance - full_model$deviance, > reduced_model$df.residual - full_model$df.residual, lower.tail= > FALSE); > > This is not solving my problem meaning my program still stops and > gives me the following error: > > Error in ifelse(y == 0, 1, y/mu) : dim<- : dims [product 9] do not > match the length of object [18] > Error in pmatrix[perm, ] <- apply(pairs.subset, 1, getLRTp2) : > nothing to replace with > > > Can you help me figure out what I have done incorrectly? > > Thanks for your time, > > Juliet > > ______________________________________________ > R-help@r-project.org mailing list > 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. > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-help@r-project.org mailing list 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.