R-beta: port of bicreg package to R?
Malcolm Gillies
gillies at cmcind.far.ruu.nl
Thu Sep 24 18:35:02 CEST 1998
Thomas Lumley wrote:
> On Tue, 22 Sep 1998, Malcolm Gillies wrote:
>> R version: 0.62.1 (June 15, 1998)
>>
>> I just very naively attempted to grab the 'bicreg' package for
>> Bayesian model selection from the StatLib library, and get it running
>> under R.
>
> Here's a formula method for data.frame that you can put in the function to
> allow formula(cdf)
> [...]
Thanks, that indeed did the trick.
In the mean time, I discovered what appear to be some problems with the
"leaps" port on CRAN (version 1.0-3).
First off, leaps.R declares a function "make.names" which clashes with
an R base function, breaking data.frame in the process. I don't know
enough about R to know if these things should be sitting in separate
namespaces, but I hacked my way around this by just giving the function
a unique name.
Secondly, there appears to be a typo where "col.names" appears in place
of "colnames".
Anyway, I've included a patch below (for illustrative purposes only,
as I can't really claim to understand what I'm doing ;-)
I still don't have any joy, as now leaps is complaining. This probably
has more to do with the fact that I'm flying blind...
> bicreg(hiv[-14,-17], hiv[-14,17])
Error: leaps requires full-rank design matrix; use subsets()
> traceback()
[1] "stop(\"leaps requires full-rank design matrix; use subsets()\")"
[2] "leaps(x, y, wt = wt, method = \"r2\", names = dimnames(x)[[2]])"
[3] "bicreg(hiv[-14, -17], hiv[-14, 17])"
>
Malcolm
--
Malcolm Gillies <M.B.Gillies at pharm.uu.nl>
PhD student, computational medicinal chemistry
Dept Medicinal Chemistry, Faculty of Pharmacy,
Utrecht University, The Netherlands
----
*** leaps.R Thu Sep 24 17:42:06 1998
--- - Thu Sep 24 18:33:00 1998
***************
*** 5,11 ****
library.dynam("leaps.so")
! leaps.make.names<-function(np){
if (np<27) letters[1:np] else as.character(1:np)
}
leaps.setup<-function(x,y,wt=rep(1,length(y)),force.in=NULL,force.out=NULL,intercept=TRUE,nvmax=8,nbest=1,warn.dep=T){
--- 5,11 ----
library.dynam("leaps.so")
! make.names<-function(np){
if (np<27) letters[1:np] else as.character(1:np)
}
leaps.setup<-function(x,y,wt=rep(1,length(y)),force.in=NULL,force.out=NULL,intercept=TRUE,nvmax=8,nbest=1,warn.dep=T){
***************
*** 13,19 ****
nn<-NROW(x)
if (length(y)!=nn) stop("y and x different lengths")
if (length(wt)!=nn) stop("wt and x different lengths")
! if (is.null(colnames(x))) colnames(x)<-leaps.make.names(np)
index<-rep(0,np)
names(index)<-colnames(x)
index[force.in]<--1
--- 13,19 ----
nn<-NROW(x)
if (length(y)!=nn) stop("y and x different lengths")
if (length(wt)!=nn) stop("wt and x different lengths")
! if (is.null(colnames(x))) colnames(x)<-make.names(np)
index<-rep(0,np)
names(index)<-colnames(x)
index[force.in]<--1
***************
*** 326,332 ****
leaps<-function(x,y,wt=rep(1,NROW(x)),int=TRUE,method=c("Cp","adjr2","r2"),nbest=10,names=NULL,df=NROW(x),strictly.compatible=T){
if (!is.logical(int)) stop("int should be T or F")
! if (!is.null(names)) colnames(x)<-names
method<-method[1]
if (pmatch(method,c("Cp","adjr2","r2"),nomatch=0)==0) stop("Ambiguous or unrecognised method name")
if (strictly.compatible){
--- 326,332 ----
leaps<-function(x,y,wt=rep(1,NROW(x)),int=TRUE,method=c("Cp","adjr2","r2"),nbest=10,names=NULL,df=NROW(x),strictly.compatible=T){
if (!is.logical(int)) stop("int should be T or F")
! if (!is.null(names)) col.names(x)<-names
method<-method[1]
if (pmatch(method,c("Cp","adjr2","r2"),nomatch=0)==0) stop("Ambiguous or unrecognised method name")
if (strictly.compatible){
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list