% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/teststat.R
\name{addcovar}
\alias{addcovar}
\title{Run a large-scale regression test}
\usage{
addcovar(lsregmem, xr)
}
\arguments{
\item{lsregmem}{An object of class \code{lsregmem} as returned by
\code{\link{lsReg}}.}

\item{xr}{Numeric matrix of additional covariates to test. Number of columns
must match the \code{colstoadd} value used in \code{\link{lsReg}}.}
}
\value{
Invisibly returns the exit code (0 on success, nonzero on error).
After a successful call, results are stored in the \code{lsregmem} object:
\describe{
\item{\code{lsregmem$testvalue}}{The test statistic. For \code{"lrt"}
this is a chi-square statistic (p-values via \code{pchisq}). For all
other test types this is a z-score (p-values via \code{pnorm}).}
\item{\code{lsregmem$fitdata$betab}}{The parameter estimate(s) for
\code{xr}. Not meaningful for \code{"score"} or \code{"robustscore"},
which do not fit the full model.}
}
}
\description{
Computes a hypothesis test statistic for one or more new covariates
\code{xr} using memory pre-allocated by \code{\link{lsReg}}.
}
\examples{
datafile <- system.file("extdata", "simulated_data.rds", package = "lsReg")
dat <- readRDS(datafile)
basemdl <- glm(ylin ~ x1 + x2, data = dat, family = gaussian)
mem <- lsReg(basemdl, colstoadd = 1, testtype = "wald")
addcovar(mem, as.matrix(dat[, "z5", drop = FALSE]))
mem$fitdata$betab[1]  # parameter estimate for z5
mem$testvalue[1, 1]   # Wald z-score for z5
}
