# [R] I have aproblem --thank you

Mon Oct 4 15:57:36 CEST 2010

```dear teacher:
thank you for your help,witn your help i develop the nomogram successfully.
after that i want to do the internal validation to the nomogram.i wish to use the bootstrap to achieve the prediction accuracy of the nomogram,and then i encounter problem again,just like that.(error to :complete.cases(x, y, wt) : (the length of the augment was different))
i hope you tell me where is the mistake,and maybe i have chosen the wrong function.
thank you
turly yours
......

>> n<-100
>> set.seed(10)
>> Sex<-factor(0:1,labels=c("F","M"))
>> Smoking<-factor(0:1,labels=c("No","yes"))
>> +0.92*as.numeric(Sex)-1.338
> L
[1] -0.755 -0.172  0.363  0.946
>> y <- ifelse(runif(n) < plogis(L), 1, 0)
ddist <- datadist(dfr)  # wrap the vectors into a dataframe.
f<-lrm(y~T.Grade +Sex+Smoking, data=dfr) # skip the as.numeric()'s
### Gives an error message due to singular X matrix.
singular information matrix in lrm.fit (rank= 5 ).  Offending
variable(s):
Sex=M
Error in lrm(y ~ T.Grade + Sex + Smoking, data = dfr) :
Unable to fit model using “lrm.fit”

n<-100
set.seed(10)
Sex<-factor(sample(0:1, 100, replace=TRUE),labels=c("F","M"))
Smoking<-factor(sample(0:1, 100, replace=TRUE),labels=c("No","yes"))

+0.92*as.numeric(Sex)-1.338)
dfr\$y <- with(dfr, ifelse(runif(n) < plogis(L), 1, 0) )

nom <- nomogram(f, fun=function(x)1/(1+exp(-x)),  # or fun=plogis
fun.at=c(.001,.01,.05,seq(.1,.9,by=.1),.95,.99,.999),
funlabel="Risk of Death")
plot(nom, xfrac=.45)

load package bootstrap(achieve the prediction accuracy of the nomogram)

.................the problem....................
> theta.fit <- function(dfr,y){lsfit(dfr,y)}
> theta.predict <- function(fit,dfr){cbind(1,dfr)%*%fit\$coef}
> sq.err <- function(y,yhat) { (y-yhat)^2}
> results <- bootpred(x,y,50,theta.fit,theta.predict,err.meas=sq.err)
error to :complete.cases(x, y, wt) : (the length of the augment was different.
```