Learn R Programming

lme4breeding (version 1.0.80)

balanceData: Balance a dataset

Description

Used to balance a dataset for given slope and intercept.

Usage

balanceData(data, slope=NULL, intercept=NULL)

Value

It returns the new balanced dataset.

Arguments

data

Dataset to be balanced.

slope

A character value indicating the column in the dataset that will serve as slope in the random regression model.

intercept

A character vector indicating the column(s) in the dataset that will serve as intercepts in the random regression model. If more than one column name is provided the intercept value is assumed to be the concatenation of the variables provided.

Details

It returns the same original dataset but balanced for the slopes given certain intercept variables.

References

Giovanny Covarrubias-Pazaran (2024). lme4breeding: enabling genetic evaluation in the age of genomic data. To be submitted to Bioinformatics.

Douglas Bates, Martin Maechler, Ben Bolker, Steve Walker (2015). Fitting Linear Mixed-Effects Models Using lme4. Journal of Statistical Software, 67(1), 1-48.

See Also

lmebreed-- the core function of the package

Examples

Run this code

DT = DT_big
M = apply(M_big,2,as.numeric)
rownames(M) <- rownames(M_big)

# unbalance the data intentionally to mimic a real scenario with missing records
nas <- sample(1:nrow(DT), round(nrow(DT)*.2))
DTu <- droplevels(DT[setdiff(1:nrow(DT), nas),])

# balance your data to be able to use the eigen decomposition
DTb <- balanceData(data=DTu, slope = "id", intercept = c("envf","repf"))
DTb$value <- imputev(x=DTb$value, by=DTb$env)

# now this dataset can be used with the argument 'rotation=TRUE' in lmebreed

Run the code above in your browser using DataLab