[R] lme4 problem: model defining and effect estimation ------ question from new bird to R community from SAS community

From: Nilaya Sharma <nilaya.sharma_at_gmail.com>
Date: Fri, 15 Apr 2011 22:21:47 -0400


Hi R community,

I am new bird to R and moved recently from SAS. I am no means expert on either but very curious learner. So your help crucial for me to learn R. I have already got positive expression.

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)

# my R practice codes

require (lme4)
 lmer(adg ~ 1 + (1|sire) + (1|dam/sire), data=genetic_evaluation)

 ****error message********************************************88
 Error: length(f1) == length(f2) is not TRUE In addition: Warning messages:
1: In sire:dam : numerical expression has 20 elements: only the first used 2: In sire:dam : numerical expression has 20 elements: only the first used
**********************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

NIL         [[alternative HTML version deleted]]



R-help_at_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. Received on Sat 16 Apr 2011 - 05:44:26 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 16 Apr 2011 - 08:10:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive