[R] Trouble fitting models with nonNULL datadist in Design Library

From: Holder, Daniel J. <dan_holder_at_merck.com>
Date: Tue, 18 Mar 2008 13:00:36 -0400


Having trouble with datadist in the Design library. When I set the datadist option, all of the fitting functions give error messages similar to "Error in exists(x, envir, mode, inherits) : invalid first argument". Code below was run in R version 2.5.0 under windows, but get similar results with R version 6.2, except with additional problem that it will not fit model with "options(datadist=NULL)" since use of storage.mode(x) <- "single" seems to now be defunct instead of deprecated.

For example
> library(Design)
> set.seed(243)
> temp.df<-data.frame(x1=rnorm(100),x2=rnorm(100))
> temp.df$y<- temp.df$x1 - temp.df$x2 + rnorm(100)/2
>
> dd<-datadist(temp.df)
> options(datadist=dd)
>
> options()$datadist

                        x1          x2          y
Low:effect      -0.6299961 -0.82850974 -1.0273244
Adjust to       -0.1309631 -0.02919389  0.1342749
High:effect      0.7723673  0.70284942  1.2207567
Low:prediction  -1.4721508 -1.76692677 -2.3062141
High:prediction  1.8141205  1.60072989  2.8880009
Low             -2.6437032 -2.60640789 -4.2372689
High             2.8397685  1.95926958  4.8788867

>
> temp.ols<-ols(y~x1+x2, data=temp.df)

Error in exists(x, envir, mode, inherits) :

        invalid first argument
>
> options(datadist=NULL)
>
> temp.ols<-ols(y~x1+x2, data=temp.df)

Warning messages:
1: use of storage.mode(x) <- "single" is deprecated: use mode<- instead 2: use of storage.mode(x) <- "single" is deprecated: use mode<- instead
> temp.ols

Linear Regression Model

ols(formula = y ~ x1 + x2, data = temp.df)

         n Model L.R.       d.f.         R2      Sigma 
       100      256.6          2     0.9231     0.4495 

Residuals:
     Min       1Q   Median       3Q      Max 
-1.27308 -0.26226 -0.01148 0.26467 1.14479

Coefficients:

              Value Std. Error t Pr(>|t|)

Intercept -0.001592    0.04509  -0.0353    0.972
x1         1.068831    0.04428  24.1401    0.000
x2        -1.071857    0.04356 -24.6066    0.000

Residual standard error: 0.4495 on 97 degrees of freedom Adjusted R-Squared: 0.9216

> version

               _                           
platform       i386-pc-mingw32             
arch           i386                        
os             mingw32                     
system         i386, mingw32               
status                                     
major          2                           
minor          5.0                         
year           2007                        
month          04                          
day            23                          
svn rev        41293                       
language       R                           
version.string R version 2.5.0 (2007-04-23)

Would be grateful for any help. Thanks.  

Daniel Holder
Biometrics Research WP53B-120
Merck Research Labs
West Point, PA 19486



Notice: This e-mail message, together with any attachme...{{dropped:17}}

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 18 Mar 2008 - 17:16:29 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 18 Mar 2008 - 17:30:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive