var.adj {gnonadd}R Documentation

Mean and variance effect adjustments.

Description

Given is a set of (continuous) variables and a qt trait. First, this function adjusts the trait for the mean effects of the variables with a linear model. Next, the variance effect of the variables are estimated and the trait is adjusted further by scaling it in accordance with the results.

Usage

var.adj(qt, x, iter_num = 50, eps_param = 1e-10)

Arguments

qt

A numeric vector.

x

A numeric matrix, each column represents a covariate.

iter_num

An integer. Represents the number of iterations performed in the Gauss-Newton algorithm

eps_param

A number. The Gauss-Newton algorithm terminates if the incriment change of all variance estimates is smaller than this number.

Value

A vector, representing the adjusted trait.

Examples

n_val <- 50000
x <- matrix(0,nrow = n_val, ncol = 4)
for(i in 1:4) {
x[, i] <- rnorm(n_val)
}
var_vec <- exp(0.2 * x[, 1] - 0.3 * x[, 4])
qt_vec <- rnorm(n_val, 0, sqrt(var_vec))
res <- var.adj(qt_vec, x)

[Package gnonadd version 1.0.2 Index]