[R] a question regarding updating formulas with coefficients

David Winsemius dwinsemius at comcast.net
Thu Aug 12 00:23:08 CEST 2010


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?

> 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 Winsemius, MD
West Hartford, CT



More information about the R-help mailing list