Hi Peter and R community;

Thank you Peter for suggestion. I tried the following:

 genetic_evaluation<-transform(genetic_evaluation,
sire=factor(sire),dam=factor(dam))
 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:*************************************

 estimate 'sire 1 BLUP "broad" '
            intercept 1 | sire 1 0;
*#predicts performance of sire 1 across across entire dam to which he might
be mated i.e. mu + si *
*
*
   estimate 'sire 1 BLUP "narrow" '
            intercept 2 | sire 2 0
            dam(sire) 1 1  0 0  0 0  0 0  0 0  / divisor=2;
*# performance of ith sire on those dams to which they are actually mated
 mu + si + 1/2 sum(d x sij)*

   estimate 'sire 1 BLUP with dam 1'
            intercept 1 | sire 1 0
            dam(sire) 1 0;
*# 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
estimate 'sire 1 BLUP "broad" '
            intercept 1 |
            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 !!

**************************************************Just hint for
explanation *******************************
The following SAS explanation for contrast and estimate functions:
CONTRAST ‘label’ fixed-effect values | random-effect values / options;
ESTIMATE ‘label’ fixed-effect values | random-effect values / options;

The CONTRAST statement is used when there is need for custom hypothesis
tests, the ESTIMATE statement, when there is need for custom estimates.
Although they were extended in PROC MIXED to include random effects, their
use is very similar to the CONTRAST and ESTIMATE statement in PROC GLM.
suppose that we want to test if there is a significant effect of treat in
group 2, where treat has three levels and group four levels.
We also want to estimate the mean for treat 1 in group 2, the mean for treat
2 in group 2 and the difference between these two means. We will need the
following CONTRAST and ESTIMATE statements to obtain these results.

*Proc mixed data=one method=reml covtest;*
*Class group treat subject;*
*Model y=group treat group*treat /ddfm=satterth;*
*Random subject(group);*
*Contrast ‘treat in group 2’*
*Treat 1 –1 0 group*treat 0 0 0 1 –1 0 0 0 0 0 0 0,*
*Treat 0 1 –1 group*treat 0 0 0 0 1 –1 0 0 0 0 0 0;*
*Estimate ‘treat1 group2 mean’ intercept 1 group 0 1 0 0 treat 1 0 0*
*group*treat 0 0 0 1 0 0 0 0 0 0 0 0;*
*Estimate ‘treat2 group2 mean’ intercept 1 group 0 1 0 0 treat 0 1 0*
*Group*treat 0 0 0 0 1 0 0 0 0 0 0 0;*
*Estimate ‘mean diff t1g2-t2g2’ Treat 1 –1 0 group*treat 0 0 0 1 –1 0 0 0 0
0 0 0;*
*Run;*




On Sat, Apr 16, 2011 at 3:45 AM, peter dalgaard <pda...@gmail.com> wrote:

>
> On Apr 16, 2011, at 04:21 , Nilaya Sharma wrote:
>
> > genetic_evaluation <- read.table(textConnection("
> > sire dam adg
> > 1  1  2.24
> > 1  1  1.85
> > 1  2  2.05
> > 1  2  2.41
> ....
> > 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)
> >
> > # my R practice codes
> > require (lme4)
> > lmer(adg ~ 1 + (1|sire) + (1|dam/sire), data=genetic_evaluation)
>
>
> You're missing the equivalent of the SAS class statement. Grouping
> variables need to be factors:
>
> genetic_evaluation<-transform(genetic_evaluation,
>  sire=factor(sire),
>  dam=factor(dam))
>
> Also, you probably don't want a random main effect of dam, so
>
> lmer(adg ~ 1 + (1|sire) + (1|dam:sire), data=genetic_evaluation)
>
> or even
>
> lmer(adg ~ 1 + (1|sire/dam), data=genetic_evaluation)
>
>
> --
> Peter Dalgaard
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Email: pd....@cbs.dk  Priv: pda...@gmail.com
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to