simulating data with a lot of predefined constraints in R how to simulate data (in R) to generate , sample values
1) variables with specific correlation values for a particular model AND 
2) with predefined regression coefficients? 
3) Can we also set the mean and SD in the same process? 
4) Also how does one simulate the p value/significance of the variable. 
This is for imitating existing models for analysis and teaching purposes
Sorry for not being specific : this is for multiple regression, sample values. I would like to specify the mean and SD if possible (apparently not, I can specify only one in order to specify the regression coefficients?)
Thanks for the help.
 A: 1) For the predictors (independent variables, x-variables) only, you want to:
specify sample means, sds, and correlation matrix
this is equivalent to specifying the covariance matrix and the means
2) you want to specify sample coefficients in the regression
You can also specify the residual standard deviation, which will relate to whichever p-value you're interested in.
Step 1 is already addressed in a number of posts on site, such as 
a) Generating data with given sample covariance matrix
(A covariance matrix scaled to have unit variances is a correlation matrix, so that works for both)
b) Tool for generating correlated data sets
There's some mention of R code in at least one of those.
2) 
a) put the desired coefficients in $\beta$
b) simulate random normal errors
c) regress the errors on the x's and find the residuals
d) scale the residuals to the desired standard deviation (call the result $r$)
e) calculate $y=X\beta+r$
That's it.
There's a few extra tidbits in this post on simulating ANOVA that carry over to the regression case.
If you want to determine one of the p-values you can back out the required residual variance that would give that p-value from the other statistics.
