s-news
[Top] [All Lists]

Re: extracting sample size per group

To: "Fletcher, Thomas" <fletchert@umsl.edu>
Subject: Re: extracting sample size per group
From: Chuck Cleland <ccleland@optonline.net>
Date: Thu, 06 Oct 2005 14:09:40 -0400
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <ACB5FDA4EEF346479948FAA4F278E86D0149ADCC@stl-mail3.stl.umsl.edu>
References: <ACB5FDA4EEF346479948FAA4F278E86D0149ADCC@stl-mail3.stl.umsl.edu>
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
table(tmod$groups$g)

For example:

> data[sample(1:1000, size=20),] <- NA

> tmod <- lme(y~x,random=~1|g,data=data, na.action=na.omit)

> table(tmod$groups$g)
  1  2  3  4  5  6  7  8  9 10
 98 98 99 99 97 96 97 99 98 99

Fletcher, Thomas wrote:
S News List –

I am aware of how to extract the coefficients by group for a linear mixed effects model (e.g., coef (/lme.model/), but I can’t quite figure out how to get the sample size for each group. Any suggestions?

To give an example, suppose you have a dataset with 1000 individuals belonging to one of 10 groups. You create a lme model.

# create data

x <- rnorm(1000)

y <- .5*x+rnorm(1000)

g <- rep(1:10,100)

data <- cbind(x,y,g)

data <- data.frame(data)

#create a linear mixed effects model

tmod <- lme(y~x,random=~1|g,data=data)

# extracts coefficients for each group

coef(tmod)

# How do you get the sample size per group? In this example, the sample size is balanced by design, but what about real data where the group sizes are not balanced?

Thanks

Tom

-------------------------------------------------

Thomas D. Fletcher, PhD

Assistant Professor

Department of Psychology

University of Missouri - St. Louis

One University Boulevard

St. Louis, MO 63121

FletcherT@umsl.edu <mailto:FletcherT@umsl.edu>

-------------------------------------------------


--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894

<Prev in Thread] Current Thread [Next in Thread>