Sean Zhang
2009-Apr-10 20:48 UTC
[R] How to handle tabular form data in lmer without expanding the data into binary outcome form?
Dear R-gurus:
I have a question about lmer.
Basically, I have a dataset, in which each observation records number of
trials (N) and number of events (Y) given a covariate combination(X) and
group id (grp_id).
So, my dataset is in tabular form. (in case my explanation of tabular form
is unclear,
please see the link:
http://www.stat.psu.edu/online/development/stat504/06_logreg/11_logreg_fitmodel.htm
)
My question: what is the lmer syntax for tabular data ("model Y/N=X"
is the
what SAS does as seen in the link above).
In specific, where can I add N (number of trials) into the following line of
lmer code?
m1 <- lmer(Y ~ X+(1|grp_id), family=biomial(link="logit"))
As you may expect, I try to avoid expanding the tabular form data into
binary (0,1) outcome form data because doing so causes a quite large data
matrix in my study).
A link with similar question is seen at
https://stat.ethz.ch/pipermail/r-help/2008-May/161072.html
Seems to me, that link is implementing data expansion approach (they have
only 1600 obs after data expansion).
If someone knows a neat solution other than data expansion, please help.
Many thanks in advance!
-Sean
[[alternative HTML version deleted]]
Kingsford Jones
2009-Apr-10 21:43 UTC
[R] How to handle tabular form data in lmer without expanding the data into binary outcome form?
See ?lmer and notice model gm1 in the examples. As with glm, a binomial lmer model can have the response specified "as a two-column matrix with the columns giving the numbers of successes and failures". hth, Kingsford Jones On Fri, Apr 10, 2009 at 2:48 PM, Sean Zhang <seanecon at gmail.com> wrote:> Dear R-gurus: > > I have a question about lmer. > Basically, I have a dataset, in which each observation records number of > trials (N) and number of events (Y) given a covariate combination(X) and > group id (grp_id). > So, my dataset is in tabular form. (in case my explanation of tabular form > is unclear, > please see the link: > http://www.stat.psu.edu/online/development/stat504/06_logreg/11_logreg_fitmodel.htm > ) > > My question: what is the lmer syntax for tabular data ("model Y/N=X" is the > what SAS does as seen in the link above). > In specific, where can I add N (number of trials) into the following line of > lmer code? > m1 <- lmer(Y ~ X+(1|grp_id), family=biomial(link="logit")) > As you may expect, I try to avoid expanding the tabular form data into > binary (0,1) outcome form data because doing so causes a quite large data > matrix in my study). > A link with similar question is seen at > https://stat.ethz.ch/pipermail/r-help/2008-May/161072.html > Seems to me, that link is implementing data expansion approach (they have > only 1600 obs after data expansion). > If someone knows a neat solution other than data expansion, please help. > > Many thanks in advance! > > -Sean > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >