heteroscedastic variances

Reply
Occasional Contributor
Posts: 11

heteroscedastic variances


Does anyone know of a SAS code to generate heteroscedastic variances for two groups (i.e., treatment vs. control)?

Super User
Posts: 19,851

Re: heteroscedastic variances

Posted in reply to dessert_fox

I think we need more information on what you're looking for.

Occasional Contributor
Posts: 11

Re: heteroscedastic variances

Sorry I did not provide that much information to my earlier question. So basically, I want to simulate data where I can estimate and compare the variance between two groups (i.e., treatment vs. control) and it could be a simple t test, or ANOVA, or a multilevel model.

Thanks Reeza!

Rommel

Contributor
Posts: 46

Re: heteroscedastic variances

Posted in reply to dessert_fox

You should be looking at contrast or estimate statements with hovtest= bf welch lavene .

These options will give you different variance tests. A good book with examples is analysis of messy data volume 1 by milliken and johnson.

Respected Advisor
Posts: 4,930

Re: heteroscedastic variances

Posted in reply to dessert_fox

Do you want to simulate, estimate or compare variances for two groups? - PG

PG
Occasional Contributor
Posts: 11

Re: heteroscedastic variances

Yes, I wanted to simulate where the treatment group has a greater variance compared to the control group. Any model could do: t-test, ANOVA, or better yet a multilvel model.

Thanks,

Respected Advisor
Posts: 4,930

Re: heteroscedastic variances

Posted in reply to dessert_fox

OK, here is a simulation of ANOVA with two groups, in the equal and unequal variances cases :

data test;
length case $16;
call streaminit(384239);
case = "EQUAL VARIANCES";
do group = "A", "B";
     do _n_ = 1 to 50;
          x = rand("NORMAL", 10, 2);
          output;
          end;
     end;
case = "UNEQUAL VARIANCES";
group = "A";
do _n_ = 1 to 50;
     x = rand("NORMAL", 10, 2);
     output;
     end;
group = "B";
do _n_ = 1 to 50;
     x = rand("NORMAL", 10, 3);
     output;
     end;
run;

proc glm data=test;
by case;
class group;
model x = group;
means group / hovtest welch;
run;

PG

PG
Occasional Contributor
Posts: 11

Re: heteroscedastic variances

PG,

Thanks so much. This would give me a good starting point to learn how to simulate.

Rommel

Occasional Contributor
Posts: 11

Re: heteroscedastic variances

PGStats,

I've strated writing simulation codes for multilevel mediation model for normal and non-normal combined with heteroscedastic variance. Would you be kind enough to take a look at my codes when you happen to have time?

Thanks so much for the help.

Rommel

Respected Advisor
Posts: 2,655

Re: heteroscedastic variances

Posted in reply to dessert_fox

Rommel,

Do you have SAS/IML licensed?  If so, then take a look through 's blog, and find a wealth of information regarding simulation, with special parts on simulating from multivariable normal distributions, and correlated/clustered observations.  IML is so much more powerful for simulation than DATA step programming that if simulation is going to be a major part of your work, you should consider getting a license.

Steve Denham

Occasional Contributor
Posts: 11

Re: heteroscedastic variances

Posted in reply to SteveDenham

Yes Steve I have a SAS-IML license. And I have already looked through Rick Wicklin's blog and it's been very helpful. But right I would say I'm still at the very basic level of doing simulation. I wonder if at this point it's already ok to learn simulation in SAS-IML. I never knew it was more powerful though. But yes, I will start learnin SAS-IML. In fact, I already pre-ordered his book on simulation.

I really appreciate your advice.

Thanks Steve!

Rommel

Frequent Contributor
Posts: 140

Re: heteroscedastic variances

Posted in reply to dessert_fox

Rick's book on simulation is excellent (not surprising) and starts with the very basics.

Occasional Contributor
Posts: 8

Re: heteroscedastic variances

Thanks so much PG. One more question if you don't mind, do you have a sample simulation code to generate multilevel data?

Respected Advisor
Posts: 4,930

Re: heteroscedastic variances

Please be more precise. What would you like that data to look like?

PG
Occasional Contributor
Posts: 8

Re: heteroscedastic variances

Specifically, I want to generate a multilevel data where I have a treatment and a control group with the following

conditions:

        a) two levels of clusters (20 and 40 groups)

        b) two levels of sample size (10 for small sample and 20 for medium-sized sample)

        c) for each sample size, 1/2 is assigned to treatment and 1/2 is to control

Given these, I want to generate data from a nonnormal distribution (chi-square dist with df=1) and a

heteroscedastic variance where treatment to control variance ratio is 8:1.

From there I want to assess how nonnormality and heteroscedasticity affects the power and type I error of a statistical test.

Thanks so much, PG! Let me know if you need more details.

Ask a Question
Discussion stats
  • 17 replies
  • 739 views
  • 3 likes
  • 7 in conversation