From: Jon King on
I'm using anovan and I'd like to treat an interaction between two variables as a random effect (alone, the variables are fixed). The 'random' option only takes single groups. What can I do?

Thanks for any help!
From: Tom Lane on
> I'm using anovan and I'd like to treat an interaction between two
> variables as a random effect (alone, the variables are fixed). The
> 'random' option only takes single groups. What can I do?

You're right, you specify variables rather than terms as random. This is the
most common case, but I have heard of people wanting to model the
interaction between fixed effects as random.

Here's what I would do in your case. Define a new variable representing the
interaction, and specify that it is nested in the two main effects. You can
specify this new variable as random. For example, compare these:

>> a = randi(3,100,1);
>> b = randi(4,100,1);
>> ab = 10*a + b;
>> [a(1:4),b(1:4),ab(1:4)]
ans =
3 1 31
3 4 34
1 2 12
3 3 33
>> y = 10 + 4*a + b + randn(size(a));
>> [p1,a1] = anovan(y,[a b],'model','interaction');
>> [p2,a2] = anovan(y,[a b ab],'model','linear','nested',[0 0 0;0 0 0;1 1
>> 0]);
>> [p3,a3] = anovan(y,[a b ab],'model','linear','nested',[0 0 0;0 0 0;1 1
>> 0],'rand',3);

When I tried this I got the same results for the first two, reassuring me
that the idea works. The third example shows that you can then specify that
the new variable is random.

-- Tom


 | 
Pages: 1
Prev: spectrogram
Next: image recognition algorithms