[R] releveling a numeric by factor interaction

Erik Iverson eriki at ccbr.umn.edu
Tue Aug 3 23:55:08 CEST 2010



Christy Denckla wrote:
> Can anyone help me with the necessary code to relevel a numeric*factor
> interaction term in a linear model?  I would like to report the estimate,
> std. error and t-value for the reference factor.
> 
> First, I estimated a linear model with dummy variables and was able to
> retrieve model estimates for the reference factor using relevel.
> 
> for example:
> 
>> summary(update(mod.mod, . ~ . - dummy +
> + relevel(dummy, ref="m")))
> 

Please provide *reproducible* examples, generating fake data if you have to.


> However, when I attempt to follow the same procedure to estimate the
> reference factor interacted with a numeric predictor, I receive an error
> message.
> 
>> summary(update(hdanxinteract.mod, . ~ . - numeric:dummy +
> + relevel(numeric:dummy, ref="m")))
> 
> Error in relevel.default(numeric:dummy, ref = "m") :
>   'relevel' only for factors
> In addition: Warning messages:
> 1: In numeric:dummy :
>   numerical expression has 152 elements: only the first used
> 2: In numeric:dummy :
>   numerical expression has 152 elements: only the first used
> 
> If relevel is only for factors, how can I perform an analogous procedure for
> factor by numeric interactions?

Why not simply relevel the factor using what you want as the reference 
level, and re-fit the model?



More information about the R-help mailing list