Re: [R] Crossed random effects in lme

2004-05-28 Thread Douglas Bates
Søren Højsgaard [EMAIL PROTECTED] writes:

 Dear all,
 In the SASmixed package there is an example of an analysis of a split-plot 
 experiment. The model is
 
   fm1Semi - lme( resistance ~ ET * position, data = Semiconductor, random = ~ 1 | 
 Grp)
 
 where Grp in the Semiconductor dataset is defined as ET*Wafer. Is it possible to 
 specify the grouping directly some way, e.g. like 
 
   fm1Semi - lme( resistance ~ ET * position, data = Semiconductor, random = ~ 1 | 
 ET*Wafer)

Actually that does work with lme from the as-yet-unreleased version
0.6-1 of the lme4 package.  See the slides from my presentation at
useR!2004
 http://www.ci.tuwien.ac.at/Conferences/useR-2004/Keynotes/Bates.pdf

I'm back at my home now and will endeavor to get lme4_0.6-1 released
as soon as possible.

-- 
Douglas Bates[EMAIL PROTECTED]
Statistics Department608/262-2598
University of Wisconsin - Madisonhttp://www.stat.wisc.edu/~bates/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Crossed Random Effects ?

2004-03-19 Thread Wilhelm B. Kloke
I have been asked how to handle the following situation in R:

Given an unbalanced design of 3 crossed random effects, such as
subject, rater and item, how to estimate the variance components?

I know how to do it using lme, but this seems to be limited to
the nested case; or to use aov with error strata, when the
design is balanced. 
-- 
Dipl.-Math. Wilhelm Bernhard Kloke
Institut fuer Arbeitsphysiologie an der Universitaet Dortmund
Ardeystrasse 67, D-44139 Dortmund, Tel. 0231-1084-257

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Crossed Random Effects ?

2004-03-19 Thread Douglas Bates
Wilhelm B. Kloke [EMAIL PROTECTED] writes:

 I have been asked how to handle the following situation in R:
 
 Given an unbalanced design of 3 crossed random effects, such as
 subject, rater and item, how to estimate the variance components?
 
 I know how to do it using lme, but this seems to be limited to
 the nested case; or to use aov with error strata, when the
 design is balanced. 

With the current version of lme it is difficult and inefficient to
work with crossed random effects.  A new version of lme being
developed makes this much easier.  I expect to release new versions of
the Matrix and lme4 packages with R-1.9.0 (early April). I will
describe the new lme capabilities in more detail at the useR!2004
conference in May.
-- 
Douglas Bates[EMAIL PROTECTED]
Statistics Department608/262-2598
University of Wisconsin - Madisonhttp://www.stat.wisc.edu/~bates/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] crossed random effects- clarified version

2003-07-02 Thread Sarah Mclean
Hi,

here is a clarified version of my problem.

I have a total of 4*74 observations on 74 different
mums in 5 different populations of mums, subject to 6
treatments (2 moisture levels*3 substrate types).

I want to know if mum interacts with moisture level or
substrate type.

Population, moisture and substrate are fixed effects
and mum is a random effect within population. Plot is
a random whole-plot error for a split-plot design. The
data set is called fm.

This is the formula I used and the error message I
got:

fm$pmu - getGroups(fm, ~1|pop/mum, level=2)
fm$grp = as.factor(rep(1,nrow(fm)))
fm$pl - getGroups(fm, ~1|plot)
fm$mo - getGroups(fm, ~1|moist)
fm$su - getGroups(fm, ~1|sub)
 fm1 - lme(sqrt(mass) ~ iheight + moist*sub*pop,
data=fm, random=list(grp=pdBlocked(list(pdIdent(~pl -
1), pdIdent(~pmu - 1),  pdIdent(~pmu:su - 1),
pdIdent(~pmu:mo - 1)
Error in chol((value + t(value))/2) : non-positive
definite matrix in chol

The model works if the interaction terms:
pdIdent(~pmu:su - 1), pdIdent(~pmu:mo - 1), are
removed, so they are causing the problem. 

The model also works if I test mums from one
population at a time so that mum no longer needs to be
nested, i.e. if I replace pmu with mu:
fm$mu - getGroups(fm, ~1|mum)
 fm1 - lme(sqrt(mass) ~ iheight + moist*sub,
data=fm, random=list(grp=pdBlocked(list(pdIdent(~pl -
1), pdIdent(~pmu - 1),  pdIdent(~mu:su - 1),
pdIdent(~mu:mo - 1)

It would be a lot faster if I can test all of the
populations at once instead of individually.

Any help would be much appreciated.

Thanks,
Sarah

http://mobile.yahoo.com.au - Yahoo! Mobile
- Check  compose your email via SMS on your Telstra or Vodafone mobile.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] crossed random effects

2003-07-01 Thread Spencer Graves
	  Have you studied Pinhiero and Bates (2000) Mixed Effects Models in S 
and S-Plus (Springer)?

	  Also, have you tried simplifying your lme call until you get 
something that works, then start adding back terms in various 
configurations until it breaks?

	  Have you tried to compute how many coefficients are estimated in both 
fixed and random terms and evaluate whether all are estimable?  For 
example, with 2 factors at 2 levels each, if you don't have all 4 
possible combinations, you can't estimate the interaction -- even if you 
have thousands of replications of each.

	  Finally, you can always try to read the code.  I've learned a lot 
about S-Plus / R by doing that -- and solved a lot of my own problems 
that way.

hope this helps.  spencer graves

Sarah Mclean wrote:
Hi,

if I have posted this twice, please ignore this. I'm
not sure if I sent it to the correct e-mail address
the first time.
I have a data set on germination and plant growth with
the following variables:
dataset=fm
mass (response)
sub (fixed effect)
moist (fixed effect)
pop (fixed effect)
mum (random effect nested within population)
iheight (covariate)
plot (random effect- whole plot factor for split-plot
design).
I want to see if moist or sub interacts with mum for
any of the pops, but I am getting an error message. 

This is the formula I used:
fm$pmu - getGroups(fm, ~1|pop/mum, level=2)
fm$grp = as.factor(rep(1,nrow(fm)))
fm$pl - getGroups(fm, ~1|plot)
fm$mo - getGroups(fm, ~1|moist)
fm$su - getGroups(fm, ~1|sub)
fm1 - lme(sqrt(mass) ~ iheight + moist*sub*pop,
data=fm, random=list(grp=pdBlocked(list(pdIdent(~pl -
1), pdIdent(~pmu - 1),  pdIdent(~pmu:su - 1),
pdIdent(~pmu:mo - 1)
Error in chol((value + t(value))/2) : non-positive
definite matrix in chol
I know the problem is with the random interaction
terms, but I don't know how to overcome this.
Any advice would be greatly appreciated. I'm new to R
and analysis such as this.
Thank you,

Sarah Mclean
[EMAIL PROTECTED]
http://mobile.yahoo.com.au - Yahoo! Mobile
- Check  compose your email via SMS on your Telstra or Vodafone mobile.
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] crossed random effects

2003-07-01 Thread Sarah Mclean
Hi,

thanks for the advice. I have looked at the Pinheiro
and Bates book and I've tried simplifying my model.

I've narrowed the problem down to having mum nested
within pop. If I run the analysis on each population
separately, the interaction between mo and su with mum
works fine.

If I could analyse all of the pops at once this would
be preferable because I have multiple responses and
pops to test so it would take a bit of time. I'm
hoping there is any easier way.

Thanks 
Sarah

 --- Spencer Graves [EMAIL PROTECTED] wrote:  
  Have you studied Pinhiero and Bates (2000) Mixed
 Effects Models in S 
 and S-Plus (Springer)?
 
 Also, have you tried simplifying your lme call
 until you get 
 something that works, then start adding back terms
 in various 
 configurations until it breaks?
 
 Have you tried to compute how many coefficients
 are estimated in both 
 fixed and random terms and evaluate whether all are
 estimable?  For 
 example, with 2 factors at 2 levels each, if you
 don't have all 4 
 possible combinations, you can't estimate the
 interaction -- even if you 
 have thousands of replications of each.
 
 Finally, you can always try to read the code. 
 I've learned a lot 
 about S-Plus / R by doing that -- and solved a lot
 of my own problems 
 that way.
 
 hope this helps.  spencer graves
 
 Sarah Mclean wrote:
  Hi,
  
  if I have posted this twice, please ignore this.
 I'm
  not sure if I sent it to the correct e-mail
 address
  the first time.
  
  I have a data set on germination and plant growth
 with
  the following variables:
  
  dataset=fm
  mass (response)
  sub (fixed effect)
  moist (fixed effect)
  pop (fixed effect)
  mum (random effect nested within population)
  iheight (covariate)
  plot (random effect- whole plot factor for
 split-plot
  design).
  
  I want to see if moist or sub interacts with mum
 for
  any of the pops, but I am getting an error
 message. 
  
  This is the formula I used:
  fm$pmu - getGroups(fm, ~1|pop/mum, level=2)
  fm$grp = as.factor(rep(1,nrow(fm)))
  fm$pl - getGroups(fm, ~1|plot)
  fm$mo - getGroups(fm, ~1|moist)
  fm$su - getGroups(fm, ~1|sub)
  
 fm1 - lme(sqrt(mass) ~ iheight + moist*sub*pop,
  
  data=fm,
 random=list(grp=pdBlocked(list(pdIdent(~pl -
  1), pdIdent(~pmu - 1),  pdIdent(~pmu:su - 1),
  pdIdent(~pmu:mo - 1)
  Error in chol((value + t(value))/2) : non-positive
  definite matrix in chol
  
  I know the problem is with the random interaction
  terms, but I don't know how to overcome this.
  
  Any advice would be greatly appreciated. I'm new
 to R
  and analysis such as this.
  
  Thank you,
  
  Sarah Mclean
  [EMAIL PROTECTED]
  
  
  http://mobile.yahoo.com.au - Yahoo! Mobile
  - Check  compose your email via SMS on your
 Telstra or Vodafone mobile.
  
  __
  [EMAIL PROTECTED] mailing list
 

https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 
  

http://mobile.yahoo.com.au - Yahoo! Mobile
- Check  compose your email via SMS on your Telstra or Vodafone mobile.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] crossed random effects

2003-07-01 Thread Spencer Graves
	  How many mum's and pop's do you have, and how many observations do 
you have of each mum-pop combination?  If you want mum nested within 
pop, do I infer correctly that each mum has mated with only one pop, but 
that each pop may have offspring by multiple mums?  The table of mum-pop 
combinations might help explain why you got, Error in chol((value + 
t(value))/2) : non-positive definite matrix in chol.

	  If you can get an answer ignoring pop, then you might be able to get 
an answer with pop as a separate random term without specifying mum 
nested within pop.  Also, I'd check very carefully the specification of 
nesting:  I've messed that up more than once, and I'm bald now, because 
I tore all my hair out before I figured out what I was doing wrong. 
(Well, there is a slight exageration there.)  Have you tried a very 
simple toy problem (or a published example) with nesting to make sure 
you can get the correct answer?

hope this helps.
spencer graves
Sarah Mclean wrote:
Hi,

thanks for the advice. I have looked at the Pinheiro
and Bates book and I've tried simplifying my model.
I've narrowed the problem down to having mum nested
within pop. If I run the analysis on each population
separately, the interaction between mo and su with mum
works fine.
If I could analyse all of the pops at once this would
be preferable because I have multiple responses and
pops to test so it would take a bit of time. I'm
hoping there is any easier way.
Thanks 
Sarah

 --- Spencer Graves [EMAIL PROTECTED] wrote:  
  Have you studied Pinhiero and Bates (2000) Mixed

Effects Models in S 
and S-Plus (Springer)?

	  Also, have you tried simplifying your lme call
until you get 
something that works, then start adding back terms
in various 
configurations until it breaks?

	  Have you tried to compute how many coefficients
are estimated in both 
fixed and random terms and evaluate whether all are
estimable?  For 
example, with 2 factors at 2 levels each, if you
don't have all 4 
possible combinations, you can't estimate the
interaction -- even if you 
have thousands of replications of each.

	  Finally, you can always try to read the code. 
I've learned a lot 
about S-Plus / R by doing that -- and solved a lot
of my own problems 
that way.

hope this helps.  spencer graves

Sarah Mclean wrote:

Hi,

if I have posted this twice, please ignore this.
I'm

not sure if I sent it to the correct e-mail
address

the first time.

I have a data set on germination and plant growth
with

the following variables:

dataset=fm
mass (response)
sub (fixed effect)
moist (fixed effect)
pop (fixed effect)
mum (random effect nested within population)
iheight (covariate)
plot (random effect- whole plot factor for
split-plot

design).

I want to see if moist or sub interacts with mum
for

any of the pops, but I am getting an error
message. 

This is the formula I used:
fm$pmu - getGroups(fm, ~1|pop/mum, level=2)
fm$grp = as.factor(rep(1,nrow(fm)))
fm$pl - getGroups(fm, ~1|plot)
fm$mo - getGroups(fm, ~1|moist)
fm$su - getGroups(fm, ~1|sub)

fm1 - lme(sqrt(mass) ~ iheight + moist*sub*pop,
data=fm,
random=list(grp=pdBlocked(list(pdIdent(~pl -

1), pdIdent(~pmu - 1),  pdIdent(~pmu:su - 1),
pdIdent(~pmu:mo - 1)
Error in chol((value + t(value))/2) : non-positive
definite matrix in chol
I know the problem is with the random interaction
terms, but I don't know how to overcome this.
Any advice would be greatly appreciated. I'm new
to R

and analysis such as this.

Thank you,

Sarah Mclean
[EMAIL PROTECTED]
http://mobile.yahoo.com.au - Yahoo! Mobile
- Check  compose your email via SMS on your
Telstra or Vodafone mobile.

__
[EMAIL PROTECTED] mailing list

https://www.stat.math.ethz.ch/mailman/listinfo/r-help




http://mobile.yahoo.com.au - Yahoo! Mobile
- Check  compose your email via SMS on your Telstra or Vodafone mobile.
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] crossed random effects

2003-06-30 Thread Sarah Mclean
Hi,

I have a data set on germination and plant growth with
the following variables:

dataset=fm
mass (response)
sub (fixed effect)
moist (fixed effect)
pop (fixed effect)
mum (random effect nested within population)
iheight (covariate)
plot (random effect- whole plot factor for split-plot
design).

I want to see if moist or sub interacts with mum for
any of the pops, but I am getting an error message. 

This is the formula I used:
fm$pmu - getGroups(fm, ~1|pop/mum, level=2)
fm$grp = as.factor(rep(1,nrow(fm)))
fm$pl - getGroups(fm, ~1|plot)
fm$mo - getGroups(fm, ~1|moist)
fm$su - getGroups(fm, ~1|sub)
 fm1 - lme(sqrt(mass) ~ iheight + moist*sub*pop,
data=fm, random=list(grp=pdBlocked(list(pdIdent(~pl -
1), pdIdent(~pmu - 1),  pdIdent(~pmu:su - 1),
pdIdent(~pmu:mo - 1)
Error in chol((value + t(value))/2) : non-positive
definite matrix in chol

I know the problem is with the random interaction
terms, but I don't know how to overcome this.

Any advice would be greatly appreciated. I'm new to R
and analysis such as this.

Thank you,

Sarah Mclean
[EMAIL PROTECTED]


http://mobile.yahoo.com.au - Yahoo! Mobile
- Check  compose your email via SMS on your Telstra or Vodafone mobile.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] crossed random effects

2003-06-30 Thread Sarah Mclean
Hi,

if I have posted this twice, please ignore this. I'm
not sure if I sent it to the correct e-mail address
the first time.

I have a data set on germination and plant growth with
the following variables:

dataset=fm
mass (response)
sub (fixed effect)
moist (fixed effect)
pop (fixed effect)
mum (random effect nested within population)
iheight (covariate)
plot (random effect- whole plot factor for split-plot
design).

I want to see if moist or sub interacts with mum for
any of the pops, but I am getting an error message. 

This is the formula I used:
fm$pmu - getGroups(fm, ~1|pop/mum, level=2)
fm$grp = as.factor(rep(1,nrow(fm)))
fm$pl - getGroups(fm, ~1|plot)
fm$mo - getGroups(fm, ~1|moist)
fm$su - getGroups(fm, ~1|sub)
 fm1 - lme(sqrt(mass) ~ iheight + moist*sub*pop,
data=fm, random=list(grp=pdBlocked(list(pdIdent(~pl -
1), pdIdent(~pmu - 1),  pdIdent(~pmu:su - 1),
pdIdent(~pmu:mo - 1)
Error in chol((value + t(value))/2) : non-positive
definite matrix in chol

I know the problem is with the random interaction
terms, but I don't know how to overcome this.

Any advice would be greatly appreciated. I'm new to R
and analysis such as this.

Thank you,

Sarah Mclean
[EMAIL PROTECTED]


http://mobile.yahoo.com.au - Yahoo! Mobile
- Check  compose your email via SMS on your Telstra or Vodafone mobile.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help