Re: [R] na.action and simultaneous regressions

From: Talbot Katz <>
Date: Wed 03 Jan 2007 - 22:23:04 GMT

Hi Bert.

Thank you so much, your solution with "apply" works perfectly. Sorry, I know this was an elementary question, and I saw the statement you referred to on the Help page. I just wasn't sure why, considering that there is a facility for na options, the option of treating the dependent variables separately with respect to missing values wasn't included. Thanks!

>From: Bert Gunter <>
>To: "'Talbot Katz'" <>, <>
>Subject: RE: [R] na.action and simultaneous regressions
>Date: Wed, 3 Jan 2007 13:46:03 -0800
>As the Help page says:
>If response is a matrix a linear model is fitted separately by
>to each column of the matrix
>So there's nothing hidden going on "behind the scenes," and
>apply(cbind(y1,y2),2,function(z)lm(z~x)) (or an explicit loop, of course)
>will produce a list each of whose components is a separate fit using all
>nonmissing data in the column.
>Bert Gunter
>Genentech Nonclinical Statistics
>South San Francisco, CA 94404
>-----Original Message-----
>[] On Behalf Of Talbot Katz
>Sent: Wednesday, January 03, 2007 11:56 AM
>Subject: [R] na.action and simultaneous regressions
>I am running regressions of several dependent variables using the same set
>of independent variables. The independent variable values are complete,
>each dependent variable has some missing values for some observations; by
>default, lm(y1~x) will carry out the regressions using only the
>without missing values of y1. If I do lm(cbind(y1,y2)~x), the default will
>be to use only the observations for which neither y1 nor y2 is missing.
>like to have the regression for each separate dependent variable use all
>non-missing cases for that variable. I would think that there should be a
>way to do that using the na.action option, but I haven't seen this in the
>documentation or figured out how to do it on my own. Can it be done this
>way, or do I have to code the regressions in a loop? (By the way, since it
>restricts to non-missing values in all the variables simultaneously, is
>because it's doing some sort of SUR or other simultaneous equation
>estimation behind the scenes?)
>-- TMK --
>212-460-5430 home
>917-656-5351 cell
> mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.
> mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu Jan 04 09:49:39 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 03 Jan 2007 - 23:30:25 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.