Statistical comparison of two signals I need to develop an algorithm that will compare two signals and generate some metric(s) to describe changes between them. Signal processing and analysis isn’t my strong point so I would appreciate any help!
Here is an example of what the signals look like:

The signal starts at a constant amplitude, then transitions into a lower amplitude before transitioning back up to the same constant amplitude as the start. The part in the middle is the region of interest, which is what needs to be analysed. Some of the differences that I am expecting (all within the region of interest) are:


*

*Mean amplitude of the area of interest, relative to the start and end amplitudes

*Slope of fall/rise transitions and of individual peaks and troughs

*Number of peaks and troughs


The algorithm needs to output some generic metrics which can be used to quantify changes in any or all of these parameters. Any guidance on what method(s) I could use to do this  would be a great help. I know a little about cross-correlation and have heard about wavelet transform analysis, but I am wondering if these are appropriate, or if there are other methods that would work better.
 A: Time series analysis incorporating both ARIMA structure and empirically identifiable deterministic structure (level shifts/local time trends.seasonal pulses and pulses) might be of some use to you http://www.unc.edu/~jbhill/tsay.pdf. Good analytics/software should/could identify 2 level shifts ( 3 regimes) which would be important starting point for your analysis providing "the region of interest". If you wish you can post your data and I will try and demonstrate that to you and the list.
A: There is no one single algorithm that will yield what you want. 
If your desire is to compare two signals then from the signal procesing point of view you can do the following. 
If the signal is stationary use multitaper magnitude-squared coherence from multitaper package using Harmonic F Statistic against a null hypothesis of white noise for the result.This will tell you in what frequencies the two signals overlap.
If the signal is non stationary use phase differential analysis and wavelet cross correlation. This will tell you across time how strong the similarities between the two series are.  
In regards to you desired output 
1.Mean amplitude of the area of interest, relative to the start and end amplitudes
I believe you refer here at what are the dominant frequencies of each series. You can calculate these by extracting the amplitudes of the signal across frequencies from multitaper. 
2.Slope of fall/rise transitions and of individual peaks and troughs
Use gradients as to measure this. The gradient represents the slope of the tangent of the graph of the function representing a trend or down. the gradient points in the direction of the greatest rate of increase of the function and its magnitude is the slope of the graph in that direction.
3.Number of peaks and troughs
Use function finpeaks from R package MassArray
