[R-sig-ME] scope for LHS of formula in lmList
Ken Knoblauch
ken.knoblauch at inserm.fr
Mon Sep 6 11:25:51 CEST 2010
Hi,
I have a data frame
str(Context)
'data.frame': 120 obs. of 4 variables:
$ Obs : Factor w/ 6 levels "A","B","C","D",..: 1 1 1 1 1 1 1 1 1 1 ...
$ TargCntr: num 0 0.002 0.004 0.006 0.008 0 0.002 0.004 0.006 0.008 ...
$ NumYes : int 0 0 5 18 23 24 22 22 22 24 ...
$ NumNo : int 24 24 19 6 1 0 2 2 2 0 ...
and find that if I run lmList as follows, I get an error message
in which names from the data frame are not found if enclosed in
a cbind for the LHS of formula (for a binomial family)
lmList(cbind(NumYes, NumNo) ~ TargCntr | Obs,
data = Context, family = binomial)
Error in cbind(NumYes, NumNo) : object 'NumYes' not found
...
but it works fine if I either define a 2 column matrix in my
workspace or add one to the data frame.
resp <- with(Context, cbind(NumYes, NumNo))
lmList(resp ~ TargCntr | Obs, Context, binomial)
Call: lmList(formula = resp ~ TargCntr | Obs, data = Context, family =
binomial)
Coefficients:
(Intercept) TargCntr
A -0.8574118 369.1977
B -0.8048122 425.1355
...
or
Context <- within(Context, Resp <- cbind(NumYes, NumNo))
lmList(Resp ~ TargCntr | Obs, Context, binomial)
Call: lmList(formula = Resp ~ TargCntr | Obs, data = Context, family =
binomial)
Coefficients:
(Intercept) TargCntr
A -0.8574118 369.1977
B -0.8048122 425.1355
...
So, there is an easy workaround. I've mostly been working
with binary responses lately, so hadn't noticed this behavior
earlier.
sessionInfo()
R version 2.11.1 Patched (2010-08-30 r52847)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] lme4_0.999375-35 Matrix_0.999375-44 lattice_0.19-11
loaded via a namespace (and not attached):
[1] grid_2.11.1 MASS_7.3-7 nlme_3.1-96 stats4_2.11.1
[5] tools_2.11.1
Thank you.
best,
Ken
--
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html
More information about the R-sig-mixed-models
mailing list