Re: [R] Urgent - I really need some help lme4 model avg Estimates

2012-03-28 Thread Dragonwalker
Thank you Mitchell,

I will try that. So I presume that the initial paper where they showed the
estimates AND the intercept from a model averaging procedure may have been
done using a different method?

Would it still be prudent to use a global model and then perhaps show the
top so many, perhaps those with a delta2  and then show their weights?
Would it also be okay to just do a model average and then perhaps show the
weights of each covariate and factor within these models to show their
relative importance? I think the way the paper presented the results of
extremely similar research, using only models using A+B+C+(1|D) etc and then
model average, and able to come up with an Intercept and then much smaller
comparable estimates made me think that this was probably the correct way to
present the results and that getting these values must be something that I
just didn't know how to code. They were even able to compare the Estimate
differences among the variables whereas when I used -1 to remove the
intercept the distance between the variables differed (although within
stayed the same).

Thank you again for your kind reply.

Rachel



--
View this message in context: 
http://r.789695.n4.nabble.com/Urgent-I-really-need-some-help-lme4-model-avg-Estimates-tp4511178p4512504.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] two lmer questions - formula with related variables and output interpretation

2012-03-27 Thread Dragonwalker
Hello,
I have been attempting to set up a lme and have looked at numerous posts
including 'R's lmer cheat-sheet' as well as reading a number of papers and
other resources including R help, but I am still a little confused on how to
write my model (I thought I had it).

I have asked a number of questions on different forums; most of which have
been resolved.

My main concern right now is whether my model is correct. I studied broods
of precocial chicks and watched each chick every other day for five minutes
if possible. As chicks on the same day are completely non-independent the
mean was found for each brood for each day. Variables that were recorded
were the behaviours during that time and the habitats used.

There were seven broods. Three at one site and four at the other site. Only
one site had a brood that consistently used mudflats rather than oceanfront
habitats. As none of the data within a brood is truly independent, along
with the very small number of broods, it became impossible to use
conventional statistics to test the hypotheses and so it was suggested that
mixed-effects models would be the best option as it would not only allow for
all data to be used with a random effect of Brood ID to negate the
pseudo-replication but also let me look at partial use of mudflats in one of
the other broods that only used it periodically.

So, for this part of the analysis I would like to see which factors affect
the amount of time feeding. I set up a global model with ten fixed variables
plus (1|Brood). Site, tide.h.l, tide.inc.out, MF.vs.OF, Human Disturbance
Rate (HDr), Human Disturbance proportion of time(HDp), non-Human Disturbance
(two variables as for Human Disturbance) and Age and mean.foraging.rate. As
so:

gm1-lmer(Feeding~Site+tide.level+MF.vs.OF+HDr+HDp+NHDr+NHDp+Age+mean.for.rate+(1|Brood),
data=AllBrood, REML=TRUE)

I wished to put all the factors together to explore which ones really did
influence the time spent feeding and used 'dredge' command to run all
possible combinations and then averaged the models with an AICc Delta2. I
was expecting that the proportion of time being disturbed (HDp and NHDp)
would be the most relevant as by default the greater time in other
behaviours the less time for feeding. However, MF.vs.OF had a larger effect
than HDp and NHDp but this may be because MF observations did not experience
HDp at all so this may push the effect of this habitat. Surprisingly
non-human disturbance rates rather than time had a greater effect (but these
are quite even among habitats.

The results of the model.avg are as follows:
 Estimate Std. Error z value Pr(|z|)
(Intercept)   102.7190 5.5300  18.575   2e-16 ***
HDr-1.5495 0.3451   4.490 7.11e-06 ***
MF.vs.OF2  -7.6780 3.7507   2.047  0.04065 *  
NHDp   -0.5145 0.2909   1.769  0.07695 .  
NHDr   -1.4164 0.4663   3.037  0.00239 ** 
Site2   6.1477 2.7400   2.244  0.02485 *  
tide.h.l2  -7.2546 2.6914   2.695  0.00703 ** 
tide.inc.out2  -5.8486 2.6187   2.233  0.02553 *  
HDp-0.3773 0.2732   1.381  0.16731
mean.for.rate  -0.3966 0.3220   1.232  0.21807
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Full model-averaged coefficients (with shrinkage): 
 (Intercept)HDr  MF.vs.OF2   NHDp   NHDr  Site2 
tide.h.l2 tide.inc.out2HDp
  102.718962  -1.549499  -5.734171  -0.239550  -1.416373   5.336532 
-7.254627 -5.848553  -0.044795
 mean.for.rate
 -0.081734

Relative variable importance:
  (Intercept)   Age   HDp   HDr mean.for.rate 
MF.vs.OF  NHDp  NHDr 
 1.00  0.00  0.12  1.00  0.21 
0.75  0.47  1.00 
 Site  tide.h.l  tide.inc.out 
 0.87  1.00  1.00 

I was wondering whether there would be a better way to formulate the model
to allow for this effect, or could I just keep it as is and just infer that
it may be partly affected by the amount of disturbance within these habitats
but as it has a greater effect that other factors are at play which would
then lead me onto the next model which is going to explore observations that
do not include disturbance which would allow me to tease the natural factors
affecting feeding behaviour? I was going to run this second model with site
still as a fixed effect and then run it with (1|Site) to remove site effect
(if one is found).

I would prefer to keep it simple as I really want to use a lme, but don't
have the understanding for more complex interactions.

I has also asked a question, which is yet to be answered on stats stack
exchange, in regards to the output of the model.avg.  as follows:

I have seen the Estimates described as the effect of the variable and this
is discussed in results sections as an important value to report (in regards
to the size of them and their direction (+ve/-ve). (the paper I 

Re: [R] Using MuMIn - error message

2012-03-27 Thread Dragonwalker
Hello Mike,

I don't think I did, but I fixed the issue by loading each package before
use. The second issue was solved by removing a variable that was used to
create two other categorical variables. I think it must have been
recognising this.

Thanks for the help.

--
View this message in context: 
http://r.789695.n4.nabble.com/Using-MuMIn-error-message-tp4500236p4508901.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] two lmer questions - formula with related variables and output interpretation

2012-03-27 Thread Dragonwalker
I realised that I removed the link to the question but forgot to remove the
text regarding it. Sorry. I am not sure if I am supposed to link to other
forums, but I can add the links as needed (as the format is clearer).

I actually have one more question though in regards to which data to use.
If it is better to just report the estimates and CIs then should I use those
with shrinkage instead, and if so, does anyone know how I can get the CIs
for these rather than just the regular CIs. I apologise if I am asking too
many questions within one post.

Rachel

--
View this message in context: 
http://r.789695.n4.nabble.com/two-lmer-questions-formula-with-related-variables-and-output-interpretation-tp4508876p4509334.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] Urgent - I really need some help lme4 model avg Estimates

2012-03-27 Thread Dragonwalker
Hello all,
If someone could take a little time to help me then I would be very
grateful.
I studied piping plovers last summer. I watched each chick within a brood
for 5 minutes and recorded behaviour, habitat use and foraging rate.
There were two Sites, the first with 4 broods and the second with 3 broods.  
http://r.789695.n4.nabble.com/file/n4511178/Table_PP_Maslo_et_al.png As the
data within a brood is non-independent and the fact that there were so few,
then conventional statistical tests were of little use. I therefore spent a
couple of months looking at mixed-models to allow me to use all the data for
each day and use (1|Brood) as a random effect.

At first i struggled with what models meant, but last week they 'sort of '
clicked and realised how to run them and how to weigh which models were the
best (using AICc). 
As I had a number of factors/covariates that I wanted to look at I learned
to use the dredge command in the MuMIn package from an a priori global model
and decided to model average the models with a delta2.

I have two main questions: 
I was looking at similar research that also looked at models and they also
came up with model average estimates and CIs for each variable and factor. 
They ended up with one table showing the top so many models with their AICc,
delta and weights and then another table showing the model average Estimates
and CIs for each factor and co-variate and also the Intercept.   Each
category within each variable was shown (I have attached an image of the
table - the heading does not seem to match what is shown however).
Their explanation of the variables was as follows:
A second model including these variables and wind speed reported a DAICc
score 2; therefore, we model- averaged the parameter estimates included in
these 2 best models (Table 3). Of the 5 habitats in which we observed
plovers feeding, effect size was highest at artificial tidal ponds (5.52),
followed by the intertidal zone (3.97). Positive effects of ephemeral pools
(2.65) and bay shores (2.32) on adult foraging rates were 48% and 42% lower
than artificial ponds,
respectively. Conversely, sand flats (-2.30) had an equal but opposite
effect on foraging rate, when compared to bay
shores. The results also indicated that foraging rate was highest for adults
during the post-breeding stage. In addition,
vehicles had a 2.3 times larger effect on foraging adults than people.
Finally, foraging rates during low tide were
higher than at high tide by a factor of 2.5, as would be expected.

As you can see, their explanation seems to suggest that all values are
comparable e.g. vehicles and people.

When I ran the model average I also got an Intercept estimate but only the
second and beyond categorical Estimates were shown (e.g. if one factor was
high tide, low tide, then only the estimate for low tide was shown,
obviously an estimate of difference between the two).
I asked on stats.stackexchange and they suggested just adding -1 to the end
of the model, but although this worked, the estimates became much bigger to
compensate for there being no intercept and although the difference between
the Estimates were the same for 'within factor', the 'among factor'
variables seemed to change (bigger differences between), along with the
p-values for each group. In addition there was, of course, no intercept.

I am therefore wondering whether anyone knows how I may be able to preserve
the initial Estimates but still get the missing values (obviously the other
researchers seemed to have done this as they still have an intercept and
comparable estimates).

This is my most important issue right now, but if someone has a moment,
could you also tell me whether I should use the p-values as well, or should
i just stick with explaining the magnitude of the effects, their direction
and their Relative Importance. i want to keep it at a level that I can
understand.

Thank you in advance. I know everyone is busy but I would be very grateful
for a prompt response if at all possible.

Sincerely.

--
View this message in context: 
http://r.789695.n4.nabble.com/Urgent-I-really-need-some-help-lme4-model-avg-Estimates-tp4511178p4511178.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] Urgent - I really need some help lme4 model avg Estimates

2012-03-27 Thread Dragonwalker
I understand where you are coming from, but the issue is that some
exploration of the data through graphs and the like, showed that patterns
could be seen. However with only 7 means it is extremely difficult to get
any kind of statistical evidence and as some mean values are the same some
of the tests that I wanted to use such as a Mann-Whitney would not even run
so I had to resort to a one-sample Wilcoxon with a set mu value. (minimum
p-value that was even possible was p=0.280). 

I asked a couple of forums in December about the issues at hand and they
suggested that I look into mixed-effect models so I read some chapters on
them and got very excited, but at the time still thought of them as some
test that could give me means. However it all clicked and I realise that
they can be more useful as a tool to illustrate which factors and covariates
best fit to the response variable.

I understand the concepts of fitting an intercept and slope somewhat but the
paperwork on it can be a little confusing, however the way they were used in
the paper (of which I attached one of the tables) seemed a very
straightforward method of teasing the intricate factors of habitat, age and
other factors that could be affecting behaviour such as time feeding and
foraging rate. Believe me, if i could have survived with Kruskal-Wallis then
I would have had my thesis written up three months ago with a lot less
stress. I am not looking for pretty as I don't even want it published, but I
did hope to be able to give the time that I spent collecting data justice.

I have come really far, thanks to some great people, but I do not have
anyone near me who can help and my adviser is 3000 miles away too and is not
a statistician either.
All I would like to know is how could Maslo et al. have calculated estimates
for all categories AND an intercept and is there a method to do this in R. 
I have spent months trying to find these answers and so I would greatly
appreciate an answer to this question. 

Thank you again.



--
View this message in context: 
http://r.789695.n4.nabble.com/Urgent-I-really-need-some-help-lme4-model-avg-Estimates-tp4511178p4511396.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] Using MuMIn - error message

2012-03-24 Thread Dragonwalker
This was solved by loading each package right before using it (I thought you
loaded both at the beginning). However I now have an additional issue. I ran
a small model with just three factors to try it out and it worked
beautifully, but when I tried to run it with all the factors this is what I
got when I tried to run the model:

 ABmodel-read.csv(file.choose(), header=T)
 ABmodel$Brood-as.factor(ABmodel$Brood)
 ABmodel$Site-as.factor(ABmodel$Site)
 ABmodel$Age.class-as.factor(ABmodel$Age.class)
 ABmodel$Tide-as.factor(ABmodel$Tide)
 ABmodel$tide.h.l-as.factor(ABmodel$tide.h.l)
 ABmodel$tide.inc.out-as.factor(ABmodel$tide.inc.out)
 ABmodel$MF.vs.OF-as.factor(ABmodel$MF.vs.OF)
 local({pkg - select.list(sort(.packages(all.available =
 TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
 
 fullABmodel1-lmer(Feeding~Site+Age.class+tide.h.l+tide.inc.out+Tide+HDp+NHDp+Foraging.Eff+MF.vs.OF+Age+HDr+NHDr+AllDr+(1|Brood),
 data=ABmodel, REML=FALSE)
Error in mer_finalize(ans) : Downdated X'X is not positive definite, 7.
 fullABmodel1-lmer(Feeding~Site+Age.class+tide.h.l+tide.inc.out+Tide+HDp+NHDp+Foraging.Eff+MF.vs.OF+Age+HDr+NHDr+AllDr+(1|Brood),
 data=ABmodel, REML=FALSE)
Error in mer_finalize(ans) : Downdated X'X is not positive definite, 7.
 fullABmodel1-lmer(Feeding~Site+Age.class+tide.h.l+tide.inc.out+Tide+HDp+NHDp+Foraging.Eff+MF.vs.OF+Age+HDr+NHDr+AllDr+(1|Brood),
 data=ABmodel, REML=FALSE)
Error in mer_finalize(ans) : Downdated X'X is not positive definite, 7.
 summary(fullABmodel)
Error in summary(fullABmodel) : 
  error in evaluating the argument 'object' in selecting a method for
function 'summary': Error: object 'fullABmodel' not found
 
I am attaching my raw .csv file. Note those above that are as.factors. The
file has more factors than I am using because I am also going to be looking
at different issues with it. Note that broods are nested within site but I
want to see if site has an effect. I ran a smaller model and it was weighted
and had a delta below 2 but not sure if that is only because so few factors
were being compared, so thought I would run it as a fixed then maybe as a
random later. http://r.789695.n4.nabble.com/file/n4500740/AllBroodmodel.csv
AllBroodmodel.csv 


--
View this message in context: 
http://r.789695.n4.nabble.com/Using-MuMIn-error-message-tp4500236p4500740.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] Using MuMIn - error message

2012-03-23 Thread Dragonwalker
Hello,
I hope that you can bare with me. I am new to models, but I think I have a
pretty godd understanding of how to run them now, including how to use AICc
and Anova. The issue is that I have many factors that I wish to compare so
doing each one at a time would take forever.
I came across the MuMIn package and I was so excited, however I am getting
an error message and i don't know why.
Firstly it is a mixed model that I am running with lme4. The .csv file that
it comes from has more factors than I will probably use but I only listed
the ones that I wanted to test. I had also coded the ones that are labels
and not continuous data using the as.factor command and I ran the most
complex model and ran summary() and it seemed to have worked fine.

My model was:
fm2test-lmer(Feeding~MF.vs.OF+Age.class+tide.h.l+Site+HDp+(1|Brood),
data=ABMtest.df)

and then I wanted to use the dredge command as so:
dd-dredge(fm2test, trace=TRUE, rank=AICc, REML=FALSE)

I got an error:
Error in UseMethod(fixef) : 
  no applicable method for 'fixef' applied to an object of class mer

I have no idea how to fix this. I have looked at ?dredge but cannot find
anything there and I am very new to R so any help would be greatly
appreciated. 

I want to run all the possible models using the factors and then want to
identify those models which best explain Feeding. I also have other models
to run and in addition I have more factors to use but wanted to do this
first as a test. 

Could someone also advise me on a way to list all models in order and if
each model is accessible in order to compare with Anova?

Thank you so much in advance.

Rachel

--
View this message in context: 
http://r.789695.n4.nabble.com/Using-MuMIn-error-message-tp4500236p4500236.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.