Hi,
I am trying to figure how —if possible— to test an interaction while I do not have data, just a correlation matrix.
What I have tried is to simulate data with the same correlational structure, calculate the product term, estimate, and repeat 1,000 times. In order to check the soundness of the approach, I have worked on an example to compare the results from the analysis of a dataset and from the corresponding correlation matrix. The results are inconsistent as you can see if you run the syntax below ('Step 2' section) and if you compare the results to those reported on the webpage which url is in the 'Step 1' section.
Any idea what I am doing wrong? Is the entire approach wrong or can it be fixed? How?
Thanks,
Christophe
I am trying to figure how —if possible— to test an interaction while I do not have data, just a correlation matrix.
What I have tried is to simulate data with the same correlational structure, calculate the product term, estimate, and repeat 1,000 times. In order to check the soundness of the approach, I have worked on an example to compare the results from the analysis of a dataset and from the corresponding correlation matrix. The results are inconsistent as you can see if you run the syntax below ('Step 2' section) and if you compare the results to those reported on the webpage which url is in the 'Step 1' section.
Any idea what I am doing wrong? Is the entire approach wrong or can it be fixed? How?
Thanks,
Christophe
Code:
******************************** * Step 1: Working from dataset * ******************************** * A worked example is available here: https://stats.idre.ucla.edu/stata/faq/how-can-i-explain-a-continuous-by-continuous-interaction-stata-12/ * NB: cannot replicate because the dataset is no longer available at the mentioned url ******************************************* * Step 2: Working from correlation matrix * ******************************************* * Set up of the steps to be repeated for the simulation in a program program myprogram, rclass * drop of all variables to create an empty dataset drop _all * creation of a vector that contains the equivalent of a lower triangular correlation matrix matrix c = (1, 0.5445, 1, 0.6215, 0.6623, 1) * drawing of a sample of 1000 cases from a normal distribution with specified correlation structure (by default, means = 0 and s.d. = 1) drawnorm X W Y, n(1000) corr(c) cstorage(lower) * X refers to 'socst' * W refers to 'math' * Y refers to read * model estimation quietly summarize W global m=r(mean) global s=r(sd) capture generate WX=W*X sem (X W WX -> Y), standardized nocapslatent level(90) return scalar X_on_Y = [Y]_b[X] return scalar W_on_Y = [Y]_b[W] return scalar WX_on_Y = [Y]_b[WX] describe * end * use the simulate command to rerun myprogram 1000 times * collect the betas (_b) and standard errors (_se) from the sem each time simulate X_on_Y = [Y]_b[X] W_on_Y = [Y]_b[W] WX_on_Y = [Y]_b[WX], reps(1000) nodots: myprogram describe * summarize ci mean X_on_Y W_on_Y WX_on_Y, level(90)
Comment