Description Usage Arguments Value Examples
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.
1 |
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 of residual variance given proposed model
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.