Thanks, Ryan. It looks like Carol (second message) was asking about a single random term model, maybe an intercept only model. Let’s take a specific example. mixed y with xc w z/fixed=xc w z xc*w xc*z/ method=ml/print solution/random intercept xc | subjectid(clus) covtype(un)/ save=fixpred(fixpred) pred(pred) resid(resid). (probably not syntactically correct but will facilitate communication). I write the composite equation as
y = (g00 + g01*w + g02*z + u0) + xc*(g10 + g11*w + g12*z + u1) + e I did some computations on the save command terms.
I found that variance of (y-pred) equaled the variance of resid, which I figure must be ‘e’ in the equation. If that’s true then I figure that variance of (y-fixpred) would seem to be the variance of ((u0+xc*u1)+e).
However, I notice that in the your reply to Tino (March 19) you said
COMPUTE residual_level_2 = y - FXPRED_1.
Or, (u0+xc*u1). The last difference number is (pred-fixpred). What would this variance be? If resid is ‘e’, and either (y-fixpred) or (pred-fixpred) is (u0+xc*u1), is there any way to extract/compute u0 and u1?
Gene Maguin From: GMAIL [mailto:[hidden email]]
On Jun 17, 2014, at 5:17 PM, "Maguin, Eugene" <[hidden email]> wrote:
|
Gene, You pose an interesting question which I had not thought of previously. I *think* one way to obtain U0J and U1J requires the use of the distributive property of multiplication on the RANDOM statement.
Suppose we have the following random coefficient model: Level 1 Equation: y = B0J + B1J*time + eij Level 2 Equations:
B0J = Gamma00 + u0j B1J = Gamma10 + u1j Full Equation: y = Gamma00 + Gamma10*time + ( u1j*time + u0j + eij )
Assuming the random components are uncorrelated, the standard MIXED model code would be: MIXED y WITH time /FIXED=time | SSTYPE(3) /METHOD=REML
/PRINT=SOLUTION G /RANDOM intercept time | subject(subject_ID). However, using the distributive property of multiplication, the following model is mathematically equivalent to:
MIXED y WITH time BY subject_ID /FIXED=time | SSTYPE(3) /METHOD=REML /PRINT=SOLUTION G /RANDOM=subject_ID subject_ID*time. Using the second parameterization of the model, I *think* one can take advantage of the TEST sub-command to estimate B0J, U0J, B1J, and U1J. Assuming there are a total of N=10 subjects and the time variable is a whole number that starts at 0 and increases by one unit as 0,1,2,3,... etc., then the code to obtain the parameter estimates of interest for the first subject would be:
MIXED y WITH time BY subject_ID /FIXED=time | SSTYPE(3) /METHOD=REML /PRINT=SOLUTION G /RANDOM=subject_ID subject_ID*time /TEST 'B01' intercept 1 | subject_ID 1 0 0 0 0 0 0 0 0 0
/TEST 'U01' | subject_ID 1 0 0 0 0 0 0 0 0 0 /TEST 'B11' time 1 | subject_ID*time 1 0 0 0 0 0 0 0 0 0 /TEST 'U11' | subject_ID*time 1 0 0 0 0 0 0 0 0 0
/SAVE=PRED. To test this out, make sure that the following is true: B01 = Gamma00 + U01 B11 = Gamma10 + U11 where, Gamma00 = fixed intercept Gamma10 = fixed slope If the above is correct (which it should be), then make sure the following is also true (for subject 1), PRED_1 = B01 + B11*("value of "time")
HTH, Ryan On Wed, Jun 18, 2014 at 5:07 PM, Maguin, Eugene <[hidden email]> wrote:
|
All, Below is a simulated example verifying what I stated in the previous post. Best, Ryan -- /*Generate Data*/.
/*seed for random generator*/. set seed 987879546. new file. input program. compute subject_ID = -99. compute Gamma00 = -99. compute Gamma10 = -99.
compute u0j = -99. compute u1j = -99. compute B0J = -99. compute B1J = -99. compute eij = -99. compute time = -99. leave subject_ID to time. /*100 subjects*/. loop subject_ID = 1 to 100. /*fixed intercept*/. compute Gamma00 = 0.50. /*fixed slope*/. compute Gamma10 = 0.30.
/*random intercept error term*/. compute u0j = sqrt(.30)*rv.normal(0,1). /*random slope error term*/. compute u1j = sqrt(.30)*rv.normal(0,1). /*random intercept term*/.
compute B0J = Gamma00 + u0j. /*random slope term*/. compute B1J = Gamma10 + u1j. /*30 time points*/. loop time = 0 to 29. /*error term*/.
compute eij = rv.normal(0,1). /*full equation*/. compute y = B0J + B1J*time + eij. end case. end loop. end loop. end file. end input program.
execute. MIXED y WITH time BY subject_ID /FIXED=time | SSTYPE(3) /METHOD=REML /PRINT=SOLUTION G /RANDOM=subject_ID subject_ID*time /TEST 'B01' intercept 1 | subject_ID 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 /TEST 'U01' | subject_ID 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 /TEST 'B11' time 1 | subject_ID*time 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 /TEST 'U11' | subject_ID*time 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 /SAVE=PRED.
On Fri, Jun 20, 2014 at 11:32 PM, Ryan Black <[hidden email]> wrote:
|
For clarity, the TEST statements I wrote previously for this simulation example: ...provides estimates for subject 1. If one wanted estimates for subject 2, the following TEST statements would need to be added: /TEST 'B02' intercept 1 | subject_ID 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 /TEST 'U02' | subject_ID 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 /TEST 'B12' time 1 | subject_ID*time 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 /TEST 'U12' | subject_ID*time 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Clearly one could do this for each subject. Ryan
On Sun, Jun 22, 2014 at 12:22 AM, Ryan Black <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |