[R] a question regarding updating formulas with coefficients

Charles C. Berry cberry at tajo.ucsd.edu
Thu Aug 12 01:43:24 CEST 2010


On Wed, 11 Aug 2010, David Winsemius wrote:

>
> On Aug 11, 2010, at 6:45 PM, Charles C. Berry wrote:
>
>> On Wed, 11 Aug 2010, David Winsemius wrote:
>> 
>> > 
>> > On Aug 11, 2010, at 6:03 PM, Jarrett Byrnes wrote:
>> > 
>> > > I have formulae with coefficents that I would like to update.  However, 
>> > > I get some strange results.  For example, see the following:
>> > > For the formula y ~ d+ 3*r+t
>> > 
>> > Did you really get meaningful results from that formula? Care to provide 
>> > an example? Maybe there is something more for me to learn.
>> > 
>> > 
>> > > I want to add a variable p, so
>> > > >  update(y~d+0*r+t, .~.+p)
>> > 
>> > In formulas the "*" operator is an interaction creator. so you told R to 
>> > make 0 + r + 0:r. Probably not what you thought you were doing. So what 
>> > were you trying to do anyway?
>> > 
>> > > produces
>> > > y ~ d + t + p - 1
>> > 
>> > Which at least explains why you got the -1 (which in R formulas is that 
>> > same as +0).
>> > > If the coefficient is not 0, but rather, something else - say, 3,
>> > 
>> > What do you think you are accomplishing when you put a scalar coefficient 
>> > in the formula?
>> > 
>> 
>> Maybe he wants
>>
>>  ?I
>
> Possibly, but wouldn't that just result in a "deflation" by a factor of 3 of 
> the estimated coefficient if you wrappedI around that rem ...  I(3*r) ?

Quite so. It is just one way (and I am not touting it) of rescaling a 
variable.

  I 
> also wondered if he might need to be referred to:
>
> ?offset
>
>
>> 
>> ??
>
> ?? back 'atcha.

My '??' was intended for the OP, but your guess seems good to me.

Chuck

>
> -- 
> David.
>> 
>> Chuck
>> 
>> > > I get the following:
>> > > >  update(y~d+3*r+t, .~.+p)
>> > > Error in terms.formula(tmp, simplify = TRUE) :
>> > > invalid model formula in ExtractVars
>> > > >  Is there a way to do this,
>> > 
>> > > or a different call I should be trying?
>> > 
>> > What you should be doing depends on what you want to happen.
>> > 
>> > -- 
>> > 
>> > David
>> 
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> R-help at 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.
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901



More information about the R-help mailing list