R/onebyone.R

Defines functions onebyone.null onebyone.int obo

Documented in obo

obo <- function(anoint,...){

	OBO <- onebyone.int(anoint)
	OBO.null <- onebyone.null(anoint)
	LRTs <- LRT.onebyone(OBO,OBO.null)
	names(LRTs) <- all.vars(formula(paste("~",as.character(anoint@formula@prognostic)[3],sep="",collapse="")))
	pvalues <- sapply(LRTs,function(x)pchisq(x,df=1,lower.tail=FALSE))
	names(pvalues) <- names(LRTs)

list(
	fit = OBO,
	LRT = LRTs,
	pvalue = 	pvalues
	)

}

onebyone.int <- function(anoint,...){
	
	if(any(anoint@formula@family=="coxph")){
		lapply(anoint@formula@uni, function(f) coxph(f, data=anoint@data,...))
	}
	else{		
		lapply(anoint@formula@uni, function(f) glm(f, data=anoint@data,
						family=anoint@formula@family,...))
	}
	
}

onebyone.null <- function(anoint,...){
	
	null.formulas <- sapply(anoint@formula@uni,make.null.formula,USE.NAMES=FALSE) 
	
	if(any(anoint@formula@family=="coxph")){
		lapply(null.formulas, function(f) coxph(f, data=anoint@data,...))
	}
	else{		
		lapply(null.formulas, function(f) glm(f, data=anoint@data,
						family=anoint@formula@family,...))
	}
	
}

Try the anoint package in your browser

Any scripts or data that you put into this service are public.

anoint documentation built on May 30, 2017, 6:39 a.m.