Skip to contents

Generates a linear outcome variable by summing all columns that start with "." (representing fixed, random, and error effects).

Usage

add_linear_outcome(data, output_col = "y_linear")

Arguments

data

A data frame containing effect columns prefixed with ".".

output_col

Name of the column to store the linear outcome (default "y_linear").

Value

A tibble with the added linear outcome column.

Examples

df <- tibble::tibble(.beta = 0.5, .u = rnorm(5), .error = rnorm(5))
add_linear_outcome(df)
#> # A tibble: 5 × 4
#>   .beta      .u  .error y_linear
#>   <dbl>   <dbl>   <dbl>    <dbl>
#> 1   0.5  0.0700  2.76     3.33  
#> 2   0.5 -0.639   0.0465  -0.0926
#> 3   0.5 -0.0500  0.578    1.03  
#> 4   0.5 -0.251   0.118    0.367 
#> 5   0.5  0.445  -1.91    -0.967