[R-sig-ME] [R] errors with lme4
Ben Bolker
bbolker at gmail.com
Thu Nov 24 23:08:37 CET 2011
[cc'ing to r-sig-mixed-models list]
On 11-11-24 03:25 PM, Alessio Unisi wrote:
> Hi Ben,
> thanks for answer!
>
> sorry but i'm a new R-user and i'm not so skilled...also in statistic! : ))
> just few answer and question to yours...
Knowing *neither* R *nor* statistics can be a fairly dangerous
combination. If you ask politely, people on the R help lists will often
help with statistical questions, but they are technically off-topic.
There are other places (such as http://stats.stackexchange.com/ ) for
asking statistics questions ... and it would really be very best to see
if you can get some local help (classes or helpful colleagues/fellow
students/professors/consultants).
>
>> I can't prove it, but I strongly suspect that some of your
>> coefficients are perfectly multicollinear.
>
> some they are...yes..but not all...hatch and lay surely they are...what
> does it change i have to multiplicate instead of sum?
By "perfectly multicollinear" I don't mean that they are strongly
collinear (which ecologists often worry about, correctly, but sometimes
more than they need to) but rather "perfectly".
For example, suppose you ran a 2x2 factorial design (e.g. effects of
temperature and light) but ended up with a missing "corner" (e.g. no
samples in the high-light/high-temperature combination). You would then
be unable to estimate an interaction term, because you would be trying
to estimate 4 parameters (intercept/grand mean, light effect,
temperature effect, interaction) from only three independent sets of
data. This is the same idea: some of your predictors probably line up
*perfectly* with combinations of other predictors.
>
> the idea of using glmer() or lmer() is because i had to deal with random
> factor (1|territory)...glm can't handle this? i don't think...
You're correct that you will need to get back to glmer() eventually,
but I wanted you try out glm() because the presence of NAs in your
coefficient vector will confirm that collinearity is the problem, not
some other issue with glmer ...
>
>> How many observations are left after na.omit(fledge)?
>>
>>
> sorry..i don't understand...
When you run the analysis, R will drop rows from your data set that
have NAs in any of the predictors. It looks like you have a total of
152 observations, but I wonder how many there are with complete records.
nrow(na.omit(fledge)) will tell you this.
>> What is the difference between your 'S1' and 'S2' temperature
>> records?
>
> those are temperature recorded in different time....S1 is during egg
> laying and incubation and S2 is during hatching and rearing of the chicks
Can we please see the results of summary(fledge)?
It would be good if you were willing to post your whole data set
somewhere for download (or at a pinch e-mail it to me).
Ben Bolker
>
>
> thank you
> alessio
>
>
> Ben Bolker ha scritto:
>> Alessio Unisi <franceschi6 <at> unisi.it> writes:
>>
>>
>>> Dear R-users,
>>> i need help for this topic!
>>>
>>> I'm trying to determine if the reproductive success (0=fail,
>>> 1=success) of a species of bird is related to a list of covariates.
>>>
>>> These are the covariates:
>>> § elev: elevation of nest (meters)
>>> § seadist: distance from the sea (meters)
>>> § meanterranova: records of temperature
>>> § minpengS1: records of temperature
>>> § wchillpengS1: records of temperature
>>> § minpengS2: records of temperature
>>> § wchillpengS2: records of temperature
>>> § nnd: nearest neighbour distance
>>> § npd: nearest penguin distance
>>> § eggs: numbers of eggs
>>> § lay: laying date (julian calendar)
>>> § hatch: hatching date (julian calendar)
>>> I have some NAs in the data.
>>>
>>> I want to test the model with all the variable then i want to remove
>>> some, but the ideal model:
>>> GLM.1 <-lmer(fledgesucc ~ +lay +hatch +elev +seadist +nnd +npd
>>> +meanterranova +minpengS1 +minpengS2 +wchillpengS1 +wchillpengS2
>>> +(1|territory), family=binomial(logit), data=fledge)
>>>
>>> doesn't work because of these errors:
>>> 'Warning message: In mer_finalize(ans) : gr cannot be computed at
>>> initial par (65)'.
>>> "matrix is not symmetric [1,2]"
>>>
>>> If i delete one or more of the T records (i.e. minpengS2
>>> +wchillpengS2) the model works...below and example:
>>>
>>> GLM.16 <-lmer(fledgesucc ~ lay +hatch +elev +seadist +nnd +npd
>>> +meanterranova +minpengS1 +(1|territory), family=binomial(logit),
>>> data=fledge)
>>>
>>> > summary(GLM.16)
>>> Generalized linear mixed model fit by the Laplace approximation
>>> Formula: fledgesucc ~ lay + hatch + elev + seadist + nnd + npd +
>>> meanterranova + minpengS1 + (1 | territory)
>>> Data: fledge
>>> AIC BIC logLik deviance
>>> 174 204.2 -77 154
>>> Random effects:
>>> Groups Name Variance Std.Dev.
>>> territory (Intercept) 0.54308 0.73694
>>> Number of obs: 152, groups: territory, 96
>>>
>>>
>>
>> I can't prove it, but I strongly suspect that some of your
>> coefficients are perfectly multicollinear. Try running your
>> model as a regular GLM:
>>
>> g1 <- glm(fledgesucc ~ +lay +hatch +elev +seadist +nnd +npd
>> +meanterranova +minpengS1 +minpengS2 +wchillpengS1 +wchillpengS2
>> and see if some of the coefficients are NA.
>>
>> coef(g1)
>>
>> lm() and glm() can handle this sort of "rank-deficient" or
>> multicollinear input, (g)lmer can't, as of now.
>>
>> I suspect that you may be overfitting your model anyway:
>> you should aim for not more than 10 observations per parameter
>> (in your case, since all your predictors appear to be continuous,
>> How many observations are left after na.omit(fledge)?
>>
>> What is the difference between your 'S1' and 'S2' temperature
>> records?
>>
>> ______________________________________________
>> 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.
>>
>>
>> -----
>> Nessun virus nel messaggio.
>> Controllato da AVG - www.avg.com
>> Versione: 2012.0.1873 / Database dei virus: 2101/4636 - Data di
>> rilascio: 24/11/2011
>>
>
More information about the R-sig-mixed-models
mailing list