Dear Mixed Model Experts

I was trying to fit a mixed model in animal experiment but stuck at simple
point. The following similar example is from SAS mixed model pp 212.

# data

genetic_evaluation <- read.table(textConnection("
sire dam adg
1  1  2.24
1  1  1.85
1  2  2.05
1  2  2.41
2  1  1.99
2  1  1.93
2  2  2.72
2  2  2.32
3  1  2.33
3  1  2.68
3  2  2.69
3  2  2.71
4  1  2.42
4  1  2.01
4  2  1.86
4  2  1.79
5  1  2.82
5  1  2.64
5  2  2.58
5  2  2.56"), header = TRUE)

 require(lme4); mod <- lmer(adg ~ 1 + (1|sire) + (1|dam:sire),
data=genetic_evaluation)
 ranef (mod)

provides random effects associated with dam:sire and sire,  but do not
provide the comparisons I  need. It looks like I need to define and apply
own contrasts or there is any other functions to do so? Please consider the
following situations:


*********************** I am still struggling to find a suitable way for the
following estimates:*************************************

*#predicts performance of sire 1 across across entire dam to which he might
be mated i.e. mu + si *
*# performance of ith sire on those dams to which they are actually mated
 mu + si + 1/2 sum(d x sij)*
*# conditional mean,  mu + si + d(s)ij , dam specific predictor assessing
performance of a specific sire-by-dam combination*

   ods select CovParms Estimates;

#and for all estimate outputs
            sire 1 0  0   0 0
            dam(sire)  0 0  0 0  0 0  0 0  0 0;
*# every effects in the model, sire 1 0 is causing remaining sire effects
zero*

***************************my
trial**************************************************8
#just scratch for the first of the following estimation:
attach(genetic_evaluation)
sireconts <- c(1,0)
contrasts(sire) <- sireconts
 contrasts(sire) <- sireconts

Error in `contrasts<-`(`*tmp*`, value = c(1, 0)) :
  wrong number of contrast matrix rows

I did not further because I did not if I am trying in right direction !!

**********************how can I estimate the BLUP effects?*************
#equavalent code in SAS
proc mixed data=genetic_evaluation;
   class sire dam;
   model adg= / ddfm=kr;
   random sire dam(sire);
   estimate 'sire 1 BLUP "broad" '
            intercept 1 | sire 1 0;
   estimate 'sire 1 BLUP "narrow" '
            intercept 2 | sire 2 0
            dam(sire) 1 1  0 0  0 0  0 0  0 0  / divisor=2;
   estimate 'sire 1 BLUP with dam 1'
            intercept 1 | sire 1 0
            dam(sire) 1 0;
   ods select CovParms Estimates;
run;

# Estimate statement define predictable functions. All fixed effect
cofficient must appear first and then random effect coefficients. The fixed
and random
#effect cofficient are seperated by |

****************Expected outputs according to SAS
*************************************
                      Estimate
sire 1 BLUP "broad    2.2037
sire 1 BLUP "narrow"  2.1609
sire 1 BLUP with dam1 2.1002

 Data details:
The data is animal science data in which five sires were randomly sampled
from the population and were randomly mated with two dams.
Two offspring per sire dam combination were measured. Average daily gain was
recorded. We are interested in breeding value of ith sire(means that which
gives offsprings with higher gain


Thank you for your help

NIL

	[[alternative HTML version deleted]]


