For practice, I'm trying to provide an estimation for a nonparametric model on dataset BMACS from library (npmlda). I'm having trouble to set up a kernel estimator with Uniform(-1/2,1/2) kernel and bandwidth h = 0.5.
The outcome I'm interested in is CD4 over time, which I believe the initial set up should be:
fit.linear.1 <- loess(CD4 ~ Time , span =0.5 , degree=1, data=BMACS) plot(CD4 ~ Time, data=BMACS, xlab = "Time since infection (years)", ylab = "CD4 percentage", ylim=c(0,65), cex=0.7, col='gray50', main="Local linear: span=0.5") lines(Time.int, predict(fit.linear.1 , data.frame(Time = Time.int)),col=1, lwd=2) mtext("A.", cex=1.3, side=3, line=0.7, font=2, at=-0.9)
I'm not very clear on what type of limit is represented by (-1/2, 1/2). If it is the limit for Time, then the smoothed curve will be too short to have any purpose for this analysis? If it is the range for the uniform kernel what function should I use for the setup that allows me to define a bandwidth?
Could anyone suggest a possible setup in R for the problem?