Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion define subset argument for function lm as variable?

Received: by 10.180.24.165 with SMTP id v5mr2503398wif.1.1345561214640;
        Tue, 21 Aug 2012 08:00:14 -0700 (PDT)
X-BeenThere: r-help-archive@googlegroups.com
Received: by 10.216.201.22 with SMTP id a22ls482872weo.5.gmail; Tue, 21 Aug
 2012 08:00:14 -0700 (PDT)
Received: by 10.180.105.2 with SMTP id gi2mr2503454wib.4.1345561214479;
        Tue, 21 Aug 2012 08:00:14 -0700 (PDT)
Received: by 10.180.105.2 with SMTP id gi2mr2503453wib.4.1345561214471;
        Tue, 21 Aug 2012 08:00:14 -0700 (PDT)
Return-Path: <r-help-boun...@r-project.org>
Received: from hypatia.math.ethz.ch (hypatia.math.ethz.ch. [129.132.145.15])
        by gmr-mx.google.com with ESMTPS id i17si3950188wiw.0.2012.08.21.08.00.14
        (version=TLSv1/SSLv3 cipher=OTHER);
        Tue, 21 Aug 2012 08:00:14 -0700 (PDT)
Received-SPF: neutral (google.com: 129.132.145.15 is neither permitted nor denied by best guess record for domain of r-help-boun...@r-project.org) client-ip=129.132.145.15;
Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 129.132.145.15 is neither permitted nor denied by best guess record for domain of r-help-boun...@r-project.org) smtp.mail=r-help-boun...@r-project.org
Received: from hypatia.math.ethz.ch (hypatia [129.132.145.15])
	by hypatia.math.ethz.ch (8.14.1/8.14.1) with ESMTP id q7LEwCdE020709;
	Tue, 21 Aug 2012 17:00:12 +0200
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on hypatia.math.ethz.ch
X-Spam-Level: 
X-Spam-Status: No, score=-4.2 required=5.0 tests=AWL, BAYES_00,
	RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1
Received: from phil2.ethz.ch (phil2.ethz.ch [129.132.202.240])
	by hypatia.math.ethz.ch (8.14.1/8.14.1) with ESMTP id q7LEw8X9020685
	for <r-h...@r-project.org>; Tue, 21 Aug 2012 16:58:08 +0200
Received: from smtaintvv03-out.gene.com ([72.34.133.203]
	helo=smtaintvv03.gene.com) by phil2.ethz.ch with esmtp (Exim 4.69)
	(envelope-from <bgun...@gene.com>) id 1T3pu7-00058G-9b
	for r-h...@r-project.org; Tue, 21 Aug 2012 16:58:08 +0200
Received: from smtaextvv02-gmail.gene.com (smtaextvv02-gmail.gene.com
	[72.34.132.18])
	by smtaintvv03.gene.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.1.1) with
	ESMTP id q7LEw1dg000891
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL)
	for <r-h...@r-project.org>; Tue, 21 Aug 2012 07:58:01 -0700
Received: from mail-qa0-f48.google.com (mail-qa0-f48.google.com
	[209.85.216.48])
	by smtaextvv02-gmail.gene.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.1.1)
	with ESMTP id q7LEw0qs023591
	(version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK)
	for <r-h...@r-project.org>; Tue, 21 Aug 2012 07:58:00 -0700
Received: by qady1 with SMTP id y1so38959qad.7
	for <r-h...@r-project.org>; Tue, 21 Aug 2012 07:57:59 -0700 (PDT)
	d=google.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type:x-gm-message-state;
	bh=6leshoIY2TlStBnJxyadNRpdEh4TKi6ElaOZywAGSjw=;
	b=HxMsk8S4DEvncKBjKrght5dC6bvvLSgR9fH+O8Cl4k4tTbu1M6oFabpVQz4XhHnbcT
	FHFlWg1uqx5IUmYbxIwH4Lu2p3o85u7CUfNZzJze8eFJQzANk6gZuyhXig5rUgA9NP9D
	OfvqR1xKj46wiv/QGoPGzztomfyAt/yg4cm84xPgdmGnY0ruAZtl7C4E2oDf7ucQTBM0
	WNXfZoWED6LU2+XAxdMZAA64lq2v33nmkou8VhR3bKCpSch3ISi0nVkDD92jMZ0D3RLI
	4x4+k/7hpG+VwyrJtSo19a7pbYvdcj26aRHZDIQRn7QaTE+mmMsP9yJ9N9BPOXI2twSz
	1MIw==
MIME-Version: 1.0
Received: by 10.224.179.9 with SMTP id bo9mr4564489qab.86.1345561079799; Tue,
	21 Aug 2012 07:57:59 -0700 (PDT)
Received: by 10.49.5.202 with HTTP; Tue, 21 Aug 2012 07:57:59 -0700 (PDT)
In-Reply-To: <50339EDC.5060...@gmail.com>
References: <50339EDC.5060...@gmail.com>
Date: Tue, 21 Aug 2012 07:57:59 -0700
Message-ID: <CACk-te34QKbhdcQcYRLWeuNkVDfw6jiBRzg904JEQAr_nvs...@mail.gmail.com>
From: Bert Gunter <gunter.ber...@gene.com>
To: Rai...@krugs.de
X-Gm-Message-State: ALoCoQk/3owMW1WjxICZQzKM2a2VpgLuqSwiHmf7asUSBUDTLPXcq1rSnwqteRixIuXv1C/JB5XF
X-Tag-Only: YES
X-Filter-Node: phil2.ethz.ch
X-USF-Spam-Level: 
X-USF-Spam-Status: hits=0.8 tests=MISSING_FROM,RP_MATCHES_RCVD,SPF_PASS
X-USF-Spam-Flag: NO
X-Virus-Scanned: by amavisd-new at stat.math.ethz.ch
Cc: R-help <r-h...@r-project.org>
Subject: Re: [R] define subset argument for function lm as variable?
X-BeenThere: r-h...@r-project.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "Main R Mailing List: Primary help" <r-help.r-project.org>
List-Unsubscribe: <https://stat.ethz.ch/mailman/options/r-help>,
	<mailto:r-help-requ...@r-project.org?subject=unsubscribe>
List-Archive: <https://stat.ethz.ch/pipermail/r-help>
List-Post: <mailto:r-h...@r-project.org>
List-Help: <mailto:r-help-requ...@r-project.org?subject=help>
List-Subscribe: <https://stat.ethz.ch/mailman/listinfo/r-help>,
	<mailto:r-help-requ...@r-project.org?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: r-help-boun...@r-project.org
Sender: r-help-boun...@r-project.org

?? I do not groc what you mean. ... subset == subs would work fine in
your lm call. So unless someone else does get it, you may need to
elaborate.

In general, ?substitute, ?bquote, and ?quote are useful to avoid
immediate evaluation of calls, but I don't know if that's relevant to
what you want here.

-- Bert

On Tue, Aug 21, 2012 at 7:44 AM, Rainer M Krug <r.m.k...@gmail.com> wrote:
> Hi
>
> I want to do a series of linear models, and would like to define the input
> arguments for lm() as variables. I managed easily to define the formula
> arguments in a variable, but I also would like to have the "subset" in a
> variable. My reasoning is, that I have the subset in the results object.
>
> So I wiould like to add a line like:
>
> subs <- dead==FALSE & recTreat==FALSE
>
> which obviously does not work as the expression is evaluated immediately. Is
> is it possible to do what I want to do here, or do I have to go back to use
>
> dat <- subset(dat, dead==FALSE & recTreat==FALSE)
>
> ?
>
>
>
> dat <- loadSPECIES(SPECIES)
> feff <- height~pHarv*year               # fixed effect in the model
> reff <- ~year|plant                     # random effect in the model, where
> year is the
> dat.lme <- lme(
>              fixed = feff,                           # fixed effect in the
> model
>              data  = dat,
>              random = reff,                          # random effect in the
> model
>              correlation = corAR1(form=~year|plant), #
>              subset = dead==FALSE & recTreat==FALSE, #
>              na.action = na.omit
>              )
> dat.lm <- lm(
>             formula =  feff,              # fixed effect in the model
>             data = dat,
>             subset = dead==FALSE & recTreat==FALSE,
>             na.action = na.omit
>             )
>
> Thanks,
>
> Rainer
>
> --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
> UCT), Dipl. Phys. (Germany)
>
> Centre of Excellence for Invasion Biology
> Stellenbosch University
> South Africa
>
> Tel :       +33 - (0)9 53 10 27 44
> Cell:       +33 - (0)6 85 62 59 98
> Fax :       +33 - (0)9 58 10 27 44
>
> Fax (D):    +49 - (0)3 21 21 25 22 44
>
> email:      Rai...@krugs.de
>
> Skype:      RMkrug
>
> ______________________________________________
> R-h...@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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

______________________________________________
R-h...@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.