[R] Problem with logtrans, from library MASS

Murray Jorgensen maj at stats.waikato.ac.nz
Fri May 14 12:36:29 CEST 2004


Thanks for the help.

The variables do all come from a frame but with various transformations 
and manipulations. I prefer not to stick them all into a new frame just 
to call one function.

Thanks again,

Murray Jorgensen

Prof Brian Ripley wrote:
> On 14 May 2004, Peter Dalgaard wrote:
> 
> 
>>Murray Jorgensen <maj at stats.waikato.ac.nz> writes:
>>
>>
>>>Greetings all!
>>>
>>>This problem occurs using R 1.8.1 on Windows XP. I downloaded the
>>>binaries for R and all packages, including the VR bundle, in December
>>>2003.
>>>
>>>The data consists of NZ$ prices and attributes for 643 cars.
>>>
>>> > summary(price)
>>>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's
>>>   14290   35800   48990   65400   79000  285000       2
>>> > library(MASS)
>>> > boxcox(price ~ doors+CC+KW+KG+LENGTH, lambda=seq(-0.1,0.5,length=30))
>>> > boxcox(price ~ doors+CC+KW+KG+LENGTH, lambda=seq(-0.5,0.1,length=30))
>>>
>>>This all works fine, I get a fairly sharp peak near lambda=-0.25, but then:
>>>
>>> > logtrans(price ~ doors+CC+KW+KG+LENGTH, alpha=seq(-10000,0,length=30))
>>>Error in eval(expr, envir, enclos) : Object "price" not found
>>>
>>
>>The issue is that logtrans has a 'data' argument that defaults to NULL
>>(the author(s) may have a reason for having this inconsistent with
>>boxplot?). Adding data=.GlobalEnv seems to work.
> 
> 
> It's an R/S difference.  data=NULL or list() in S does give you the normal
> search path.  I guess this got noticed for boxplot and not logtrans.
> 
> Using a data argument would in any case be a very good idea.
> 

-- 
Dr Murray Jorgensen      http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: maj at waikato.ac.nz                                Fax 7 838 4155
Phone  +64 7 838 4773 wk    +64 7 849 6486 home    Mobile 021 1395 862




More information about the R-help mailing list