How to set limits for the x and y axis using vis.gam() function from mgcv package in r?

StackOverflow https://stackoverflow.com/questions/14805915

  •  09-03-2022
  •  | 
  •  

I am using vis.gam() to plot the results from the following model:

gam.5 <- gam(mortality.under.2~s(maternal_age)+ s(birth_year) + 
          te(birth_year,maternal_age) + wealth + sex + 
         residence+ maternal_educ 
          ,data=colombia1,family="binomial") 

The code to make the plot is the following:

 vis.gam(gam.5,view=c("maternal_age","birth_year"),
         plot.type="contour",type="response",
         cond=list(wealth="Lowest quintile",sex="Female",
         residence="Rural",maternal_educ="Primary"))

Unfortunately, it produces predict values outside the range of the data for the variables 'maternal_age' and 'birth_year'. Any suggestion on how to constrain the range of the predicted values in the plot for the variables in view?

Thanks a bunch,

Antonio Pedro.

有帮助吗?

解决方案

Looking at the code it appears the graphics paradigm is base graphics (specifically the persp function) and that there is trailing dots argument, so why not add:

..., `xlim=range(columbia1(maternal_age), ylim=range(columbia1$birth_year)`
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top