nested random effect in advanced.procD.lm

299 views
Skip to first unread message

netbird....@gmail.com

unread,
Oct 30, 2017, 9:45:05 AM10/30/17
to geomorph R package
Hi,
I'm trying to construct a mixed model to test for one fixed factor effect (treatment) using advanced.procD.lm ('type' is another fixed factor).
I'd like to add the nested factors site/female as a random effect and use log(cs) as co-variance.
Yet, when I try the syntax I know from lme4 package:

advanced.procD.lm(shape ~log(cs)+(1+treat|site/female)+type, ~log(cs)+(1+treat|site/female)+type+treat, ...)

I get an error:

Error in procD.fit(f1, data = data, pca = FALSE, ...) :
  Your formula appears to have data embedded within objects
                             (a '$' is part of the formula).  It is not possible to reconcile
                             the location of the data from the object that contains it with this
                             function.  Either use a geomorph data frame or liberate the data from
                             the object and try again.

What am I doing wrong?

Any help will be appreciated,
Avi

Mike Collyer

unread,
Oct 30, 2017, 10:16:44 AM10/30/17
to geomorph-...@googlegroups.com
Avi,

advanced.procD.lm does not use the syntax of lme4.  What you are doing wrong is to assume that the formula arguments in one function from a completely different package work in other functions in other packages.  Unfortunately, the procD.lm and advanced.procD.lm functions do not have the same formula argument capability as lme4 (specifically specifying common or random intercepts).

Mike

-- 
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.
To post to this group, send email to geomorph-...@googlegroups.com.
Visit this group at https://groups.google.com/group/geomorph-r-package.
To view this discussion on the web, visit https://groups.google.com/d/msgid/geomorph-r-package/45bea1e7-0bf7-4392-9c5f-a8212f012bd0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

netbird....@gmail.com

unread,
Oct 30, 2017, 10:25:59 AM10/30/17
to geomorph R package
Hi Mike,
Thanks!
Is there other (more complicated?) way to state which of my factors are random (maybe even nested?) with intercept and/or slope?
thanks again,
Avi


On Monday, October 30, 2017 at 4:16:44 PM UTC+2, Michael Collyer wrote:
Avi,

advanced.procD.lm does not use the syntax of lme4.  What you are doing wrong is to assume that the formula arguments in one function from a completely different package work in other functions in other packages.  Unfortunately, the procD.lm and advanced.procD.lm functions do not have the same formula argument capability as lme4 (specifically specifying common or random intercepts).

Mike
On Oct 30, 2017, at 9:45 AM, netbird....@gmail.com wrote:

Hi,
I'm trying to construct a mixed model to test for one fixed factor effect (treatment) using advanced.procD.lm ('type' is another fixed factor).
I'd like to add the nested factors site/female as a random effect and use log(cs) as co-variance.
Yet, when I try the syntax I know from lme4 package:

advanced.procD.lm(shape ~log(cs)+(1+treat|site/female)+type, ~log(cs)+(1+treat|site/female)+type+treat, ...)

I get an error:

Error in procD.fit(f1, data = data, pca = FALSE, ...) :
  Your formula appears to have data embedded within objects
                             (a '$' is part of the formula).  It is not possible to reconcile
                             the location of the data from the object that contains it with this
                             function.  Either use a geomorph data frame or liberate the data from
                             the object and try again.

What am I doing wrong?

Any help will be appreciated,
Avi

-- 
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.

Mike Collyer

unread,
Oct 30, 2017, 10:40:31 AM10/30/17
to geomorph-...@googlegroups.com
Hi Avi,

No, these functions do not have that capability.  nested.update can change F values to recognize that the MS for random effects should be used rather than MSE, but that is the limit to the functionality of geomorph functions.  lme4 is designed for univariate data and uses ML or REML rather than least squares for parameter estimation, which makes a prior designation of fixed and random effect important.

One could use lmer, shape variable by shape variable, and then try to find a way to bring the results back together for a multivariate hypothesis test, but I do not presume to even suggest how to go about that.

Mike

To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.

To post to this group, send email to geomorph-...@googlegroups.com.
Visit this group at https://groups.google.com/group/geomorph-r-package.

netbird....@gmail.com

unread,
Oct 30, 2017, 11:11:02 AM10/30/17
to geomorph R package
Hi Mike,
One last question if I may: having a factor I can't include in my models (in advanced.procD.lm) as a random factor, does it make more sense to include it in both the reduced and full models with another (suppose to be fixed) factor, or to omit it altogether?
Thank you,
Avi
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsubscri...@googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.
To post to this group, send email to geomorph-...@googlegroups.com.
Visit this group at https://groups.google.com/group/geomorph-r-package.

Mike Collyer

unread,
Oct 30, 2017, 4:19:39 PM10/30/17
to geomorph-...@googlegroups.com
Hi Avi,

I’m not sure I understand this question.  Whatever factor you want to add to either the full or reduced model does not need to be designated as fixed or random to be included or excluded.  For example, if A is random and B is fixed, one can do this

fit <- advanced.procD.lm( Y ~ A, Y ~ B/A, …)

and results would pertain to a hypothesis test for the fixed effect, given the random effect.  You do not have to try to convince the function that one is random and one is fixed.  Keep in mind that least-squares estimation of parameters is used though.

Mike

To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.

To post to this group, send email to geomorph-...@googlegroups.com.
Visit this group at https://groups.google.com/group/geomorph-r-package.

netbird....@gmail.com

unread,
Oct 31, 2017, 12:40:57 PM10/31/17
to geomorph R package
Hi Mike,

In your example you nested a random factor within a fixed factor in the full model. I think I understand.
What I meant is, if I want to test for the treatment ('treat') effect (which is a fixed factor):

fit <- advanced.procD.lm(shape ~ female + type, ~ female + type + treat...)

Doesn't it matter that I include/mix  a random factor (female) and a fixed factor (type) in the reduced model as if they are equal?

Avi

Mike Collyer

unread,
Oct 31, 2017, 12:50:04 PM10/31/17
to geomorph-...@googlegroups.com
Avi,

You can have ~ female + type in both models; you can have ~type/female in both models; you can have ~ type * female in both models.  You just have to decide - based on your point of view, preference, and personal dogma, as the researcher who knows these data - which way you want to model these alternative sources of variation for your test of treatment.

I like to think of this as a null hypothesis test for var(treatment | other model effects).  The other model effects can be dealt with in multiple ways.  You choose the way and tell us why it is important.

Cheers!
Mike

-- 

You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.
To post to this group, send email to geomorph-...@googlegroups.com.
Visit this group at https://groups.google.com/group/geomorph-r-package.

netbird....@gmail.com

unread,
Oct 31, 2017, 12:59:45 PM10/31/17
to geomorph R package
Mike,
Thank you so much.
Avi


On Tuesday, October 31, 2017 at 6:50:04 PM UTC+2, Michael Collyer wrote:
Avi,

You can have ~ female + type in both models; you can have ~type/female in both models; you can have ~ type * female in both models.  You just have to decide - based on your point of view, preference, and personal dogma, as the researcher who knows these data - which way you want to model these alternative sources of variation for your test of treatment.

I like to think of this as a null hypothesis test for var(treatment | other model effects).  The other model effects can be dealt with in multiple ways.  You choose the way and tell us why it is important.

Cheers!
Mike
On Oct 31, 2017, at 12:40 PM, netbird....@gmail.com wrote:

Hi Mike,

In your example you nested a random factor within a fixed factor in the full model. I think I understand.
What I meant is, if I want to test for the treatment ('treat') effect (which is a fixed factor):

fit <- advanced.procD.lm(shape ~ female + type, ~ female + type + treat...)

Doesn't it matter that I include/mix  a random factor (female) and a fixed factor (type) in the reduced model as if they are equal?

Avi

-- 
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages