2016-06-29 8 views
1

GAM 평활화 기능 및 요인에 대한 y 제한을 조정하여 다른 계절에 대한 서로 다른 두 GAM 모델의 효과를보다 쉽게 ​​비교할 수 있습니다. plot.gam 함수에서 ylim 옵션을 사용할 때 나는 스무딩 기능에서는 y 축을 변경할 수만 있지만 요인에서는 변경할 수 없습니다. 예를 들어MGCV GAM 팩터 플롯에서 y 축을 변경하는 방법은 무엇입니까?

: 제 플롯

library(mgcv) 
data(cars) 
Gam1 <- gam(Price~s(Mileage)+factor(Cylinder), data=cars, family="gaussian") 

plot.gam(Gam1, shade=T, pages=1, all.terms=T, rug=FALSE) 
plot.gam(Gam1, shade=T, pages=1, ylim=c(-8000,8000), all.terms=T, rug=FALSE) 

, 매끄럽게 변화 아닌 계수 만의 y 제한. 여기서 무슨 일이 일어나고 어떻게 해결할 수 있습니까?

답변

1

코드가 plot.gam() 인 경우 실현하기가 어렵습니다. plot()termplot()을 사용하여 두 개의 플롯을 따로 더 잘 그려야합니다.

library(caret); library(mgcv) 
data(cars) 
Gam1 <- gam(Price ~ s(Mileage) + as.factor(Cylinder), data=cars, family="gaussian") 

par(mfrow=c(1,2)) 
plot(Gam1, shade=T, all.terms=F, rug=FALSE, ylim=c(-5000, 8000)) 
termplot(Gam1, se=T, ylim=c(-5000, 30000), ask=F, col.term = 1, col.se = 1) 
par(mfrow=c(1,1)) 

enter image description here

+0

예! 이것은 완벽하게 작동했습니다. 당신의 도움을 주셔서 감사합니다! – anorca