Re: [R] Mixed effects model with binomial errors - problem

2008-09-19 Thread RFTW

anyone?


RFTW wrote:
 
 ok... the model now runs properly (say, without errors). Now about the
 result.
 These are the averages per treatments
 
 tapply(VecesArbolCo.VecesCo.C1,T2,mean)
   a b  c d 
 0.49 0.56 0.45 0.58 
 
 
 I run this very simple model
 
 summary(model1-lmer(cbind(VisitsExpTree,TotalVisits-VisitsExpTree)~
 treatment +(1|Individual), family=binomial, data=r))
 
 Generalized linear mixed model fit by the Laplace approximation 
 Formula: cbind(VisitsExpTree,TotalVisits-VisitsExpTree)~ treatment
 +(1|Individual)  
Data: r 
AIC   BIC logLik deviance
  242.3 255.9 -116.2232.3
 Random effects:
  GroupsNameVariance Std.Dev.
  Individuo (Intercept) 0.14075  0.37517 
 Number of obs: 112, groups: Individuo, 37
 
 Fixed effects:
 Estimate Std. Error z value Pr(|z|)   
 (Intercept)  0.372280.19031  1.9562  0.05044 . 
 treatmentb  0.033670.24520  0.1373  0.89079   
 treatmentc -0.606060.23330 -2.5978  0.00938 **
 treatmentd -0.255040.22790 -1.1191  0.26311   
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
 
 Correlation of Fixed Effects:
 (Intr) T2bT2c   
 T2b -0.675  
 T2c -0.697  0.543   
 T2d -0.720  0.544  0.581
 
 
 wouldnt we expect the intercept to be roughtly the mean of treatment a?
 and thus the estimate of treatmentb to be +0.07, c: -0.04 and d: +0.09
 roughly?
 
 Is this model just completely not estimating well, or are the estimates
 not the 'real values'. 
 
 I tried to get teh predict function to give me the 4 predicted values
 based on the model, but i havent succeeded in doing so. maybe someone can
 help me on that one too (predict(model1,type=response) doesnt work)
 
 thnx
 

-- 
View this message in context: 
http://www.nabble.com/Mixed-effects-model-with-binomial-errorsproblem-tp19413327p19566778.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Mixed effects model with binomial errors - problem

2008-09-19 Thread ONKELINX, Thierry

First of all I'm forwarding this mail to the R-SIG-mixed-models, which
is more appropriate to your question.

Remember that family = bionomial uses by default the logit link. Hence
all parameters will be on the logit scale. So you will need to
backtransform them for comparison. Then you'll see that the parameters
are much closer to the averages. They still differ, but that is due to
the difference in model. Your averages are essentially something like
summary(model1-glm(cbind(VisitsExpTree,TotalVisits-VisitsExpTree)~
treatment +(1|Individual), family=binomial, data=r))

 library(boot)
 intercept - 0.37228
 treatmentb - 0.03367
 treatmentc - -0.60606
 treatmentd - -0.25504
 inv.logit(intercept)
[1] 0.5920098
 inv.logit(intercept + treatmentb)
[1] 0.6001164
 inv.logit(intercept + treatmentc)
[1] 0.4418197
 inv.logit(intercept + treatmentd)
[1] 0.5292765

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens RFTW
Verzonden: vrijdag 19 september 2008 8:16
Aan: r-help@r-project.org
Onderwerp: Re: [R] Mixed effects model with binomial errors - problem


anyone?


RFTW wrote:
 
 ok... the model now runs properly (say, without errors). Now about the
 result.
 These are the averages per treatments
 
 tapply(VecesArbolCo.VecesCo.C1,T2,mean)
   a b  c d 
 0.49 0.56 0.45 0.58 
 
 
 I run this very simple model
 
 summary(model1-lmer(cbind(VisitsExpTree,TotalVisits-VisitsExpTree)~
 treatment +(1|Individual), family=binomial, data=r))
 
 Generalized linear mixed model fit by the Laplace approximation 
 Formula: cbind(VisitsExpTree,TotalVisits-VisitsExpTree)~ treatment
 +(1|Individual)  
Data: r 
AIC   BIC logLik deviance
  242.3 255.9 -116.2232.3
 Random effects:
  GroupsNameVariance Std.Dev.
  Individuo (Intercept) 0.14075  0.37517 
 Number of obs: 112, groups: Individuo, 37
 
 Fixed effects:
 Estimate Std. Error z value Pr(|z|)   
 (Intercept)  0.372280.19031  1.9562  0.05044 . 
 treatmentb  0.033670.24520  0.1373  0.89079   
 treatmentc -0.606060.23330 -2.5978  0.00938 **
 treatmentd -0.255040.22790 -1.1191  0.26311   
 ---
 Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
 
 Correlation of Fixed Effects:
 (Intr) T2bT2c   
 T2b -0.675  
 T2c -0.697  0.543   
 T2d -0.720  0.544  0.581
 
 
 wouldnt we expect the intercept to be roughtly the mean of treatment
a?
 and thus the estimate of treatmentb to be +0.07, c: -0.04 and d: +0.09
 roughly?
 
 Is this model just completely not estimating well, or are the
estimates
 not the 'real values'. 
 
 I tried to get teh predict function to give me the 4 predicted values
 based on the model, but i havent succeeded in doing so. maybe someone
can
 help me on that one too (predict(model1,type=response) doesnt work)
 
 thnx
 

-- 
View this message in context:
http://www.nabble.com/Mixed-effects-model-with-binomial-errorsproble
m-tp19413327p19566778.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document. The views expressed in  this message and 
any annex are purely those of the writer and may not be regarded as stating an 
official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@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.


Re: [R] Mixed effects model with binomial errors - problem

2008-09-11 Thread RFTW

ok... the model now runs properly (say, without errors). Now about the
result.
These are the averages per treatments

tapply(VecesArbolCo.VecesCo.C1,T2,mean)
  a b  c d 
0.49 0.56 0.45 0.58 


I run this very simple model

 summary(model1-lmer(cbind(VisitsExpTree,TotalVisits-VisitsExpTree)~
 treatment +(1|Individual), family=binomial, data=r))

Generalized linear mixed model fit by the Laplace approximation 
Formula: cbind(VisitsExpTree,TotalVisits-VisitsExpTree)~ treatment
+(1|Individual)  
   Data: r 
   AIC   BIC logLik deviance
 242.3 255.9 -116.2232.3
Random effects:
 GroupsNameVariance Std.Dev.
 Individuo (Intercept) 0.14075  0.37517 
Number of obs: 112, groups: Individuo, 37

Fixed effects:
Estimate Std. Error z value Pr(|z|)   
(Intercept)  0.372280.19031  1.9562  0.05044 . 
treatmentb  0.033670.24520  0.1373  0.89079   
treatmentc -0.606060.23330 -2.5978  0.00938 **
treatmentd -0.255040.22790 -1.1191  0.26311   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Correlation of Fixed Effects:
(Intr) T2bT2c   
T2b -0.675  
T2c -0.697  0.543   
T2d -0.720  0.544  0.581


wouldnt we expect the intercept to be roughtly the mean of treatment a? and
thus the estimate of treatmentb to be +0.07, c: -0.04 and d: +0.09 roughly?

Is this model just completely not estimating well, or are the estimates not
the 'real values'. 

I tried to get teh predict function to give me the 4 predicted values based
on the model, but i havent succeeded in doing so. maybe someone can help me
on that one too (predict(model1,type=response) doesnt work)

thnx
-- 
View this message in context: 
http://www.nabble.com/Mixed-effects-model-with-binomial-errorsproblem-tp19413327p19436083.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


[R] Mixed effects model with binomial errors - problem

2008-09-10 Thread RFTW

Hi, 
We released individual birds into a room with 2 trees. We counted the number
of visits to each of the 2 tree. One of the trees is always a control tree
and the other tree is either  treatment 1, treatment 2 or treatment3 or
treatment 4. 


Ind Treat ContrTree ExpTree Total visits
1   1   11  16  27
1   2   6   9   15
1   3   5   13  18
1   4   11  25  36
2   1   2   3   5
4   1   6   7   13
4   3   4   4   8
4   4   2   5   7
6   1   1   1   2
6   4   5   16  21
etc
etc

(as you see, not all treatments are included for all individuals)

Our question is if the proportion of visits to the experimental tree, in
relation to the total number of visits to both trees differs between
treatments.


We have made treatment and individual into a factor
All individuals were subjected to a maximum of 4  treatments, so
'individual' is a random factor


We came up with this model:
model1-lmer(cbind(ExpTree,Total visits-ExpTree)~ Treat +(1|Ind),method=ML
, family=binomial, data=r))

However, the error we get is this:

Error in match.arg(method, c(Laplace, AGQ)) : 
  'arg' should be one of “Laplace”, “AGQ”


HELP!


-- 
View this message in context: 
http://www.nabble.com/Mixed-effects-model-with-binomial-errorsproblem-tp19413327p19413327.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Mixed effects model with binomial errors - problem

2008-09-10 Thread RFTW

ok, the model does run now! 

but, dont i need the method=ML when i want to compare this model with a
reduced model  using anova(model1, model2)? The R-Book tells me that REML is
not good for that (p.635)

So, besides that... how do i now do a sort of posthoc test to see 1)
estimates of all treatments and 2) which treatments are different from
which.

Luc. 
PS. the names are not the original names in the file






Ben Bolker wrote:
 
 RFTW l.temarvelde at nioo.knaw.nl writes:
 
 
 Our question is if the proportion of visits to the experimental tree, in
 relation to the total number of visits to both trees differs between
 treatments.
 
 We have made treatment and individual into a factor
 All individuals were subjected to a maximum of 4  treatments, so
 'individual' is a random factor
 
 We came up with this model:
 model1-lmer(cbind(ExpTree,Total visits-ExpTree)~ Treat
 +(1|Ind),method=ML
 , family=binomial, data=r))
 
   why not leave out method=ML and see what happens?
   for the current iteration of lmer, REML is not a possibility
 in any case.  The default Laplace method should work OK.
 
I'd be slightly worried about your variable name with a space
 in it (`Total visits`) -- are you sure that is working as expected?
 
   For further questions along these lines I would suggest
 e-mailing [EMAIL PROTECTED] instead ...
 
   Ben Bolker
 
 __
 R-help@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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Mixed-effects-model-with-binomial-errorsproblem-tp19413327p19414516.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Mixed effects model with binomial errors - problem

2008-09-10 Thread Ben Bolker
RFTW l.temarvelde at nioo.knaw.nl writes:

 
 
 ok, the model does run now! 
 
 but, dont i need the method=ML when i want to compare this model with a
 reduced model  using anova(model1, model2)? The R-Book tells me that REML is
 not good for that (p.635)

  maximum likelihood (ML) is the default [and only!] estimation
method for generalized linear mixed models (GLMMs, or in other
words lmer with a family argument) in lmer.  It is correct that
you shouldn't compare REML fits with different fixed effects, but
unfortunately it's almost as bad (not theoretically wrong, but
very unreliable for small to moderate sample sizes) to use likelihood
ratio tests (as in anova(model1,model2)) for these tests.

   See http://www.zoo.ufl.edu/bolker/glmm_rev-26aug.pdf for more
information ...

  Ben Bolker

__
R-help@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.