R/construct.fixed.prediction.matrix.R

Defines functions construct.fixed.prediction.matrix

construct.fixed.prediction.matrix <-
function(object, newdata, genotype, grandom) {
	if(!is.null(object$terms$fixed)) {
		mfp <- model.frame(object$terms$fixed, newdata, xlev = attr(object$terms$fixed, "xlev"))
		Xp <- model.matrix(object$terms$fixed, data = mfp, contrasts.arg = attr(object$terms$fixed, "contrast"))

		if(!grandom & (genotype %in% all.vars(object$terms$fixed))) {
			dim <- table(attr(Xp,"assign"))[-1]
			Xp <- Xp[,-(1:(dim[1]+1)),drop = FALSE]
		} else {
			Xp <- Xp[,-1,drop = FALSE]
		}
	} else {
		Xp <- NULL
	}
	Xp
}

Try the SpATS package in your browser

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

SpATS documentation built on Nov. 10, 2022, 5:58 p.m.