I want to fit a mixed model using nlme package in R which is equivalent to
following SAS codes:

proc mixed data = one;
class var1 var2  year loc rep;
model yld = var1 * var2;
random loc year(loc) rep*year(loc);
estimate "mean" intercept 5 var1*var2 1 0 0 0 0 1 0 0 0 1 0 0 1 0 1 /
divisor = 5;

I tried the following codes:

require(nlme)
fm1 <- lme(yld ~ var1*var2, data = one, random = loc + year | loc + rep *
year | loc)

I have few basic questions:

(a) model and random term specification -  is the above code correct. If
not or there is better way to do it in other packages including lme4

(b) estimate - I do not know how to apply contrasts to the interaction
term. When contrast are applied, how are treatment level sorted in R so
that my orthogonal contrast are not wrong.

	[[alternative HTML version deleted]]


