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.