# 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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.8708875179290771, "perplexity": 552.8446864971896}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-25/segments/1623487612154.24/warc/CC-MAIN-20210614105241-20210614135241-00191.warc.gz"}