LmerNotes - MRC CBU Language Wiki

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
Type the odd letters out: scieNce GATHeRS knowledge fAster tHAN SOCIeTY GATHErS wisdom

location: LmerNotes

http://r.789695.n4.nabble.com/lmer-causes-segfault-td2335407.html

LmerExamples

in lmer this is pretty crucial if you have factors that are identified by numerical values:

>dummy.data = read.csv("~/tmp/tmp.csv")
>dummy.data$c <- factor(dummy.data$c)


> str(dummy.data)
'data.frame':   4800 obs. of  5 variables:
 $ g : Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ...
 $ s : Factor w/ 24 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ c : Factor w/ 100 levels "1","2","3","4",..: 1 1 2 2 3 3 4 4 5 5 ...
 $ pc: Factor w/ 2 levels " c"," p": 1 2 1 2 1 2 1 2 1 2 ...
 $ x : num  0.175 0.511 0.237 0.572 0.306 ...

ezANOVA converts numeric values to factors because it knows that everything but the dependent variable must be a factor.

ezANOVA is limited in the number of levels of a factor (roughly 50?)

lmer can take multiple levels, but doesn't give you standard stats.

> library(ez)
>ezPrecis(dummy.data)
Data frame dimensions: 4800 rows, 5 columns
      type missing values min max
g   factor     1.       1.   1   2
s   factor     1.     24    1.  24
c   factor     1.    100    1. 100
pc  factor     1.       1.   c   p
x  numeric     1.   3848    1.   1

The factor (ordered) function creates a factor (ordered
factor) from a vector. Factor labels can be specied in the
optional labels argument.
Suppose the spray variable in the InsectSprays data was
stored as numeric values 1; 2; : : : ; 6. We convert it back to a
factor with factor.
> str(sprays <- within(InsectSprays, spray <- as.integer(spray))'data.frame': 72 obs. of 2 variables:
$ count: num 10 7 20 14 14 12 10 23 17 20 ...
$ spray: int 1 1 1 1 1 1 1 1 1 1 ...
> str(sprays <- within(sprays, spray <- factor(spray,
+ labels = LETTERS[1:6])))
'data.frame': 72 obs. of 2 variables:
$ count: num 10 7 20 14 14 12 10 23 17 20 ...
$ spray: Factor w/ 6 levels "A","B","C","D",..: 1 1 1 1 1 1 1 1 1 1 ...

-- Main.DennisNorris - 27 Oct 2010