2
$\begingroup$

The problem is given below:

Simultaneous values of time $t$ and output $y$ from a specific sensor has been measured and is tabulated below $$\begin{array}{cc} t & y \\ \hline 1 & 17 \\ 2 & 15 \\ 3 & 11 \\ 4 & 10\\ 5&8\\ 6&7\\ 7&7 \end{array} $$ Determine whether the model $y_1(t) = \beta_0 + \beta_1 t$ or $y_2(t) = \gamma_0 + \gamma_1t^{-1}$ gives the best least squares fit to the data.

by having the design matrix and observation vector

enter image description here

In the first model I get following beta: $\beta_0=17.71$ and $\beta_1= -1.75$

by the formula:

$\beta = (X^TX)^{-1}X^Ty$.

My question is then, how to make the design matrix for the second model. the $t^{-1}$ confuse me!

$\endgroup$

2 Answers 2

4
$\begingroup$

Simply take the second column of your X1 matrix and invert the values, that is it should be $X1(:,2) = [1,1/2,1/3,\ldots,1/7]^T$

Then determine which line gives you a better fit between the two.

It should be noted, this type of regression is sometimes called "Linear Regression With Basis Functions." This concept can add a tremendous amount of flexibility to linear regression and you can get all kinds of neat fits. If you have interest, a simple search of this will give you many interesting articles/presentations/lecture notes on the topic.

$\endgroup$
0
$\begingroup$

Linear function

$$ y_{1}(t) = \beta_{0} + \beta_{1} t $$ Linear system: $$ \begin{align} \mathbf{A} \beta &= y \\ % \left[ \begin{array}{cc} 1 & 1 \\ 1 & 2 \\ 1 & 3 \\ 1 & 4 \\ 1 & 5 \\ 1 & 6 \\ 1 & 7 \\ \end{array} \right] % \left[ \begin{array}{c} \beta_{0} \\ \beta_{1} \end{array} \right] % &= % \left[ \begin{array}{c} 17 \\ 15 \\ 11 \\ 10 \\ 8 \\ 7 \\ 7 \end{array} \right] % \end{align} $$ Solution: $$ \beta_{LS} = % \left[ \begin{array}{c} \beta_{0} \\ \beta_{1} \end{array} \right] = % \frac{1}{28} \left[ \begin{array}{r} 496 \\ -49 \end{array} \right] % = % \left[ \begin{array}{c} 17.7143 \\ -1.753 \end{array} \right] % $$ Error: $$ r = \mathbf{A} \beta - y \qquad \Rightarrow \qquad r \cdot r \approx 7.67857 $$ linear


Reciprocal function

$$ y_{2}(t) = \gamma_{0} + \frac{\gamma_{1}} {t} $$ Linear system: $$ \begin{align} \mathbf{A} \beta &= \frac{1}{y} \\ % \left[ \begin{array}{cc} 1 & 1 \\ 1 & 2 \\ 1 & 3 \\ 1 & 4 \\ 1 & 5 \\ 1 & 6 \\ 1 & 7 \\ \end{array} \right] % \left[ \begin{array}{c} \gamma_{0} \\ \gamma_{1} \end{array} \right] % &= % \left[ \begin{array}{c} \frac{1}{17} \\ \frac{1}{15} \\ \frac{1}{11} \\ \frac{1}{10} \\ \frac{1}{8} \\ \frac{1}{7} \\ \frac{1}{7} \end{array} \right] % \end{align} $$ Solution: $$ \gamma_{LS} = % \left[ \begin{array}{c} \gamma_{0} \\ \gamma_{1} \end{array} \right] = % \frac{1}{4398240} \left[ \begin{array}{c} 181296 \\ 68891 \end{array} \right] % = % \left[ \begin{array}{c} 0.0412201 \\ 0.0156633 \end{array} \right] % $$ Error: $$ r = \mathbf{A} \gamma - \frac{1}{y} \qquad \Rightarrow \qquad r \cdot r \approx 0.000213205 $$

reciprocal

$\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.