Potential bug in update.formula when updating offsets

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Potential bug in update.formula when updating offsets

Paul Buerkner
Hi all,

update.formula does not seem to correctly update (i.e. remove in my case)
offset terms.

Here is an example:

update(~x + offset(z), ~ . - offset(z))
> ~x + offset(z)

Also:
update(~x, ~ . - offset(z))
> ~x + offset(z)

In both cases, I would expect the result
> ~x

as  - <term>  should remove <term> from the formula as happens for instance
in:

update(~x + z, ~ . - z)
> ~x

I don't know if this behavior is intentional but I would say it is at least
unfortunate.

Paul

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Potential bug in update.formula when updating offsets

Peter Dalgaard-2
Terry, Martin

Would this happen to be related to the "indexing term objects" issue that has been bothering you?

-pd

> On 5 Aug 2019, at 21:44 , Paul Buerkner <[hidden email]> wrote:
>
> Hi all,
>
> update.formula does not seem to correctly update (i.e. remove in my case)
> offset terms.
>
> Here is an example:
>
> update(~x + offset(z), ~ . - offset(z))
>> ~x + offset(z)
>
> Also:
> update(~x, ~ . - offset(z))
>> ~x + offset(z)
>
> In both cases, I would expect the result
>> ~x
>
> as  - <term>  should remove <term> from the formula as happens for instance
> in:
>
> update(~x + z, ~ . - z)
>> ~x
>
> I don't know if this behavior is intentional but I would say it is at least
> unfortunate.
>
> Paul
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Re: Potential bug in update.formula when updating offsets

R devel mailing list
Yes, it is almost certainly the same issue.  At useR I promised Martin that I would put
together a clear example and fix for him and I have not yet done so.  I will try to do
that this week.

   The heart of the issue is that in a terms object the offset expression will apear in
the 'variables' attribute but not in the 'term.labels' or 'order' attributes, and the base
code tries to use the same subscripting vector for all 3 if then.   The same bit of code
shows up in update.formula and in [.formula; a fix for one can be applied to both.

I had all this worked out, then had some problems logging into buzilla, then sent it to
Martin about the same time 2-3 more urgent things got dumped on him, and then we've both
let it lie. At useR he said (and I've no reason to disagree) that my prior note was
unclear.  Let me recreate the example and fix, more carefully.

Terry T.


On 8/6/19 3:21 AM, peter dalgaard wrote:

> Terry, Martin
>
> Would this happen to be related to the "indexing term objects" issue that has been bothering you?
>
> -pd
>
>> On 5 Aug 2019, at 21:44 , Paul Buerkner <[hidden email]> wrote:
>>
>> Hi all,
>>
>> update.formula does not seem to correctly update (i.e. remove in my case)
>> offset terms.
>>
>> Here is an example:
>>
>> update(~x + offset(z), ~ . - offset(z))
>>> ~x + offset(z)
>> Also:
>> update(~x, ~ . - offset(z))
>>> ~x + offset(z)
>> In both cases, I would expect the result
>>> ~x
>> as  - <term>  should remove <term> from the formula as happens for instance
>> in:
>>
>> update(~x + z, ~ . - z)
>>> ~x
>> I don't know if this behavior is intentional but I would say it is at least
>> unfortunate.
>>
>> Paul
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel