[R] Using termplot() with transformations of x

Niels Richard Hansen Niels.R.Hansen at math.ku.dk
Fri Aug 27 08:46:57 CEST 2010



On 27/08/10 01.10, Peter Dunn wrote:
> Hi all
>
> I was playing with termplot(), and came across what appears to be an
> inconsistency.
>
> It would appreciate if someone could enlighten me:
>
>> # First, generate some data: y<- rnorm(100) x<- runif(length(y),1,2)
>
>> # Now find the log of x: logx<- log(x)
>>
>> # Now fit two models that are exactly the same, but specified differently:
>> m1<- lm(y~log(x)) # Using log in the call m2<- lm(y~logx) # Using the
>> variable logx
>>
>> # The two termplots() are different: par(mfrow=c(1,2)) termplot(m1)
>> termplot(m2)
>
>
> I see two models that are identical, but produce different termplot()s.  In
> both cases, the independent variable is log(x), but is just specified
> differently.
>
> If this is intended, what is the logic?  Or am I missing something?

I believe it is intended, and quite as expected. The plot is against
the term variable on its original scale - not the transformed scale.

- Niels

>
> Thanks.
>
> P.
>
>> sessionInfo()
> R version 2.11.1 (2010-05-31) x86_64-apple-darwin9.8.0
>
> locale: [1] en_AU.UTF-8/en_AU.UTF-8/C/C/en_AU.UTF-8/en_AU.UTF-8
>
> attached base packages: [1] stats     graphics  grDevices utils     datasets
> methods   base
>
>
> Peter Dunn: Biostatistician (Room T4.12) School of Health and Sport Science
> Faculty of Science, Health and Education  ML-34 University of the Sunshine
> Coast, Locked Bag 4 Maroochydore DC Qld 4558
>
> Tel: +61 7 5456 5085 Fax: +61 7 5430 2896 Email: pdunn2 at usc.edu.au
> www.usc.edu.au
>
> CRICOS Provider Number: 01595D This communication is intended for the
> recipient only and should not be forwarded, distributed or otherwise read by
> others without express permission. The views expressed in this email are not
> necessarily those of the University of the Sunshine Coast.
>

-- 
Niels Richard Hansen                     Web:   www.math.ku.dk/~richard	
Associate Professor                      Email: Niels.R.Hansen at math.ku.dk
Department of Mathematical Sciences             nielsrichardhansen at gmail.com
University of Copenhagen                 Skype: nielsrichardhansen.dk	
Universitetsparken 5                     Phone: +45 353 20783 (office)	
2100 Copenhagen Ø                               +45 2859 0765 (mobile)
Denmark



More information about the R-help mailing list