User Tools

Site Tools


resources:lme

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
resources:lme [2014/09/08 21:11] – Page moved from lme to resources:lme adminresources:lme [2019/05/22 16:08] (current) – external edit 127.0.0.1
Line 14: Line 14:
 However, I found it easier to do this: However, I found it easier to do this:
  
 +<code rsplus>
 colnames(x) <- c("name1","name2"...) colnames(x) <- c("name1","name2"...)
 +</code>
  
 based on guidance from:  based on guidance from: 
Line 24: Line 26:
 http://cran.r-project.org/doc/manuals/r-devel/R-data.html http://cran.r-project.org/doc/manuals/r-devel/R-data.html
  
-''Column names can be given explicitly via the col.names; explicit names override the header line (if present).'' +>Column names can be given explicitly via the col.names; explicit names override the header line (if present).
  
  
Line 30: Line 32:
 http://cran.r-project.org/web/packages/arm/index.html http://cran.r-project.org/web/packages/arm/index.html
  
-''arm: Data Analysis Using Regression and Multilevel/Hierarchical Models 
  
-R functions for processing lm, glm, svy.glm, merMod and polr outputs.''+>''arm: Data Analysis Using Regression and Multilevel/Hierarchical Models'' 
 +
 +>R functions for processing lm, glm, svy.glm, merMod and polr outputs.
  
-**arm** package provides the coefplot() function for plotting the regression coefficient values and std. errors. 
  
 +**arm** package provides the ''coefplot'' function for plotting the regression coefficient values and std. errors.
  
-Need to specify that subjects is a nominal variable, using the //factor// command:+ 
 +Need to specify that subjects is a nominal variable, using the ''factor'' command:
  
 http://www.statmethods.net/input/datatypes.html http://www.statmethods.net/input/datatypes.html
  
-''Tell R that a variable is nominal by making it a factor. The factor stores the nominal values as a vector of integers in the range [ 1... k ] (where k is the number of unique values in the nominal variable), and an internal vector of character strings (the original values) mapped to these integers. ''+>Tell R that a variable is nominal by making it a factor. The factor stores the nominal values as a vector of integers in the range [ 1... k ] (where k is the number of unique values in the nominal variable), and an internal vector of character strings (the original values) mapped to these integers. 
  
 ===== Interpretation of glmer output ===== ===== Interpretation of glmer output =====
-A nice description:+A nice description from:
  
 https://stat.ethz.ch/pipermail/r-sig-mixed-models/2011q1/015590.html https://stat.ethz.ch/pipermail/r-sig-mixed-models/2011q1/015590.html
  
-    In this case the coefficient corresponds to one of the +>In this case the coefficient corresponds to one of the 
-    terms in the model and I would advocate performing a likelihood ratio +>terms in the model and I would advocate performing a likelihood ratio 
-    test comparing the two models +>test comparing the two models 
- +> 
-   fm <- glmer(SameSite~BreedSuc1+Sex+(1|Bird), family="binomial"+><code rsplus> 
-   fm0 <- glmer(SameSite~Sex+(1|Bird), family="binomial" # the null +>fm <- glmer(SameSite~BreedSuc1+Sex+(1|Bird), family="binomial"
-   hypothesis model +>fm0 <- glmer(SameSite~Sex+(1|Bird), family="binomial" # the null 
-   anova(fm0, fm) +>hypothesis model 
-    +>anova(fm0, fm) 
-   Even though the function is called anova it will, in this case, +></code> 
-   perform a likelihood ratio test (LRT).  It also prints the values of +>Even though the function is called anova it will, in this case, 
-   AIC and BIC if you prefer to compare models according to one of those +>perform a likelihood ratio test (LRT).  It also prints the values of 
-   criteria but I prefer using the likelihood ratio for nested models. +>AIC and BIC if you prefer to compare models according to one of those 
- +>criteria but I prefer using the likelihood ratio for nested models. 
-   However, before doing that comparison you should ask yourself whether +>However, before doing that comparison you should ask yourself whether 
-   you want to compare models that have the, apparently unnecessary term +>you want to compare models that have the, apparently unnecessary term 
-   for Sex in them.  The way I would approach the model building is first +>for Sex in them.  The way I would approach the model building is first 
-   to reduce the model to +>to reduce the model to 
- +><code rsplus> 
-   fm1 <- lmer(SameSite~BreedSuc1+(1|Bird), family="binomial"+>fm1 <- lmer(SameSite~BreedSuc1+(1|Bird), family="binomial"
- +></code> 
-   You could then compare +>You could then compare 
- +><code rsplus> 
-   anova(fm1, fm) +>anova(fm1, fm) 
- +></code>  
-   which I presume will give a large p-value for the LRT, so we prefer +>which I presume will give a large p-value for the LRT, so we prefer 
-   the simpler model, fm1.  After that, I would compare +>the simpler model, fm1.  After that, I would compare 
- +><code rsplus> 
-   fm2 <- lmer(SameSite ~ 1 + (1|Bird), family="binomial"+>fm2 <- lmer(SameSite ~ 1 + (1|Bird), family="binomial"
- +></code>
- +
- +
resources/lme.1410225104.txt.gz · Last modified: (external edit)