find_sig: find_sig: Find residual variance of your outcome given a...

Description Usage Arguments Value Examples

View source: R/find_sig.R

Description

While the principles of variance algebra hold for linear relationships, they are complicated by non-linear terms and interactions. In fact, closed form solutions for the variance of product distributions is an active research area. This function capitalizes on the power of simulation to estimate the residual variance of a response surface given the expected value of the outcome variance.

Usage

1
find_sig(n, cov_mat, beta, target_var_y = 1, iter = 10000)

Arguments

n

Number of Obseravtion to be simulated at each iteration.

cov_mat

Covariance matrix defining how X1 and X2 are related along with their scale.

beta

Vector of coefficients mapping terms X1, X2, X1^2, X2^2, and X1*X2 to y.

target_var_y

The expected variance of y.

iter

The number of iterations to run to estimate the residual variance.

Value

Value of residual variance given proposed model

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Defining Correlation Matrix describing how x1 and x2 are related
# Covarince and variance of x1^2, x2^2, and x1*x2 follow from this matrix
cov_mat<-matrix(c(1, 0,
                  0, 1), byrow = TRUE, 2, 2)
# Defining betas x1, x2, x1^2, x2^2, and x1*x2
beta<-c(0, 0, -.075, -.075, .15)

# Simulating 10,000 draws of size 1000 assuming the correlation structure and regression weights defined above.
sig_hat <- find_sig(n = 1000, cov_mat = cov_mat, beta = beta, target_var_y = 1)                 
sig_hat

jimmyrigby94/rrs documentation built on May 12, 2020, 3:41 p.m.