# 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.

-
Comparing curve just to get a nice p-value for publication is a can of worms with so many wormholes that you better repost this on stackexchange - this has nothing to do with R. And if you do, tell them what your horizontal curve axis means. Because of serial correlation, it is absolutely important to know if this is within subject or between subjects. –  Dieter Menne Jun 27 '12 at 11:54
Thanks Dieter. The horizontal curve is within subject. Thanks for your pointers! –  Malcolm Jun 27 '12 at 12:24
Could you give us a bit more detail about what's on the y axis (I'm assuming that the x axis is time)? And for each patient do you have a series of measurements with and without mental stress, or do some have it and some not? –  Andrew Jul 10 '12 at 16:44
Is your question related to this Is it possible to fit a data curve to another data curve? (Deleting the answer added, that should have been a comment.) –  Noble P. Abraham Sep 7 '12 at 15:32

## migrated from stackoverflow.comJun 27 '12 at 12:50

This question came from our site for professional and enthusiast programmers.

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?

-