[R] problem with step-Function

Andreas Pauling pauling at giub.unibe.ch
Mon Feb 25 14:23:26 CET 2002


Dear R-community
The following loops produce the error message:

Error in round(x, digits) : Non-numeric argument to mathematical
function

after performing the outer loop 6 times

Splus can execute these loops but is very much slower than R .
Interestingly, if the scale-argument in the step-function is omitted R
performes these loops a few times more.
What could be the reason for that error?
Any hint is appreciated!

Andreas


RQuadrat<-list()
elimParam<-list()
frei.grade<-list()
RQuadrat<-c(rep(list(rep(NA,286)),26))
elimParam<-c(rep(list(rep(NA,286)),26))
frei.grade<-c(rep(list(rep(NA,286)),26))

cat('\nVerarbeitete Gitterpunkte (von 286):\n')

for(i in 1:286)
  {
  j<-1
  if(any(is.na(annJMSLTv.box[,i])==F))
    {

fit<-lm(annJMSLTv.box~.,data=data.frame(annJMSLTv.box=annJMSLTv.box[,i],docuProxies),
na.action=na.omit)
    RQuadrat[[j]][i]<-round(summary(fit)$r.squared, dig=3)
    frei.grade[[j]][i]<-fit$df.residual

    for(j in 2:26)
      {
      backfit<-step(fit,scale=2,trace=F,steps=1)
      fit<-eval(backfit$call)
      RQuadrat[[j]][i]<-round(summary(fit)$r.squared,3)
      frei.grade[[j]][i]<-fit$df.residual

elimParam[[j]][i]<-paste(as.character(backfit$anova$Step),collapse="")
      }
      cat(i,' ')
    }
  }

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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