Erik Lampa
2008-Nov-06 11:37 UTC
[R] Inference and confidence interval for a restricted cubic spline function in a hurdle model
Dear list, I'm currently analyzing some count data using a hurdle model. I've used the rcspline.eval function in the Hmisc-library to contruct the spline terms for the regression model, and what I want in the end is the ability to compute coefficients and confidence intervals for different changes in the smooth function as well as plotting the smooth function along with the confidence interval at the values of the x-variable. An example using the "zero"-part of the hurdle model: library(Hmisc) library(pscl) # Simulate some data set.seed(1) y<-c(rep(0,50),rnbinom(50,0.9,0.2)) x<-sin(y)+rnorm(100) # Set up the spline terms ssp<-rcspline.eval(x,inclx=T) # Fit the model and construct the smooth function f<-hurdle(y~ssp) knots<-attr(ssp,"knots") coef<-f$coefficients$zero w<-rcspline.restate(knots,coef) fun<-eval(attr(w,"function")) The coefficient for a change in x from -0.1 to 0.1 is fun(0.1)-fun(-0.1). My question is therefore how do I compute the confidence interval for this change? This is easy to do with the Design-library for the "zero"-part but as far as I know, zero-truncated negative binomial data can't be fitted using Design's functions as they are. Does someone know any neat tricks that would make this possible? Any help on this would be greatly appreciated. Thanks for your time. /Erik Lampa, Statistician, Uppsala University Hospital, Sweden [[alternative HTML version deleted]]