[R] logistic regression 3D-plot
Dear R-helpers, I tried to create a 3D surface showing the interaction between two continuous explanatory variables; the response variable is binary (0/1). The model is: model-glm(incidence~sun*trees,binomial) then I used wireframe to create a 3D plot: xyz-expand.grid(sun=seq(30,180,1),trees=seq(0,4000,10)) xyz$incidence-as.vector(predict(model,xyz)) wireframe(incidence~sun*trees,xyz,scales=list(arrows=FALSE)) which gives me a 3D plot, but the scaling of the y-axis is wrong. the range is not from 0 to 1. so my question: is there a way to plot these kind of models, with binary response variables? thanks for your help, Heike -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] logistic regression 3D-plot
I tried to create a 3D surface showing the interaction between two continuous explanatory variables; the response variable is binary (0/1). The model is: model-glm(incidence~sun*trees,binomial) then I used wireframe to create a 3D plot: xyz-expand.grid(sun=seq(30,180,1),trees=seq(0,4000,10)) xyz$incidence-as.vector(predict(model,xyz)) xyz$incidence-as.vector(predict(model,xyz, type= response)) should work wireframe(incidence~sun*trees,xyz,scales=list(arrows=FALSE)) Cheers, Lorenz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] logistic regression 3D-plot
[EMAIL PROTECTED] wrote: Dear R-helpers, I tried to create a 3D surface showing the interaction between two continuous explanatory variables; the response variable is binary (0/1). The model is: model-glm(incidence~sun*trees,binomial) then I used wireframe to create a 3D plot: xyz-expand.grid(sun=seq(30,180,1),trees=seq(0,4000,10)) xyz$incidence-as.vector(predict(model,xyz)) wireframe(incidence~sun*trees,xyz,scales=list(arrows=FALSE)) which gives me a 3D plot, but the scaling of the y-axis is wrong. the range is not from 0 to 1. so my question: is there a way to plot these kind of models, with binary response variables? thanks for your help, Heike library(Design) d - datadist(mydata); options(datadist='d') f - lrm(incidence ~ sun*trees) # lrm is for binary or ordinal response plot(f, sun=NA, trees=NA) # add method='image' or 'contour' to get other types of graphs plot(f, sun=NA, trees=NA, fun='plogis') # probability scale -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] logistic regression 3D-plot CORRECTION
library(Design) d - datadist(mydata); options(datadist='d') f - lrm(incidence ~ sun*trees) # lrm is for binary or ordinal response plot(f, sun=NA, trees=NA) # add method='image' or 'contour' to get other types of graphs plot(f, sun=NA, trees=NA, fun='plogis') # probability scale Correction: fun=plogis not 'plogis'. Sorry about that -FH __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html