Ping-Hsun Hsieh
2009-Sep-04 19:59 UTC
[R] lrm in Design package--missing value where TRUE/FALSE needed
Hi, A error message arose while I was trying to fit a ordinal model with lrm() I am using R 2.8 with Design package. Here is a small set of mydata: RC RS Sex CovA CovB CovC CovD CovE 2 1 0 1 1 0 -0.005575280 2 2 1 0 1 0 1 -0.001959580 2 3 0 0 0 1 0 -0.004725880 2 0 0 0 1 0 0 -0.005504850 2 2 1 1 0 0 0 -0.003880170 1 2 1 0 0 1 0 -0.006074230 2 2 1 0 0 1 1 -0.003963920 2 2 1 0 0 1 0 0.000658230 2 2 1 0 1 0 1 -0.002033610 2 0 0 0 0 0 1 -0.007761770 2 0 0 0 0 1 1 -0.000951784 2 Note: In the complete data, there are NAs. But the error messages showed in both the complete and above sets.>attach(mydata) >lrm(RC~RS+Sex+CovA+CovB+CovC+CovD+CovE,data=mydata,na.action=na.pass)singular information matrix in lrm.fit (rank= 8 ). Offending variable(s): CovE Error in j:(j + params[i] - 1) : NA/NaN argument>detach(mydata) >lrm(mydata$RC~ mydata$RS+ mydata$Sex+ mydata$CovA+ mydata$CovB+ mydata$CovC+ mydata$CovD+ mydata$CovE,data=mydata,na.action=na.pass)Error in if (!length(fname) || !any(fname == zname)) { : missing value where TRUE/FALSE needed I have debugged for a while, but no success. Does anyone know what happens? Thanks, Mike
David Winsemius
2009-Sep-04 21:18 UTC
[R] lrm in Design package--missing value where TRUE/FALSE needed
The idea of estimating 7 parameters from 11 cases using mostly binary variables just seems begging for a singular matrix. On Sep 4, 2009, at 3:59 PM, Ping-Hsun Hsieh wrote:> Hi, > > A error message arose while I was trying to fit a ordinal model with > lrm() I am using R 2.8 with Design package. > > Here is a small set of mydata: > RC RS Sex CovA CovB CovC CovD CovE > 2 1 0 1 1 0 -0.005575280 2 > 2 1 0 1 0 1 -0.001959580 2 > 3 0 0 0 1 0 -0.004725880 2 > 0 0 0 1 0 0 -0.005504850 2 > 2 1 1 0 0 0 -0.003880170 1 > 2 1 0 0 1 0 -0.006074230 2 > 2 1 0 0 1 1 -0.003963920 2 > 2 1 0 0 1 0 0.000658230 2 > 2 1 0 1 0 1 -0.002033610 2 > 0 0 0 0 0 1 -0.007761770 2 > 0 0 0 0 1 1 -0.000951784 2 > > Note: In the complete data, there are NAs. But the error messages > showed in both the complete and above sets. > >> attach(mydata) >> lrm(RC~RS+Sex+CovA+CovB+CovC+CovD+CovE,data=mydata,na.action=na.pass) > singular information matrix in lrm.fit (rank= 8 ). Offending > variable(s): > CovE > Error in j:(j + params[i] - 1) : NA/NaN argument > >> detach(mydata) >> lrm(mydata$RC~ mydata$RS+ mydata$Sex+ mydata$CovA+ mydata$CovB+ >> mydata$CovC+ mydata$CovD+ mydata$CovE,data=mydata,na.action=na.pass) > Error in if (!length(fname) || !any(fname == zname)) { : > missing value where TRUE/FALSE needed > > > I have debugged for a while, but no success. Does anyone know what > happens?David Winsemius, MD Heritage Laboratories West Hartford, CT
Frank E Harrell Jr
2009-Sep-04 21:44 UTC
[R] lrm in Design package--missing value where TRUE/FALSE needed
Ping-Hsun Hsieh wrote:> Hi, > > A error message arose while I was trying to fit a ordinal model with lrm() I am using R 2.8 with Design package. > > Here is a small set of mydata: > RC RS Sex CovA CovB CovC CovD CovE > 2 1 0 1 1 0 -0.005575280 2 > 2 1 0 1 0 1 -0.001959580 2 > 3 0 0 0 1 0 -0.004725880 2 > 0 0 0 1 0 0 -0.005504850 2 > 2 1 1 0 0 0 -0.003880170 1 > 2 1 0 0 1 0 -0.006074230 2 > 2 1 0 0 1 1 -0.003963920 2 > 2 1 0 0 1 0 0.000658230 2 > 2 1 0 1 0 1 -0.002033610 2 > 0 0 0 0 0 1 -0.007761770 2 > 0 0 0 0 1 1 -0.000951784 2 > > Note: In the complete data, there are NAs. But the error messages showed in both the complete and above sets. > >> attach(mydata) >> lrm(RC~RS+Sex+CovA+CovB+CovC+CovD+CovE,data=mydata,na.action=na.pass) > singular information matrix in lrm.fit (rank= 8 ). Offending variable(s): > CovE > Error in j:(j + params[i] - 1) : NA/NaN argument > >> detach(mydata) >> lrm(mydata$RC~ mydata$RS+ mydata$Sex+ mydata$CovA+ mydata$CovB+ mydata$CovC+ mydata$CovD+ mydata$CovE,data=mydata,na.action=na.pass)Please read the documentation. Use data=. Don't use $ in variables in the model. I don't know what na.pass is. lrm does not allow NAs to be used in the attempted model fit. Frank> Error in if (!length(fname) || !any(fname == zname)) { : > missing value where TRUE/FALSE needed > > > I have debugged for a while, but no success. Does anyone know what happens? > > Thanks, > Mike > ______________________________________________ > 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. >-- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University