s-news
[Top] [All Lists]

Re: extracting rows of $coefficients by variable name?

To: Steve Sullivan <ssullivan@qedgroupllc.com>
Subject: Re: extracting rows of $coefficients by variable name?
From: Chuck Cleland <ccleland@optonline.net>
Date: Fri, 23 May 2003 11:11:49 -0400
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <D4C203B93FEDF04CA2B493EB08F2E431030514@qeds001.hq.wash.qedgroupllc>
References: <D4C203B93FEDF04CA2B493EB08F2E431030514@qeds001.hq.wash.qedgroupllc>
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4b) Gecko/20030507
Steve Sullivan wrote:
Is there a handy way to extract information from a summarized lm or glm object’s $coefficients by variable name? I want to pull out only the coefficient estimate, SE, t-value and p-value for a particular variable (my treatment indicator).

Steve:
You could use use subscripting on the returned matrix with grep() to isolate the row by name. Here is an example:

my.lm <- lm(Y ~ ., data = mydata)

summary(my.lm)$coefficients[grep("COND", row.names(summary(my.lm)$coefficients)),]

where "COND" matches a particular coefficient name

hope this helps,

Chuck Cleland



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