Dontrece Smith
2012-Sep-06 11:50 UTC
[R] Generalized additive models: Plots for Qualitative Data
Hello, My name is Dontrece Smith. I am creating figures for my GAMs. I change my qualitative variables to 1 or 2 in my dataset, so I would be able to run my GAMs. However, R will only display plots for my quantitative variables and not my qualitative variables. Is there any way to fix this issue? I listed some of my code below:> library(mgcv)This is mgcv 1.7-13. For overview type 'help("mgcv-package")'.> Final <- read.csv("Final.csv", header=TRUE) > gam4<-gam(Bonnet ~ s(Depth, bs="cs", k=4) + s(Distance, bs="cs", k=4) +s(Width, bs="cs", k=4) + as.factor (System) + as.factor(Channel) + as.factor (Profile) + s(Slope, bs="cs", k=4), data = Final)> plot(gam4, shade=TRUE, pages=1)Sincerely, Dontrece -- Dontrece Smith 4906 Taylor Road Savannah, GA 31404 (770) 401-3371 [[alternative HTML version deleted]]
David Winsemius
2012-Sep-06 17:36 UTC
[R] Generalized additive models: Plots for Qualitative Data
On Sep 6, 2012, at 4:50 AM, Dontrece Smith wrote:> Hello, > My name is Dontrece Smith. I am creating figures for my GAMs. I change my > qualitative variables to 1 or 2 in my dataset, so I would be able to run my > GAMs. However, R will only display plots for my quantitative variables and > not my qualitative variables. Is there any way to fix this issue? I listed > some of my code below: > >> library(mgcv) > This is mgcv 1.7-13. For overview type 'help("mgcv-package")'. >> Final <- read.csv("Final.csv", header=TRUE) >> gam4<-gam(Bonnet ~ s(Depth, bs="cs", k=4) + s(Distance, bs="cs", k=4) + > s(Width, bs="cs", k=4) + as.factor (System) + as.factor(Channel) + > as.factor (Profile) + s(Slope, bs="cs", k=4), data = Final) >> plot(gam4, shade=TRUE, pages=1)Why not use predict()? -- David Winsemius, MD Alameda, CA, USA
Jean V Adams
2012-Sep-06 20:41 UTC
[R] Generalized additive models: Plots for Qualitative Data
Dontrece, Try using the all.terms argument to the plot.gam() function. plot(gam4, shade=TRUE, pages=1, all.terms=TRUE) Does that work? Jean Dontrece Smith <smithdon2469@gmail.com> wrote on 09/06/2012 06:50:07 AM:> > Hello, > My name is Dontrece Smith. I am creating figures for my GAMs. I changemy> qualitative variables to 1 or 2 in my dataset, so I would be able to runmy> GAMs. However, R will only display plots for my quantitative variablesand> not my qualitative variables. Is there any way to fix this issue? Ilisted> some of my code below: > > > library(mgcv) > This is mgcv 1.7-13. For overview type 'help("mgcv-package")'. > > Final <- read.csv("Final.csv", header=TRUE) > > gam4<-gam(Bonnet ~ s(Depth, bs="cs", k=4) + s(Distance, bs="cs", k=4)+> s(Width, bs="cs", k=4) + as.factor (System) + as.factor(Channel) + > as.factor (Profile) + s(Slope, bs="cs", k=4), data = Final) > > plot(gam4, shade=TRUE, pages=1) > > Sincerely, > > Dontrece > > -- > Dontrece Smith > 4906 Taylor Road > Savannah, GA 31404 > (770) 401-3371[[alternative HTML version deleted]]