Let me clarify the output I want to create:

Source               X1 (var)                  X2  (var)               X1&X2
(cov)
gen                       var(X1)                  var(X2)
 cov(x1X2)
block                     var(X1)                   var(X2)
cov(x1x2)
error/ res                 var(x1)                   var(x2)
 cov(x1x2)

I need to do posterior analysis out of this table

Thanks in advance

Maya


On Sun, Apr 17, 2011 at 9:59 PM, Maya Joshi <maya.d.joshi@gmail.com> wrote:

> Dear list
>
> I need your help: Execuse me for my limited R knowledge.
>
> #example data set
> set.seed (134)
> lm=c(1:4)
>
> block = c(rep(lm,6))
>
> gen <- c(rep(1, 4), rep(2, 4), rep(3, 4), rep(4, 4),rep(5, 4),rep(6, 4))
>
> X1 = c( rnorm (4, 10, 4), rnorm (4, 12, 6), rnorm (4, 10, 7),rnorm (4, 5,
> 2), rnorm (4, 8, 4), rnorm (4,7, 2))
>
> X2 = X1 + rnorm(length(X1), 0,3)
>
> yvar <- c(X1, X2)
>
> X <- c(rep( 1, length(X1)), rep( 2, length(X2))) # dummy x variable
>
> dataf <- data.frame(as.factor(block), as.factor(gen), as.factor(X), yvar )
>
>
>
> My objective to estimate variance-covariance between two variables X1 and
> X2. Means that I need to fit something like unstructure (UN) covariance
> structure.
>
>
>
> Question 1: I got the following error
>
> require("lme4");
>
> fm1Gen <- lmer(yvar ~ X + gen +(1|block), data= dataf) # Question 1:
> should I consider X fixed or random
>
>
>
> Error in model.frame.default(data = dataf, formula = yvar ~ X + gen +  :
>   variable lengths differ (found for 'gen')
>
>
>
> A tried nlme too.
>
> require(nlme)
>
> fm2Gen <- lme(yvar ~ X + gen,  random= ~ 1|block, data= dataf)
>
> Error in model.frame.default(formula = ~yvar + X + gen + block, data =
> list( :
>   variable lengths differ (found for 'gen') # similar error
>
>
>
> Question 2: How can get I covariance matrix between X1 and X2 either using
> lme4 or lmer.
>
>                X1        X2
>
> X1           Var (X1) Cov(X1,X2)
>
> X2           Cov(X1, X2)  Var(X2)
>
>
>
> Should I put gen in the model to do this? Should I specify something in "*
> correlation* =  "
>
> Thank you for your time
>
> Maya
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

	[[alternative HTML version deleted]]

