[R] Simple question about function with glm

Chung-hong Chan chainsawtiney at gmail.com
Mon May 7 03:46:52 CEST 2007


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



More information about the R-help mailing list