1
$\begingroup$

The data produced from my humidity sensor at different temperature is as follows (forget about purpose of frequency and its source) Data obtained from sensor at different temperature.

on re-arrangement (temp in deg C)

enter image description here

In this case temperature and frequency are independent variables and humidity is dependent on both of them. Humidity seems directly proportional to frequency if analyzed for humidity Vs Frequency and temperature seems inversely proportional to frequency while analyzed Temp Vs Frequency.

I need to be able to make an equation which gives Humidity upon solving with known temperature and frequency. For example if I input F = 8179 and T = 20.5, H should be near to 42%.

I tried polyfit and interp2 from MATLAB for frequency vs humidity and got much errors and tried least square method manually but ended getting nothing near. Specifically I do not have idea on modeling for 3 Variable equation. What may be the way for modeling 3 variable equations upon this small sets of data. Thanks.

$\endgroup$
2
$\begingroup$

You want to fit the model $H = \beta_0 + \beta_1 T + \beta_2 H + \epsilon$

The standard way to enter the data to fit this problem is to enter 3 columns, one for T, one for F, one for H.

T F H
20 8179 40
30 8044 40
40 7923 40
20 8343 60
30 8250 60
40 8130 60
20 8528 80
30 8430 80
40 8320 80

In R, the model can be fitted with the command:
lm(H~T+F)

Without checking the appropiatemes of the model, the result is:
Coefficients:
(Intercept) $\;\;\;\;\;$ T $\;\;\;\;\;\;\;\;\;\;\;\;\;$ F
-845.4072 $\;\;\;\;\;$ 1.1911 $\;\;\;\;\;$ 0.1056
with Rsqr= 0.9958.

When F = 8179 and T = 20.5, the predicted value of H = -845.4072 + 1.1911*20.5 + 0.1056*8179 = 42.39791

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.