s-news
[Top] [All Lists]

thanks for responses

To: List 0-S-Plus <s-news@lists.biostat.wustl.edu>
Subject: thanks for responses
From: Emil Coman <emilcoman@yahoo.com>
Date: Mon, 22 May 2006 09:56:39 -0700 (PDT)
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=Z1XscfN6m4r41K3HJ9Hfki9fg7u1+DEGc61NFpf9v/36WnMbo96/Fy7/hiEXcBcdCJcegR02j8CoAZykA3voP7qjYNwqi+HAw5eBM1oa+ztyEuaQpCp70UDkMOVWaF0uaFEQoI74DpjTDlWgkHI2VO39W8BMn6OvG06Dd43GcuE= ;
I got some quick replies that put an end to some days of struggle on my part... thanks; here's attached the 4 first replies; I was looking at this excellent online help, but didn't know where to look...
http://www.uni-muenster.de/ZIV/Mitarbeiter/BennoSueselbeck/s-html/shelp.html

emil


How low will we go? Check out Yahoo! Messenger?s low PC-to-Phone call rates.

From: s-news-owner@lists.biostat.wustl.edu [mailto:s-news-owner@lists.biostat.wustl.edu]On Behalf Of Emil Coman

Sent: Monday, May 22, 2006 9:16 AM

To: s-news@lists.biostat.wustl.edu

Subject: [S] basic inquiry: "select if"

 

 this is my first question posted here, and I'm a beginner with S-Plus, so bear with me...

I am trying to run some analyses, any, say a

lm(Y~ X+ Z)

or

gee(formula = (formula = Y~ X+ Z), cluster = W, variance = "glm.scale")

but only for a sub-group of my dataset, say for males only; I know in SPSS there is a command "select if (gender=1)" e.g., but does anyone know the S-Plus similar command? thanks a lot,

From:   "Barker, Chris [SCIUS]" <cbarker1@scius.jnj.com> 

To:       "'Emil Coman'" <emilcoman@yahoo.com>

Subject:            RE: [S] basic inquiry: "select if"

Date:    Mon, 22 May 2006 12:25:24 -0400

 

Presumably you ?attached? the dataframe

Try ?gee for the syntax.

Otherwise, the syntax may be something like

lm(Y~ X+ Z, subset=Gender==1

or you can subset the dataframe

gender.dfr <- my.dataframe[gender==1 , ]; # notice  the comma - its very important

then

lm(y ~ x + z , data="" )

        Chris Barker

Associate Director, Biostatistics

            Scios Inc.

6500 Paseo Padre Parkway

     Fremont, CA 94555

Tel 510 248 2439

Fax 510 248 2451

Date:    Mon, 22 May 2006 12:23:53 -0400

From:   "Chuck Cleland" <ccleland@optonline.net> 

Subject:            Re: [S] basic inquiry: "select if"

To:       "Emil Coman" emilcoman@yahoo.com

 

Look at the subset argument to lm().  For example:

mydf <- data.frame(Y = Y, X = X, Z = Z, GENDER = GENDER)

lm(Y ~ X + Z, data = "" subset = (GENDER == "Male"))

There is most likely a subset argument to gee() as well.

hope this helps,

Chuck

 

From:   "Jim Pratt" <JimP@sonuspharma.com> 

To:       "Emil Coman" <emilcoman@yahoo.com>

Emil,

Many functions in S-Plus have a subset= option.  Go to ?lm to see example.

You will likely want to use data= "" as well.  It certainly helps make sure you are using the correct variables.

My.df <- data.frame(X,Y,Z,Gender)

lm(Y~X+Z, data="" subset=Gender==1)

 [Notice two equal signs == in the Gender==1.  This is important.  A single = is an assignment, while == is a condition statement.]

Best of luck.

Jim

Date:    Mon, 22 May 2006 09:36:16 -0700 (PDT)

From:   "Bill Dunlap" <bill@insightful.com> 

To:       "Emil Coman" <emilcoman@yahoo.com>

Subject:            Re: [S] basic inquiry: "select if"

 

Add the argument subset=gender==1 (or gender="M" opr gender="Male",

depending on how you encoded things).  You may put arbitrarily

complicated expressions in the subset argument.  E.g.,

            subset= gender=="Male" & PaternalAge-Age<20 & Stage %in% c("I","II")

to use only males who were born of teenage fathers and are in stage I

or II of some malady.

help(lm) and help(gee) tell about the subset= argument.

By the way

  gee(formula = (formula = Y~ X+ Z), cluster = W, variance = "glm.scale")

should probably be just

  gee(formula = Y~ X+ Z, cluster = W, variance = "glm.scale")

The former saves a dataset called "formula" (containing the formula

Y~X+Z) and then computes gee().

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

Bill Dunlap

Insightful Corporation

bill at insightful dot com

360-428-8146

"All statements in this message represent the opinions of the author and do

 not necessarily reflect Insightful Corporation policy or position."

<Prev in Thread] Current Thread [Next in Thread>
  • thanks for responses, Emil Coman <=