Local polynomial regression

#1
Hi,

I have "smoothed" rather than using a linear line between X and Y.

My R code is the following :
# Loess model
plot(Y ~ X)
loess.model <- loess(Dataset$Y ~ Dataset$X)
loess.model
hat <- predict(loess.model)
lines(Dataset$X[order(Dataset$X)], hat[order(Dataset$X)], col="red")

Number of Observations: 52
Equivalent Number of Parameters: 4.62
Residual Standard Error: 0.9877


1) This R code here above doesn't give me the R-square. Strange because I think that one way to get the R-square is to square the correlation between the original y-values and the predicted y-values at the same point - what I call hat in my R code.
How can I get the R-square of the loess fit ? Could You give me the R code ?


2) My R code uses the predict function on a loess object to get the curve. Now, if I want to make predictions with LOESS. How can I use the predict function on new x values ?


3) Using R, how can I get the confidence interval to know if the curvature is real/important or if a straight line would probably fit as well and any curvature is due to chance ?


Looking forward to reading You soon.

Figone
 
#2
Hi,
I guess I got responses to my 2 first questions.

## to get the R.square
loess.model=loess(Dataset$Y~Dataset$X)
SSE=sum((Dataset$Y-predict(loess.model) )^2)
SST=sum((Dataset$Y-mean(Dataset$Y))^2)
R.square=(SST-SSE)/SST
R.square


## to predict
predict(loess.model,Dataset$X)
predict(loess.model,11)
predict(loess.model,c(11,13,15))

But I still don't know how to get the confidence interval. My third question. So any help would be very Kind from You.
Thanks !