Hi all R users I did a logistic regression with my binary variable Y (0/1) and 2 explanatory variables. Now I try to draw my nomogram with predictive value. I visited the help of R but I have problem to understand well the example. When I use glm fonction, I have a problem, thus I use lrm. My code is: modele<-lrm(Y~L+P,data=donnee) fun<- function(x) plogis(x-modele$coef[1]+modele$coef[2]) f <- Newlabels(modele,c(L="poids",P="taille")) nomogram(f, fun=list('Prob Y<=1'=plogis), fun.at=c(seq(0,1,by=.1),.95,.99), lmgp=.1, cex.axis=.6) fun.at=c(.01,.05,seq(.1,.9,by=.1),.95,.99), lmgp=.2, cex.axis=.6) options(Fire=NULL) Result is bad and I have this following error message: Erreur dans value.chk(at, i, NA, -nint, Limval, type.range = "full") : variable L does not have limits defined by datadist Could you help me on the code to draw nomogram. Nb: my English is low, I apologize. Thank for your help Komine -- View this message in context: http://r.789695.n4.nabble.com/Draw-a-nomogram-after-glm-tp3498144p3498144.html Sent from the R help mailing list archive at Nabble.com.
Please read the documentation for the rms package, particularly the datadist function. Note that in your subject line glm should be lrm. Frank Komine wrote:> > Hi all R users > I did a logistic regression with my binary variable Y (0/1) and 2 > explanatory variables. > Now I try to draw my nomogram with predictive value. I visited the help of > R but I have problem to understand well the example. When I use glm > fonction, I have a problem, thus I use lrm. My code is: > modele<-lrm(Y~L+P,data=donnee) > fun<- function(x) plogis(x-modele$coef[1]+modele$coef[2]) > f <- Newlabels(modele,c(L="poids",P="taille")) > nomogram(f, fun=list('Prob Y<=1'=plogis), > fun.at=c(seq(0,1,by=.1),.95,.99), > lmgp=.1, cex.axis=.6) > fun.at=c(.01,.05,seq(.1,.9,by=.1),.95,.99), > lmgp=.2, cex.axis=.6) > options(Fire=NULL) > Result is bad and I have this following error message: > Erreur dans value.chk(at, i, NA, -nint, Limval, type.range = "full") : > variable L does not have limits defined by datadist > > Could you help me on the code to draw nomogram. > Nb: my English is low, I apologize. > Thank for your help > Komine >----- Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Draw-a-nomogram-after-glm-tp3498144p3498279.html Sent from the R help mailing list archive at Nabble.com.
Thanks Frank I will try rms package and give after the result. Komine -- View this message in context: http://r.789695.n4.nabble.com/Draw-a-nomogram-after-glm-tp3498144p3499771.html Sent from the R help mailing list archive at Nabble.com.
Hi, I use datadist fonction in rms library in order to draw my nomogram. After reading, I try this code: f<-lrm(Y~L+P,data=donnee) f <- lrm(Y~L+P,data=donnee) d <- datadist(f,data=donnee) options(datadist="d") f <- lrm(Y~L+P) summary(f,L=c(0,506,10),P=c(45,646,10)) plot(Predict(f,L=200:800,P=3)) Unfortunately, I have error after the 2nd code: Erreur dans datadist(f, data = donnee) : program logic error Please could you provide me a document more simple which is more understandable for new R user. Thanks for your help. Komine -- View this message in context: http://r.789695.n4.nabble.com/Draw-a-nomogram-after-glm-tp3498144p3501534.html Sent from the R help mailing list archive at Nabble.com.
Hi all R users, Thanks Frank for your advices In fact I posted all my script. In the R Help, the script for nomogram is long and I took only the part what I think interesting in my case. I use informations from( datadist {Design} and rms {rms}) in the help of R software to do my code. I see that I progress with my nomogram. Because with the following code where I put my real variables names: library(Design) library(rms) d <- datadist(Fire) options(datadist='d') f<-lrm(Ignition~FMC+Charge,data=Fire) summary(f,FMC=c(0,506.40),Charge=c(45,646)) # min and max of FMC: 0 ,506.40 and the min and max of Charge: 45, 646 plot(Predict(f,FMC=0:506.40,Charge=646)) plot(nomogram(f, interact=list(Charge= c(.2,.7)))) # sorry, not understand vector c(.2,.7) from R help As result, I have the figure 1 then figure 2 but there is a problem. Because the 3rd line of Figure 2 "Charge" must to go 0 until 650. Also the linear predictor must to go 0 until 1. http://r.789695.n4.nabble.com/file/n3503828/nomo.jpeg http://r.789695.n4.nabble.com/file/n3503828/nomogram.jpeg After, is it possible to draw my nomogram like the 3rd graph that I found in Internet, it is easier to understand. http://r.789695.n4.nabble.com/file/n3503828/nogramme.bmp Nb: I Apologize for my bad english Thanks for your help Komine PhD student Dakar _S?n?gal West Africa Komine wrote:> > Hi all R users > I did a logistic regression with my binary variable Y (0/1) and 2 > explanatory variables. > Now I try to draw my nomogram with predictive value. I visited the help of > R but I have problem to understand well the example. When I use glm > fonction, I have a problem, thus I use lrm. My code is: > modele<-lrm(Y~L+P,data=donnee) > fun<- function(x) plogis(x-modele$coef[1]+modele$coef[2]) > f <- Newlabels(modele,c(L="poids",P="taille")) > nomogram(f, fun=list('Prob Y<=1'=plogis), > fun.at=c(seq(0,1,by=.1),.95,.99), > lmgp=.1, cex.axis=.6) > fun.at=c(.01,.05,seq(.1,.9,by=.1),.95,.99), > lmgp=.2, cex.axis=.6) > options(Fire=NULL) > Result is bad and I have this following error message: > Erreur dans value.chk(at, i, NA, -nint, Limval, type.range = "full") : > variable L does not have limits defined by datadist > > Could you help me on the code to draw nomogram. > Nb: my English is low, I apologize. > Thank for your help > Komine >Komine wrote:> > Hi all R users > I did a logistic regression with my binary variable Y (0/1) and 2 > explanatory variables. > Now I try to draw my nomogram with predictive value. I visited the help of > R but I have problem to understand well the example. When I use glm > fonction, I have a problem, thus I use lrm. My code is: > modele<-lrm(Y~L+P,data=donnee) > fun<- function(x) plogis(x-modele$coef[1]+modele$coef[2]) > f <- Newlabels(modele,c(L="poids",P="taille")) > nomogram(f, fun=list('Prob Y<=1'=plogis), > fun.at=c(seq(0,1,by=.1),.95,.99), > lmgp=.1, cex.axis=.6) > fun.at=c(.01,.05,seq(.1,.9,by=.1),.95,.99), > lmgp=.2, cex.axis=.6) > options(Fire=NULL) > Result is bad and I have this following error message: > Erreur dans value.chk(at, i, NA, -nint, Limval, type.range = "full") : > variable L does not have limits defined by datadist > > Could you help me on the code to draw nomogram. > Nb: my English is low, I apologize. > Thank for your help > Komine >Komine wrote:> > Hi all R users > I did a logistic regression with my binary variable Y (0/1) and 2 > explanatory variables. > Now I try to draw my nomogram with predictive value. I visited the help of > R but I have problem to understand well the example. When I use glm > fonction, I have a problem, thus I use lrm. My code is: > modele<-lrm(Y~L+P,data=donnee) > fun<- function(x) plogis(x-modele$coef[1]+modele$coef[2]) > f <- Newlabels(modele,c(L="poids",P="taille")) > nomogram(f, fun=list('Prob Y<=1'=plogis), > fun.at=c(seq(0,1,by=.1),.95,.99), > lmgp=.1, cex.axis=.6) > fun.at=c(.01,.05,seq(.1,.9,by=.1),.95,.99), > lmgp=.2, cex.axis=.6) > options(Fire=NULL) > Result is bad and I have this following error message: > Erreur dans value.chk(at, i, NA, -nint, Limval, type.range = "full") : > variable L does not have limits defined by datadist > > Could you help me on the code to draw nomogram. > Nb: my English is low, I apologize. > Thank for your help > Komine >Hi all R users I did a logistic regression with my binary variable Y (0/1) and 2 explanatory variables. Now I try to draw my nomogram with predictive value. I visited the help of R but I have problem to understand well the example. When I use glm fonction, I have a problem, thus I use lrm. My code is: modele<-lrm(Y~L+P,data=donnee) fun<- function(x) plogis(x-modele$coef[1]+modele$coef[2]) f <- Newlabels(modele,c(L="poids",P="taille")) nomogram(f, fun=list('Prob Y<=1'=plogis), fun.at=c(seq(0,1,by=.1),.95,.99), lmgp=.1, cex.axis=.6) fun.at=c(.01,.05,seq(.1,.9,by=.1),.95,.99), lmgp=.2, cex.axis=.6) options(Fire=NULL) Result is bad and I have this following error message: Erreur dans value.chk(at, i, NA, -nint, Limval, type.range = "full") : variable L does not have limits defined by datadist Could you help me on the code to draw nomogram. Nb: my English is low, I apologize. Thank for your help Komine -- View this message in context: http://r.789695.n4.nabble.com/Draw-a-nomogram-after-glm-tp3498144p3503828.html Sent from the R help mailing list archive at Nabble.com.
Don't attach the Design package. Use only rms. Please provide the output of lrm (print the f object). With such a strong model make sure you do not have a circularity somewhere. With nomogram you can specify ranges for the predictors; default is 10th smallest to 10th largest. rms will not make customized nomograms such as the one you included. Frank Hi all R users, Thanks Frank for your advices In fact I posted all my script. In the R Help, the script for nomogram is long and I took only the part what I think interesting in my case. I use informations from( datadist {Design} and rms {rms}) in the help of R software to do my code. I see that I progress with my nomogram. Because with the following code where I put my real variables names: library(Design) library(rms) d <- datadist(Fire) options(datadist='d') f<-lrm(Ignition~FMC+Charge,data=Fire) summary(f,FMC=c(0,506.40),Charge=c(45,646)) # min and max of FMC: 0 ,506.40 and the min and max of Charge: 45, 646 plot(Predict(f,FMC=0:506.40,Charge=646)) plot(nomogram(f, interact=list(Charge= c(.2,.7)))) # sorry, not understand vector c(.2,.7) from R help As result, I have the figure 1 then figure 2 but there is a problem. Because the 3rd line of Figure 2 "Charge" must to go 0 until 650. Also the linear predictor must to go 0 until 1. http://r.789695.n4.nabble.com/file/n3503828/nomo.jpeg http://r.789695.n4.nabble.com/file/n3503828/nomogram.jpeg After, is it possible to draw my nomogram like the 3rd graph that I found in Internet, it is easier to understand. http://r.789695.n4.nabble.com/file/n3503828/nogramme.bmp Nb: I Apologize for my bad english Thanks for your help Komine PhD student Dakar _S?n?gal West Africa Komine wrote:> > Hi all R users > I did a logistic regression with my binary variable Y (0/1) and 2 > explanatory variables. > Now I try to draw my nomogram with predictive value. I visited the help of > R but I have problem to understand well the example. When I use glm > fonction, I have a problem, thus I use lrm. My code is: > modele<-lrm(Y~L+P,data=donnee) > fun<- function(x) plogis(x-modele$coef[1]+modele$coef[2]) > f <- Newlabels(modele,c(L="poids",P="taille")) > nomogram(f, fun=list('Prob Y<=1'=plogis), > fun.at=c(seq(0,1,by=.1),.95,.99), > lmgp=.1, cex.axis=.6) > fun.at=c(.01,.05,seq(.1,.9,by=.1),.95,.99), > lmgp=.2, cex.axis=.6) > options(Fire=NULL) > Result is bad and I have this following error message: > Erreur dans value.chk(at, i, NA, -nint, Limval, type.range = "full") : > variable L does not have limits defined by datadist > > Could you help me on the code to draw nomogram. > Nb: my English is low, I apologize. > Thank for your help > Komine >Komine wrote:> > Hi all R users > I did a logistic regression with my binary variable Y (0/1) and 2 > explanatory variables. > Now I try to draw my nomogram with predictive value. I visited the help of > R but I have problem to understand well the example. When I use glm > fonction, I have a problem, thus I use lrm. My code is: > modele<-lrm(Y~L+P,data=donnee) > fun<- function(x) plogis(x-modele$coef[1]+modele$coef[2]) > f <- Newlabels(modele,c(L="poids",P="taille")) > nomogram(f, fun=list('Prob Y<=1'=plogis), > fun.at=c(seq(0,1,by=.1),.95,.99), > lmgp=.1, cex.axis=.6) > fun.at=c(.01,.05,seq(.1,.9,by=.1),.95,.99), > lmgp=.2, cex.axis=.6) > options(Fire=NULL) > Result is bad and I have this following error message: > Erreur dans value.chk(at, i, NA, -nint, Limval, type.range = "full") : > variable L does not have limits defined by datadist > > Could you help me on the code to draw nomogram. > Nb: my English is low, I apologize. > Thank for your help > Komine >Komine wrote:> > Hi all R users > I did a logistic regression with my binary variable Y (0/1) and 2 > explanatory variables. > Now I try to draw my nomogram with predictive value. I visited the help of > R but I have problem to understand well the example. When I use glm > fonction, I have a problem, thus I use lrm. My code is: > modele<-lrm(Y~L+P,data=donnee) > fun<- function(x) plogis(x-modele$coef[1]+modele$coef[2]) > f <- Newlabels(modele,c(L="poids",P="taille")) > nomogram(f, fun=list('Prob Y<=1'=plogis), > fun.at=c(seq(0,1,by=.1),.95,.99), > lmgp=.1, cex.axis=.6) > fun.at=c(.01,.05,seq(.1,.9,by=.1),.95,.99), > lmgp=.2, cex.axis=.6) > options(Fire=NULL) > Result is bad and I have this following error message: > Erreur dans value.chk(at, i, NA, -nint, Limval, type.range = "full") : > variable L does not have limits defined by datadist > > Could you help me on the code to draw nomogram. > Nb: my English is low, I apologize. > Thank for your help > Komine >Komine wrote:> > Hi all R users > I did a logistic regression with my binary variable Y (0/1) and 2 > explanatory variables. > Now I try to draw my nomogram with predictive value. I visited the help of > R but I have problem to understand well the example. When I use glm > fonction, I have a problem, thus I use lrm. My code is: > modele<-lrm(Y~L+P,data=donnee) > fun<- function(x) plogis(x-modele$coef[1]+modele$coef[2]) > f <- Newlabels(modele,c(L="poids",P="taille")) > nomogram(f, fun=list('Prob Y<=1'=plogis), > fun.at=c(seq(0,1,by=.1),.95,.99), > lmgp=.1, cex.axis=.6) > fun.at=c(.01,.05,seq(.1,.9,by=.1),.95,.99), > lmgp=.2, cex.axis=.6) > options(Fire=NULL) > Result is bad and I have this following error message: > Erreur dans value.chk(at, i, NA, -nint, Limval, type.range = "full") : > variable L does not have limits defined by datadist > > Could you help me on the code to draw nomogram. > Nb: my English is low, I apologize. > Thank for your help > Komine >----- Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Draw-a-nomogram-after-glm-tp3498144p3503857.html Sent from the R help mailing list archive at Nabble.com.
Hi Frank, For to answer your request:> print(f)Logistic Regression Model lrm(formula = Ignition ~ FMC + Charge, data = Fire) Model Likelihood Discrimination Rank Discrim. Ratio Test Indexes Indexes Obs 231 LR chi2 231.58 R2 0.852 C 0.976 0 96 d.f. 2 g 8.972 Dxy 0.953 1 135 Pr(> chi2) <0.0001 gr 7878.577 gamma 0.953 max |deriv| 1e-06 gp 0.466 tau-a 0.465 Brier 0.054 Coef S.E. Wald Z Pr(>|Z|) Intercept 9.6937 1.5863 6.11 <0.0001 FMC -0.0828 0.0138 -6.02 <0.0001 Charge -0.0047 0.0021 -2.28 0.0223 I continue to try my nomogram. Thanks again Komine -- View this message in context: http://r.789695.n4.nabble.com/Draw-a-nomogram-after-glm-tp3498144p3504208.html Sent from the R help mailing list archive at Nabble.com.
Hi, I try always to do my nomogram. I change little my code in order to definite the range of my linear predictor. But I do not succeed to have 0 until 1. I tried this code. library(rms) d <- datadist(Fire) options(datadist='d') Fire$Ignition=c(0,1,by=0.1) f<-lrm(Ignition~FMC+Charge,data=Fire) print(f) summary(f,FMC=c(0,506.40),Charge=c(45,646)) plot(nomogram(f, interact=list(FMC,Charge))) The result is:> print(f)Logistic Regression Model lrm(formula = Ignition ~ FMC + Charge, data = Fire) Model Likelihood Discrimination Rank Discrim. Ratio Test Indexes Indexes Obs 231 LR chi2 0.04 R2 0.000 C 0.501 0 77 d.f. 2 g 0.026 Dxy 0.002 0.1 77 Pr(> chi2) 0.9796 gr 1.026 gamma 0.003 1 77 gp 0.006 tau-a 0.002 max |deriv| 7e-13 Brier 0.222 Coef S.E. Wald Z Pr(>|Z|) y>=0.1 0.6832 0.3018 2.26 0.0236 y>=1 -0.7033 0.3020 -2.33 0.0199 FMC 0.0002 0.0011 0.18 0.8601 Charge -0.0001 0.0009 -0.07 0.9424> summary(f,FMC=c(0,506.40),Charge=c(45,646))Effects Response : Ignition Factor Low High Diff. Effect S.E. Lower 0.95 Upper 0.95 FMC 0 506.4 506.4 0.10 0.58 -1.04 1.24 Odds Ratio 0 506.4 506.4 1.11 NA 0.36 3.45 Charge 45 646.0 601.0 -0.04 0.55 -1.11 1.03 Odds Ratio 45 646.0 601.0 0.96 NA 0.33 2.81> plot(nomogram(f, interact=list(FMC,Charge)))http://r.789695.n4.nabble.com/file/n3511218/nomogram_2.jpeg Please can I do to have linear predictor between 0 to 1. Thanks very much for your Help Komine -- View this message in context: http://r.789695.n4.nabble.com/Draw-a-nomogram-after-glm-tp3498144p3511218.html Sent from the R help mailing list archive at Nabble.com.