s-news
[Top] [All Lists]

remove var from model object

To: s-news@lists.biostat.wustl.edu
Subject: remove var from model object
From: Russell.Ivory@MerrickBank.com
Date: Wed, 17 Sep 2003 12:20:29 -0600

I have a model

testmodel <- lrm(depvar ~ age+fscore+accts+lates+stage)

As part of my diagnostics I want to manipulate things one continuous measure at a time.  I want to write a function to run a new model that will in short look for linearity.  I have the steps of my function down but I'm having trouble manipulating the model arguments in the function call.

I'd like to have the aruments be very simple as

function(testmodel,indvar)

where testmodel is the existing model object and indvar is the variable in question that I will pull out and manipulate.  For example, if I were looking at age in the model above, the function call would look like

function(testmodel,age)

and the model would then become lrm(depvar ~ age +fscore+accts+lates+stage - age + agemanipulated)

In other words, I would pull age out of the existing model and plug in a manipulated version of age then re-run the model.

I've tried to simply pull age out as a first step with things like

modelvars <- depvar ~ age+fscore+accts+lates+stage
> modelvars
depvar ~ age+fscore+accts+lates+stage
as.formula(paste("lrm(",modelvars,"-age)"))

or

paste("lrm(", substring(testmodel$call, 1, max(nchar(testmodel$call)))[2], "-age)")
[1] "lrm( depvar ~ age+fscore+accts+lates+stage -age)"

but to no avail.

I'm sure the solution is simple, but I cannot find it.  Any pointers would be greatly appreciated.

Russell Ivory
Senior Risk Scoring Analyst
Merrick Bank
10705 South Jordan Gateway
Suite 200
South Jordan, Ut  84095
(801) 545-6640

                                                                                                          ****************************************************************************This e-mail and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom it is addressed.  If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, be advised that you have received this e-mail in error, and that any use, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited.  If you received this e-mail in error, please return the e-mail to the sender at Merrick Bank and delete it from your computer.  Although Merrick Bank attempts to sweep e-mail and attachments for viruses, it does not guarantee that either are virus-free and accepts no liability for any damage sustained as a result of viruses.

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