[R] Simple question about function with glm

From: Chung-hong Chan <chainsawtiney_at_gmail.com>
Date: Mon, 07 May 2007 09:46:52 +0800


Dear all,

I coded a function called u.glm

u.glm <- function (x,ahi,age,bmiz,gender) {

	library(nortest)
	lil.rslt <- lillie.test(x)
	if (lil.rslt$p.value >0.05)

{
cat("Logtrans=0, lillie=",lil.rslt$p.value,"\n") xmodel<-glm(x~ahi+age+bmiz+as.factor(gender)) summary(xmodel) confint(xmodel) } else
{
cat("Logtrans=1, lillie=",lil.rslt$p.value,"\n") xmodel<-glm(x~ahi+age+bmiz+as.factor(gender)) summary(xmodel) confint(xmodel) }

}

Basically I just want to test the response variable for normality before modeling.
When I try to use this function, it can do the lillie's test but failed to do the glm.
What's wrong with my code?

Regards,
CH

-- 
"The scientists of today think deeply instead of clearly. One must be
sane to think clearly, but one can think deeply and be quite insane."
Nikola Tesla
http://www.macgrass.com

______________________________________________
R-help_at_stat.math.ethz.ch 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.
Received on Mon 07 May 2007 - 01:51:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 May 2007 - 04:31:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.