BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Abdus-Salaam
Obsidian | Level 7

Dear SAS community,

I'm trying to use the empirical option in the proc mixed statement for robust variances in a model because my data doesn*t fulfill homogeneity, even after different transformation (ln, square root).  I've also tried it with different groups in the repeated statement, usually i select it via AIC. My model estimates plant numbers of barley plants from a pea-barley intercropping experiment. The experiment design is a randomised incomplete block design with the test factors:
- Behandlung(treatment) (6 levels: pure stand, 90:10 (Pea%:Barley%), 70:30, 80:20, 80:40 and 50:50 )

- NStufe(fertiliser level): 0 (no fertilisation), 1 (100 kg N/ha) (for the treatments 80:20 and 80:40 is just NStufe 0         available)

 

There are 4 observations for each combination, with one missing value for treatment 80:20.

I've tried to put the subject option to the random statement and with subject=Behandlung*NStufe because this is how my data is grouped, but i've got the following error in the log:

ERROR: Empirical standard errors cannot be computed for this model because there is only one  effective subject.

I've tried it with Behandlung, NStufe and Block as subject but for all i get the same error.  Then i've put the subject option in the random statement instead and it worked for all subjects that i've already tried with the repeated statement. My random factor is Block so i guess that i should put it as a subject in the random statement but i'm not really know if this is correct. Can someone help me to find the correct way how to implement the subject option in my code and explain it to me how tho decide that?

Here is my code

data a3;
input Datum	$ Messtermin	Block	Parzelle	Variante	Behandlung	NStufe	Dichte_Erbse	Dichte_Gerste	Pflanzenzahl_Gerste;
log_Pflanzenzahl_Gerste=1/(log(Pflanzenzahl_Gerste));
datalines;
06.06.2024	1	1	1	2	1	1	0	100	162.0053691
06.06.2024	1	1	2	10	6	0	80	20	34.6878687
06.06.2024	1	1	3	6	3	0	90	10	26.2
06.06.2024	1	1	4	9	5	0	80	40	29.15329531
06.06.2024	1	1	5	7	4	0	70	30	44.13465347
06.06.2024	1	1	8	5	3	0	90	10	26.71594872
06.06.2024	1	1	9	1	1	0	0	100	159.7818182
06.06.2024	1	1	10	11	7	0	50	50	165.3264368
06.06.2024	1	1	12	8	4	1	70	30	112.1639344
06.06.2024	1	1	14	12	7	1	50	50	76.45019608
06.06.2024	1	2	15	11	7	0	50	50	190.9146341
06.06.2024	1	2	17	5	3	0	90	10	24.98595041
06.06.2024	1	2	18	10	6	0	80	20	.
06.06.2024	1	2	19	7	4	0	70	30	66.45525767
06.06.2024	1	2	20	2	1	1	0	100	262.4124286
06.06.2024	1	2	21	9	5	0	80	40	80.12765957
06.06.2024	1	2	22	6	3	1	90	10	35.16582915
06.06.2024	1	2	25	8	4	1	70	30	111.3658537
06.06.2024	1	2	26	12	7	1	50	50	115.5
06.06.2024	1	2	27	1	1	0	0	100	140.4141414
06.06.2024	1	3	29	8	4	1	70	30	109.1770335
06.06.2024	1	3	30	1	1	0	0	100	160.2692308
06.06.2024	1	3	32	11	7	0	50	50	190.1124051
06.06.2024	1	3	34	10	6	0	80	20	70.88881988
06.06.2024	1	3	35	12	7	1	50	50	57.50456026
06.06.2024	1	3	36	2	1	1	0	100	188.1761006
06.06.2024	1	4	37	9	5	0	80	40	44.62406417
06.06.2024	1	4	38	5	3	0	90	10	23.99574468
06.06.2024	1	4	40	7	4	0	70	30	124.7916667
06.06.2024	1	4	41	6	3	1	90	10	35.54
06.06.2024	1	3	43	1	1	0	0	100	200.3962264
06.06.2024	1	3	44	11	7	0	50	50	92.76923077
06.06.2024	1	3	47	8	4	1	70	30	114.6013072
06.06.2024	1	3	48	9	5	0	80	40	60.27710843
06.06.2024	1	3	49	6	3	1	90	10	29.90909091
06.06.2024	1	3	50	7	4	0	70	30	60.33128834
06.06.2024	1	4	51	5	3	0	90	10	45.22580645
06.06.2024	1	4	52	12	7	1	50	50	75.63299663
06.06.2024	1	4	54	10	6	0	80	20	91.33333333
06.06.2024	1	4	56	2	1	1	0	100	233.2857143
;run;
;


/* Pflanzenzahl Gerste = plant count barley*/
Proc mixed data=a3 empirical;
class Block Behandlung NStufe;
model log_Pflanzenzahl_Gerste = Behandlung*NStufe;
repeated/group=Behandlung*NStufe;
random Block /subject=Block;
lsmeans Behandlung*NStufe/cl;
ods output lsmeans = lsmeans;
run;
;
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
I think you could start with the most simple model:

Proc mixed data=a3 empirical;
class Block Behandlung NStufe;
model log_Pflanzenzahl_Gerste = Behandlung*NStufe;
random int /subject=Block;
lsmeans Behandlung*NStufe/cl;
ods output lsmeans = lsmeans;
run;

"repeated/group=Behandlung*NStufe;"
That means you have the same obs within each Block, but your data doesn't look like this.
If you really need REPEATED statement, I suggest you create a repeated variable for each Block like
block time
1 1
1 2
1 3
2 1
2 2

and using:
repeated time/subject=block;
or
repeated time/subject=block group=Behandlung*NStufe;

View solution in original post

2 REPLIES 2
Ksharp
Super User
I think you could start with the most simple model:

Proc mixed data=a3 empirical;
class Block Behandlung NStufe;
model log_Pflanzenzahl_Gerste = Behandlung*NStufe;
random int /subject=Block;
lsmeans Behandlung*NStufe/cl;
ods output lsmeans = lsmeans;
run;

"repeated/group=Behandlung*NStufe;"
That means you have the same obs within each Block, but your data doesn't look like this.
If you really need REPEATED statement, I suggest you create a repeated variable for each Block like
block time
1 1
1 2
1 3
2 1
2 2

and using:
repeated time/subject=block;
or
repeated time/subject=block group=Behandlung*NStufe;
Abdus-Salaam
Obsidian | Level 7

Hello Ksharp, thank you a lot 👍. It worked well. the repeated statement with the time variable and the group=Behandlung*NStufe option improved the residual plot of the residuals vs. predicted values a lot compared to the code without the repeated statement.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 2 replies
  • 303 views
  • 2 likes
  • 2 in conversation