[R] model formula

Bill Simpson William.Simpson at drdc-rddc.gc.ca
Tue Nov 18 14:40:36 CET 2003


I have continuous variables x, y, z. The plot of the data looks like this:

y
|                           z=1(o), 2(@), 3(#), 4(*)
|
|*   *  *
|
|
|#   #   #  #
|
|
|@    @    @  @
|
|                     o
|               o
|          o
|     o  
|o
------------------------ x
The correct model appears to be: if z==1, y~x+z; else y~z
(y~z + z:x isn't it)

How can I express this model in lm()? If I can't express it properly in
lm(), what is the best way to fit the model?

Thanks for any help.

Bill Simpson




More information about the R-help mailing list