# Fitting data in differential equation

I have a sampled data for two variables y and x, where y is the dependent and x is the independent variable. The two variables are related as

$A\frac{dy}{dt} + y = B\frac{d^2x}{dt^2}+C\frac{dx}{dt} + Dx$ , where A, B, C and D are constants

My question is can I do a linear regression on the following equation to find values of A, B, C, D?

$y = B\frac{d^2x}{dt^2}+C\frac{dx}{dt} + Dx - A\frac{dy}{dt}$

I calculate the the derivatives by finite differences. If above is valid, how do I find the fitted values of y (with the presence of its derivative on right hand side)?

Edit: x and y are current and voltage signals resp.

• What can you say about the likely errors in your measurements of $y$ and $x$? This is important, because the possibility of either (a) measurement error or (b) slight variation in the coefficients over time will lead to lack of fit. In that case, because you must use the observations of $y$ to estimate $dy/dt$, the proposed regression would be inappropriate (since combinations of the same random variables would appear on both sides). – whuber Dec 24 '14 at 21:34
• If you write dy/dt = ay + ... + u, then the error u doesn't need to be necessarily correlated with the level y. The discretized version could be with appropriate assumptions a regression of y_t - y_{t-1} on y_{t-1} and functions of x, which doesn't have an "endogeneity" bias with OLS. Otherwise, one of the initial applications of GMM (generalized method of Moments) was estimating linearized Euler equations with endogeneity. – Josef Dec 24 '14 at 22:52
• @user333700 So if I take the discrete version having terms y(t-1), y(t), x(t-2), x(t) etc., do a regression, and recursively find the fitted values of y(t), this will be a correct method? – easternray Dec 25 '14 at 0:10
• @whuber Originally y and x are noisy, but I am using filtered data (with delay compensation) for fitting. Also, the system is such that the coefficients vary. For this I am using piece-wise regression. Is then the linear regression valid? – easternray Dec 25 '14 at 0:45
• @easternray As whuber commented, you still need assumptions on the error term and on the correlation between error and regressors at different time points. However, if you can write it so that only past y(t-i) are regressors and the current error u(t) is uncorrelated with past y(t-i), then the parameter estimates with OLS will still be consistent. That's standard time series analysis, and, I think, there is a continuous time diffusion version, which I'm not very familiar with. (A possible problem is if the pre-filtering of the data introduces intertemporal correlation in the error term.) – Josef Dec 25 '14 at 5:00