Edwin Lebrija Trejos | 23 May 05:35
Picon
Favicon

Group level predictors in mixed models


Dear R-sig-mixed-models subscribers, I am analizing survival (ALIVE) of one year-old seedlings of over a
hundred species as a function of the total number of seedlings (TOTABN) and the proportion of
conspecifics seedlings (CONSPp) in their neighborhood (sampling quadrat). The data comes from
monitoring seedling dynamics trough time (YEAR) in a series of forest plots (PLOT). A crucial part of the
analysis is to understand the variation in responses between species (SPECIES). For now, I have one
continuous species-level variable, abundance across the landscape (LANDSPABN), that I would like to
use to explain the variation between species. After reading a number of printed and online references on
advanced statistical models it seems to me that my problem could be properly analyzed using hierarchical
bayesian modelling but I am just beggining to understand lmer (and R) and I was wondering if using such
tools I can also perform a meaningfull analysis.My first approach in lmer was to specify a model with
varying intercept and slope for the effect of conspecifics, i.e. (1+CONSPp|SPECIES) and to extract from
the results the conditional modes (using terminology in Prof. Bates draft book) of the random effects
(and their variances) to model them separately as a function other continuous predictors (using simple
weighted linear regressions). The full model of this approach is:
M1<-lmer(ALIVE~CONSPp+TOTABN+(1+CONSPp|SPECIES)+(1|PLOT)+(1|YEAR),
data=oneyrseedl,family=binomial).  After further reading I found an example from Gelman and Hill 2007
in which he includes "group level predictors". Specifically in their example, a predictor X1 appears
both as fixed (y~ X1) and random effect (1+ X1 | grouping factor) with the grouping factor predictor (X2)
modelled as an interaction with X1. So their full model is y ~ X1 + X2 + X1:X2+ (1 + X1 | grouping factor).  I
thought I may be able to specify a similar model to directly incorporate my continuous species-level
variable (species abundance across the landscape) to explain the variation in the effect of
conspecifics on seedling survival. One crucial difference between my case and Gelman and Hill´s case is
that my continuous species-level variable has only one value per species (my grouping factor) while
their X2 has a series of values per grouping factor. I thus think that if include the continuous
species-level variable in the model I do not need to include a random slope for the effects of conspecifics
(with SPECIES as a grouping factor) as I feel it would control for all the variation that could be more
meaningfully explained by my species-level variable (or any other species-level variable I may come up
later).  Thus, the model I am thinking about would  be: M2<-lmer(ALIVE~CONSPp+TOTABN+ LANDSPABN+
CONSPp:LANDSPABN + (1|PLOT)+(1|YEAR), data=oneyrseedl,family=binomial).  I am doubting if a random
(Continue reading)

Gang Chen | 22 May 19:56
Picon

How to obtain t-values from mer objects

I know how to obtain the fixed effects from a mer object:

> (fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))

> fixef(fm1)

or,

> getME(fm1, 'beta')

But how can I obtain the t-statistic values for the fixed effects?

Thanks,
Gang

Daisuke Koya | 22 May 15:16
Picon

Syntax for lme function to model random factors and interactions

Hello all,

The following (i.e. below the hash marks) is a reposting of something originally posted on the R forum. I was
told by a helpful person there to redirect my question to this forum.

My question concerns what the correct expression is to specify two random factors for the lme function. So
far I've tried:

	random = ~ 1|C + D

	random = ~ 1 + (1|C) + (1|D)

	random = ~ 1 + 1|C + 1|D

but all of these resulted in errors (mostly of the type "
Error in getGroups.data.frame(dataMix, groups) : Invalid formula for groups"). To be more specific, "C"
refers to a subject factor, while "D" refers to a repetition factor (i.e. multiple evaluations of the same
stimulus by the same subject). In this case, would the correct way to code this be:

	random = ~ 1|C/D

? Additionally, I would be grateful if someone could tell me whether I have to code the interactions in the
"random" argument in the lme function, and if so how.

Thank you very much in advance for the help.

Best regards,

Daisuke

(Continue reading)

Ahmad Rabiee | 22 May 06:51
Picon

reaped measures with unequal intervals

Hi

I have a repeated measures dataset with unequal intervals (spacing) - the intervals are Day 6, Day 13 and Day 15.
Anyone knows how to handle this type of data?

Thanks
Ahmad

	[[alternative HTML version deleted]]

Kenneth Frost | 22 May 05:24
Picon
Favicon

Re: ZERO variance and ZERO sd of random effect in lmer - justified to run a glm instead?

Try
dat$sitc <- scale(dat$sit, center = TRUE, scale = FALSE)

On 05/21/12, Julia Sommerfeld 
 wrote:
> the fixed effect "sit" is a logit transformed proportion of "psit". Some of
> the values in "psit" equal zero. Other than that, I don't know what could
> be the problem. To be honest, I haven't use the scale function before in a
> lmer. Thus, I don't quite understand why a different coef estimate is a
> problem? Since I transformed the "sit" values, why shouldn't the coef
> change accordingly?
> 
> Julia
> 
> 
> 
> 2012/5/22 Ewart Thomas <ethomas@...>
> 
> > julia, there's something funny about your new fixed effects. i expected
> > the intercept to change, and it did - a reduction of 1.1.
> >
> > i expected the effect of sitc (1.3) to be the same as that of sit (.75);
> > and the effect of dive to be the same. why the change in the sitc coeff.
> > scale() just centers, it doesn't standardise, correct?
> >
> > see if you can figure out what's 'wrong', e.g., by looking at your raw
> > data file, coding of birds (as a factor), coding of sit as numeric. i
> > estimate the sit mean to be 0.84. is this right? ...
> > ewart
> >
(Continue reading)

Julia Sommerfeld | 22 May 05:06
Picon
Picon
Favicon

Re: ZERO variance and ZERO sd of random effect in lmer - justified to run a glm instead?

the fixed effect "sit" is a logit transformed proportion of "psit". Some of
the values in "psit" equal zero. Other than that, I don't know what could
be the problem. To be honest, I haven't use the scale function before in a
lmer. Thus, I don't quite understand why a different coef estimate is a
problem? Since I transformed the "sit" values, why shouldn't the coef
change accordingly?

Julia

2012/5/22 Ewart Thomas <ethomas@...>

> julia, there's something funny about your new fixed effects.  i expected
> the intercept to change, and it did - a reduction of 1.1.
>
> i expected the effect of sitc (1.3) to be the same as that of sit (.75);
> and the effect of dive to be the same.  why the change in the sitc coeff.
>  scale() just centers, it doesn't standardise, correct?
>
> see if you can figure out what's 'wrong', e.g., by looking at your raw
> data file, coding of birds (as a factor), coding of sit as numeric.  i
> estimate the sit mean to be 0.84.  is this right? ...
> ewart
>
> On May 21, 2012, at 6:31 PM, Julia Sommerfeld wrote:
>
> Hi Ewart,
>
> Thanks for the quick reply. I've run the model using "sitc". But the
> variance is still zero.
>
(Continue reading)

Julia Sommerfeld | 22 May 03:31
Picon
Picon
Favicon

Re: ZERO variance and ZERO sd of random effect in lmer - justified to run a glm instead?

Hi Ewart,

Thanks for the quick reply. I've run the model using "sitc". But the
variance is still zero.

dat$sitc <- scale(dat$sit)

> mod8 <- lmer(ars1 ~ sitc + dive + (1|bird), data=dat, family=binomial)

> summary(mod8)
Generalized linear mixed model fit by the Laplace approximation
Formula: ars1 ~ sitc + dive + (1 | bird)
   Data: dat
   AIC   BIC logLik deviance
 159.4 171.7 -75.71    151.4
Random effects:
 Groups Name        Variance Std.Dev.
 bird   (Intercept)  0        0
Number of obs: 160, groups: bird, 25

Fixed effects:
            Estimate Std. Error z value Pr(>|z|)
(Intercept)  -1.5423     0.3705  -4.163 3.14e-05 ***
sitc          1.2913     0.2495   5.175 2.28e-07 ***
dive          1.3076     0.4374   2.990  0.00279 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
     (Intr) sitc
(Continue reading)

Julia Sommerfeld | 22 May 03:07
Picon
Picon
Favicon

ZERO variance and ZERO sd of random effect in lmer - justified to run a glm instead?

Dear list,

I'm running a lmer (package lme4) with a binomial error distribution and
"bird" as the random effect (160 observations of 25 birds). The response
variable "ars1" is coded as 0, 1.
The fixed effect "sit" is numerical and "dive" is categorical (0, 1).

What puzzles me a little is that the a variance and sd of the random effect
is ZERO. Same question has been posted before and Douglas Bates answer was:

"No, an estimate of zero is not suspicious.  It is simply an indication

that the variability between individuals is not significantly larger
than what one would expect from the random variability in the
response."

While another answer suggested that the model was "wrong":

"A zero estimate of a variance possibly indicates the model is wrong."  This
wrong model seemed to be related to a negative covariation of one of the
fixed effects ?

 My simplified model is:

mod6 <- lmer(ars1 ~ sit + dive + (1|bird), data=dat, family=binomial)

> summary(mod6)
Generalized linear mixed model fit by the Laplace approximation
Formula: ars1 ~ sit + dive + (1 | bird)
   Data: dat
(Continue reading)

Charles Determan Jr | 21 May 18:16
Picon

Re: 2nd attempt - conflict of dfs or f value in lme

Thank you for giving this some thought Joshua.  I will be sure to keep
troubleshooting this as well.  Would it be related to how gls calculates
its values that is somehow reports the 'correct' F value perhaps?

Regards,
Charles

On Mon, May 21, 2012 at 11:08 AM, Joshua Wiley <jwiley.psych@...>wrote:

> That suggests they are fitting different models somehow (not just that
> the specifc effect estimates are different).  No brilliant ideas on in
> what way though...
>
> I checked REML versus ML but that was not it.  I'll let you know if I
> have any ideas.
>
> Cheers,
>
> Josh
>
> On Mon, May 21, 2012 at 9:02 AM, Charles Determan Jr <deter088@...>
> wrote:
> > Hi Joshua,
> >
> > The -2 Log-likelihood from SAS is -58.6
> > The log-likelihood from R fit.13 is 21.9.  I assume this would be
> multiplied
> > by -2 which would give -43.8.
> >
> > Regards,
(Continue reading)

Charles Determan Jr | 21 May 14:45
Picon

2nd attempt - conflict of dfs or f value in lme

Greetings R users,

I am trying to match some SAS output of a mixed model.  After running PROC
MIXED with the covariance structure as AR1 the output below is given.  Now
when I try to replicate this with lme, I get the correct degrees of freedom
and somewhat close values.  If I try with gls, I get the exact F value but
the incorrect denominator degrees of freedom.  Is there some syntax or
parameter I can adjust to get lme to have the same F values as gls?  That
way the correct degrees of freedom would be applied and I would get the
replicated model.  The data is also included below.  Thanks to any who can
help with this issue.

Regards,

Charles

Row   ID Group Died Event_name      var
1    12510     3  YES          B     -1.05257
2    12510     3  YES        S45    -1.00000
3    12510     3  YES        FR2   -1.14630
4    12510     3  YES        FR8   -1.08831
5    12510     3  YES       FR20   -1.03339
6    21510     3   NO          B      -0.87290
7    21510     3   NO        S45     -1.22185
8    21510     3   NO        FR2     -1.01592
9    21510     3   NO        FR8    -1.06550
10   21510     3   NO       PR48    -0.65326
11   22210     3  YES          B     -1.37059
12   30810     3   NO          B     -0.92959
13   30810     3   NO        S45    -1.26680
(Continue reading)

Chris Gast | 20 May 23:12
Picon

Help with simple LME model specification in MCMCglmm

Hello,

I would like to specify the following model (in lmer() syntax) in MCMCglmm,
but seem to be unable to do so. I receive the warning message "some fixed
effects are not estimable and have been removed", although I do not believe
this should be the case.

Here's the lmer() model:

fit = lmer(y ~ -1 + cyear:stratum + site + (-1+cyear|site),data=indat)

And here's an attempt at fitting this in MCMCglmm():

fitmcmc = MCMCglmm(y ~ -1 + cyear:stratum +
site,random=~idh(-1+cyear):site,data=indat)

The data structure is relatively simple: stratum and site are categorical
(technically site is nested within stratum, so I'd give bonus points if
someone can help me specify separate variance components for the
site-specific slopes within each stratum), and "cyear" is the continuous
predictor for which I would like stratum-specific slopes with random slopes
for each site (again, within stratum, if possible).

Thanks,

Chris Gast

-----------------------------
Chris Gast
cmgast@...
(Continue reading)


Gmane