Re: [R] Continous variables with implausible transformation?
THX Yao Zhu Department of Urology Fudan University Shanghai Cancer Center Shanghai, China 2010/6/4 Frank E Harrell Jr > On 06/03/2010 11:32 AM, Joris Meys wrote: > >> You're right, it is the same. using I() won't work for the same reason >> sqrt >> don't, so : >> >> x2<- x^2 >>> lrm(y~x+x2) >>> >> >> Thx for the correction. >> Cheers >> Joris >> >> On Thu, Jun 3, 2010 at 6:14 PM, Bert Gunter >> wrote: >> >> Below. -- Bert >>> >>> Bert Gunter >>> Genentech Nonclinical Biostatistics >>> -- >>> But you wrote linear+ square. Don't you mean: >>> lrm(Y~x+x^2) >>> >>> --- I believe this is the same as lrm(Y ~ x). >>> You must protect the x^2 via >>> >>> lrm(Y ~ x + I(x^2)) >>> >> > But don't use that construct. Use lrm(Y ~ pol(x, 2)) > > Frank > > >>> -- >>> >>> -- >>> >> Joris Meys >> Statistical Consultant >> >> Ghent University >> Faculty of Bioscience Engineering >> Department of Applied mathematics, biometrics and process control >> >> Coupure Links 653 >> B-9000 Gent >> > > > -- > Frank E Harrell Jr Professor and ChairmanSchool of Medicine > Department of Biostatistics Vanderbilt University > > __ > R-help@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. > [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Continous variables with implausible transformation?
On 06/03/2010 11:32 AM, Joris Meys wrote: You're right, it is the same. using I() won't work for the same reason sqrt don't, so : x2<- x^2 lrm(y~x+x2) Thx for the correction. Cheers Joris On Thu, Jun 3, 2010 at 6:14 PM, Bert Gunter wrote: Below. -- Bert Bert Gunter Genentech Nonclinical Biostatistics -- But you wrote linear+ square. Don't you mean: lrm(Y~x+x^2) --- I believe this is the same as lrm(Y ~ x). You must protect the x^2 via lrm(Y ~ x + I(x^2)) But don't use that construct. Use lrm(Y ~ pol(x, 2)) Frank -- -- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000 Gent -- Frank E Harrell Jr Professor and ChairmanSchool of Medicine Department of Biostatistics Vanderbilt University __ R-help@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.
Re: [R] Continous variables with implausible transformation?
You're right, it is the same. using I() won't work for the same reason sqrt don't, so : > x2 <- x^2 > lrm(y~x+x2) Thx for the correction. Cheers Joris On Thu, Jun 3, 2010 at 6:14 PM, Bert Gunter wrote: > Below. -- Bert > > Bert Gunter > Genentech Nonclinical Biostatistics > -- > But you wrote linear+ square. Don't you mean: > lrm(Y~x+x^2) > > --- I believe this is the same as lrm(Y ~ x). > You must protect the x^2 via > > lrm(Y ~ x + I(x^2)) > > -- > > -- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000 Gent tel : +32 9 264 59 87 joris.m...@ugent.be --- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Continous variables with implausible transformation?
Below. -- Bert Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Joris Meys Sent: Thursday, June 03, 2010 5:20 AM To: zhu yao Cc: R-help Subject: Re: [R] Continous variables with implausible transformation? x <- rnorm(100,10,1) sqrtx <- sqrt(x) y <- rbinom(100,1,0.5) lrm(y~x+sqrtx) works. What's the problem? -- But you wrote linear+ square. Don't you mean: lrm(Y~x+x^2) --- I believe this is the same as lrm(Y ~ x). You must protect the x^2 via lrm(Y ~ x + I(x^2)) -- Cheers On Thu, Jun 3, 2010 at 6:34 AM, zhu yao wrote: > Dear r users > > I have a question in coding continuous variables in logistic regression. > > When "rcs" is used in transforming variables, sometime it gives implausible > associations with the outcome although the model x2 is high. > > So what's your tips and tricks in coding continuous variables. > > P.S. How to code variables as linear+square in the formula such as lrm. > lrm(y~x+sqrt(x)) can't work. > > Many thanks. > > Yao Zhu. > >[[alternative HTML version deleted]] > > __ > R-help@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. > -- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000 Gent tel : +32 9 264 59 87 joris.m...@ugent.be --- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] Continous variables with implausible transformation?
x <- rnorm(100,10,1) sqrtx <- sqrt(x) y <- rbinom(100,1,0.5) lrm(y~x+sqrtx) works. What's the problem? But you wrote linear+ square. Don't you mean: lrm(Y~x+x^2) Cheers On Thu, Jun 3, 2010 at 6:34 AM, zhu yao wrote: > Dear r users > > I have a question in coding continuous variables in logistic regression. > > When "rcs" is used in transforming variables, sometime it gives implausible > associations with the outcome although the model x2 is high. > > So what's your tips and tricks in coding continuous variables. > > P.S. How to code variables as linear+square in the formula such as lrm. > lrm(y~x+sqrt(x)) can't work. > > Many thanks. > > Yao Zhu. > >[[alternative HTML version deleted]] > > __ > R-help@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. > -- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000 Gent tel : +32 9 264 59 87 joris.m...@ugent.be --- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]] __ R-help@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.
[R] Continous variables with implausible transformation?
Dear r users I have a question in coding continuous variables in logistic regression. When "rcs" is used in transforming variables, sometime it gives implausible associations with the outcome although the model x2 is high. So what's your tips and tricks in coding continuous variables. P.S. How to code variables as linear+square in the formula such as lrm. lrm(y~x+sqrt(x)) can't work. Many thanks. Yao Zhu. [[alternative HTML version deleted]] __ R-help@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.