simulated_variance: simulated_variance

View source: R/simulated_variances.R

simulated_varianceR Documentation

simulated_variance

Description

Calculate simulated mean and variance in response variable(s)

Usage

simulated_variance(squid)

Arguments

squid

A squid object created with the simulate_population() function

Details

Calculates the simulated variance from the simulation parameters, as well as breaking down the source of this variance into the hierarchical levels given in the parameter list, and into individual predictors. This function has several limitations. 1. Doesn't work when 'model' is specified in simulate_population() 2. Assumes grouping factors in the data_structure are balanced - unbalanced designs can change the observed variance 3. Will be inaccurate with transformed variables (i.e. if functions are specified) 4. Doesn't deal well with three way interactions and over, unless they are the same variable (i.e. polynomials) 5. Doesn't account for covariance between interaction terms, e.g. if there is are two interaction terms rain:temp and wind:temp, they will covary, but this additional variance in the response is not calculated

Value

A list with means and variance at each level

Author(s)

Joel Pick - joel.l.pick@gmail.com

Examples

## Not run: 
squid_data <- simulate_population(
data_structure = make_structure(structure = "individual(10)", repeat_obs=2),
parameters=list(
   individual=list(
 		vcov=1.2
 	),
 	observation=list(
     names=c("temperature","rainfall", "wind"),
     mean = c(10,1 ,20),
     vcov =matrix(c(
       1, 0, 1,
       0,0.1,0,
       1, 0, 2
       ), nrow=3 ,ncol=3),
     beta =c(0.5,-3,0.4)
   ),
   residual=list(
     mean=10,
     vcov=1
   )
 )
)

simulated_variance(squid_data)

## End(Not run)

squid-group/squidSim documentation built on Dec. 15, 2024, 12:26 p.m.