2016-07-12 4 views
0

나는 내 gam 결과를 플롯하려고합니다. 플로팅은 모든 매끄러운 용어 (제 1 ~ 8 항에서)에 대해 매우 잘 작동하지만 파라 메트릭 항을 (9 이후부터) 플롯하려는 경우 축 레이블을 변경할 수 없습니다. plot, plot.gam, termplot 또는 text를 사용하더라도 문제가되지 않습니다. 어떤 팁? 당신이 F2 버튼을 눌렀을 때 plot.gam의 소스 코드를 확인할 수 있습니다 RStudio 당신이 사용하는 경우 다음 코드 예제plot.gam과 파라 메트릭 용어의 라벨 축

par(mfrow=c(3,3), oma=c(1,1,1,1),pty="s",mar=c(4.5,4.5,1,1)) 
# the first three graphs work perfectly 
plot.gam(model$gam,select=1,scale=0,pers=TRUE,all.terms=T,shade=T,xlab="Water depth",ylab="") 
plot.gam(model$gam,select=2,scale=0,pers=TRUE,all.terms=T,shade=T,xlab="Bottom current speed",ylab="") 
plot.gam(model$gam,select=3,scale=0,pers=TRUE,all.terms=T,shade=T,xlab="Substance",ylab="") 
# this graph for the parametric term is plotted but I cannot change axis labels 
plot.gam(model$gam,select=9,scale=0,pers=T,all.terms=T,shade=T,xlab="AIS",ylab="") 
+0

일부 재현 가능한 데이터 (예 :'dput()')와 질문을 편집하여 사용한 추가 패키지를 제공 할 수 있습니까? – Jimbou

+0

안녕하세요, 아래 예가 있습니다. 물론이 예제의 모델은 의미가 없지만 문제는 여전히 지속됩니다. 파라 메트릭 용어 (용어 B)에 대한 축 레이블을 변경할 수 없습니다. require (mgcv) pa <- c (1, rep (0,9)) term_A <- runif (10,9,15) term_B <- runif (10,1,25) data <- as.data.frame (cbind (pa, term_A, term_B)) mod <-gam (mod, select = 1, 0, 1 = 0, 1 = 0, 0, 1) all.terms = T, 음영 = T, xlab = "용어 A", ylab = "") plot.gam (mod, select = 2, all.terms = T, 음영 = T, xlab = "용어 B" ylab = "") –

답변

1

입니다. R에서는 대괄호없이 plot.gam을 실행하십시오. 그러면 select 값의 경우 plot()termplot()으로 대체됨을 알 수 있습니다. 따라서 x 축 레이블을 조정하려면 xlab 대신 xlabs을 사용해야합니다.

require(mgcv) 
pa <- c(1, rep(0, 9)) 
term_A <- runif(10, 9, 15) 
term_B <- runif(10, 1, 25) 
data <- as.data.frame(cbind(pa, term_A, term_B)) 
mod <- gam(pa ~ s(term_A, k=3) + term_B, family=binomial, data=data) 
summary(mod) 
par(mfrow=c(2, 2)) 
# xlab="" 
plot.gam(mod, select=1, all.terms=T, shade=T, xlab="your own lab title", ylab="") 
# xlabs="" 
plot.gam(mod, select=2, all.terms=T, shade=T, xlabs="your own lab title", ylab="") 
+0

Genius, 작동합니다! 대단히 고마워요. 코드 확인에 대해 생각 해보지 않았습니다. –

+0

@MagdaChu 당신을 진심으로 환영합니다. 왼쪽에있는 체크 버튼을 클릭하여 답을 수락하십시오. 감사. – Jimbou

관련 문제