How to compare loess models from related datasets? I'm comparing matched data from a series of patients, looking at the effect of mental stress on cardiac conduction. I'm using the loess function to visually describe my data, and have 2 curves: one for with and one for without mental stress. I'd like to compare these curves. 
Is it possible to compare two loess models from different (thought related) datasets. Alternatively, could I code +/- mental stress with 1/0 and use that to get a statistical relationship between the two models?
Any pointers would be super-appreciated.
 A: Unfortunately loess fits are not comparable.  A loess (or lowess) curve is not like one based on a linear or quadratic or cubic equation.  I know of no statistial package that will provide an equation that defines a loess curve, nor a fit statistic such as R-squared for it.  Such a curve is completely opportunistic and therefore unique to each dataset.  A loess fit is atheoretical; one would not want to use it to try to formally replicate a pattern across datasets.  You might say it's "for exploratory purposes only," and even there one must use care, as you can see if you read through threads such as this one.
A: Is the variance between the data and the curve bigger than the variance between the two curves, averaged over patients? If you want a p-value I suppose you could assume normality of errors and use the F-test on ratio of variances. The loess fit isn't a formal fit, so this is not a formal test. Could you use a formal fit? Have a look at the graphs. Do they look the same across patients?
A: predict.loess in R has an se parameter which if TRUE returns standard errors for all predicted points.  These are the usual standard errors of residuals.  One can, as well, simply take the absolute value of difference between predicted values and originals and so get a sequence of absolute errors.  These are often more robust than standard errors. 
In any case, with these in hand you are set up for doing cross validation or jackknifing to get some notion of which of a set of parameters describe a dataset better. 
Note that in time series applications, these are dependent data so cross validating or jackknifing points is not appropriate: You need to pick random subsequences of the original parent in some principled way and cross validate over those. The lengths or windows of these should tie to some phenomenon horizon in the original dataset or problem. Failing that, could look at using the stationary bootstrap of Politis and Romano as implemented in the tsbootstrap function of the tseries package. That gives a bit more flexibility for dependent sequences, but the analyst still needs to specify a mean block length. 
A: In general when comparing two different fitting curves the way to go is a performance measure.
It does not allow you to draw strong conclusions, but if you have two options you can calculate the R squared for example and at least have an idea of how good your fit can be.
