BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Lyson
Quartz | Level 8
 

 Anyone with a SAS code to simulate the linear mixed model results, e.g. from the SAS code given below:

proc mixed data=LDH_univ method=reml covtest;

class CCI4 CHCI3 Time Flask ;

model Leakage=CCI4 CHCI3 CCI4*CHCI3 Time CCI4*Time CHCI3*Time CCI4*CHCI3*Time;
repeated Time / subject=Flask type=cs;
lsmeans CCI4 / pdiff cl adjust=tukey;
lsmeans CHCI3 / pdiff cl adjust=tukey;
run;

with the following SAS Proc Mixed output:

Lyson_0-1644864383743.png

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

>  Anyone with a SAS code to simulate the linear mixed model results

I assume you are asking for simulation code that will simulate data so that the parameter estimates in your output are the expected values for a regression of Leakage onto the indep variables.

 

You need more information about your data. The correlation of the independent variables with each other is important and should be modeled. You can use PROC FREQ to analyze the proportion of observations in each level of the class variables. Because of the interaction terms, you want to look at 1-way, 2-way, and 3-way interactions. 

 

There are several sample simulation programs for repeated measures in Gibbs and Kiernan (2020), "Simulating Data for Complex Linear Models."

View solution in original post

5 REPLIES 5
ballardw
Super User

If I understand what you want then the steps I think you need are

1) Modify the code to include a STORE statement to create a file that holds the information the model created that can be used to score other data using the model results.

Something like

Store work.Ldhmixed ;

which place the information in the work library in a store name Ldhmixed. <loosely based on your data set name and the procedure>

2. Create a data set with  the model variables having values you are interested in.

3. Use Proc PLM with the store created in proc mixed and the data set to create output.

 

Warning: You Class variables should only contain values from the original model. Classes that did not exist in the original data don't have any parameters in the model. Think of building model with Gender as a class and all the values are Male. You can't do much predicting(scoring) for Females.

Lyson
Quartz | Level 8
Hi Ballardw

May you kindly try to give the code using dummy variables and parameters.
Here is what I want to achieve:

Simulate a LMM in SAS as what I achieve in R when I follow the following
steps after generating ANOVA F-tests results:

1. set.seed(123)
2. set out parameters of the model
3. simulate the random errors in the model
4. fit a model of simulated response
5. store the variables and simulated data
6. fit simulated model
7. functionize the data simulating and fitting process (to test if the
function works properly, it must produce similar results as in 6.)
8. use the working function to simulate, say 10000 samples and note the
simulation results.

Rick_SAS
SAS Super FREQ

>  Anyone with a SAS code to simulate the linear mixed model results

I assume you are asking for simulation code that will simulate data so that the parameter estimates in your output are the expected values for a regression of Leakage onto the indep variables.

 

You need more information about your data. The correlation of the independent variables with each other is important and should be modeled. You can use PROC FREQ to analyze the proportion of observations in each level of the class variables. Because of the interaction terms, you want to look at 1-way, 2-way, and 3-way interactions. 

 

There are several sample simulation programs for repeated measures in Gibbs and Kiernan (2020), "Simulating Data for Complex Linear Models."

Lyson
Quartz | Level 8

Dear Rick

 
May you kindly try to give the code using dummy variables and parameters. Here is what I want to achieve:
 
Simulate a LMM in SAS as what I achieve in R when I follow the following steps after generating ANOVA F-tests results:
  1. set.seed(123)
  2. set out parameters of the model
  3. simulate the random errors in the model
  4. fit a model of simulated response
  5. store the variables and simulated data
  6. fit simulated model
  7. functionize the data simulating and fitting process (to test if the function works properly, it must produce similar results as in 6.)
  8. use the working function to simulate, say 10000 samples and note the simulation results.
Lyson
Quartz | Level 8
Dear Rick

Thank you for the reading by Gibbs and Kiernan (2020), "Simulating Data for Complex Linear Models."

I see its full of wonderful sample simulation programs for linear models that I need time to grasp on. I appreciate the assistance.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1099 views
  • 1 like
  • 3 in conversation