In [33]:

source("../R/functions.R");




In [34]:

printLinearRegressionEstimates(n = 20, Sx = 120.622, USSx = 742.121606, St = 108.068, USSt = 596.990072, SPxt = 664.381658)




Model for lineær regression

$M: X_i \sim N(\alpha + \beta t_i, \sigma^2), \quad i = 1, \dots, n$

$n = 20$

$S_x = 120.622$

$S_t = 108.068$

$USS_x = 742.121606$

$USS_t = 596.990072$

$SSD_t = USS_t - \frac{S_t^2}{n} = 13.0554408$

$SSD_x = USS_x - \frac{S_x^2}{n} = 14.6382618$

$SP_{xt} = 664.381658$

$\bar{x}. = \frac{S_x}{n} = 6.0311$

$\bar{t}. = \frac{S_t}{n} = 5.4034$

$SPD_{xt} = SP_{xt} - \frac{S_x S_t}{n} = 664.381658 - \frac{120.622 \cdot 108.068}{20} = 12.6127432000001$

$\hat{\beta} = \frac{SPD_{xt}}{SSD_t} = \frac{12.6127432000001}{13.0554408} = 0.966090949606238 \sim\sim N(\beta, \frac{\sigma^2}{SSD_t})$

$\hat{\alpha} = \frac{S_x - \hat{\beta} S_t}{n} = \frac{120.622 - 0.966090949606238 \cdot 108.068}{20} = 0.810924162897653 \sim\sim N(\alpha, \sigma^2 (\frac{1}{n} + \frac{\bar{t}.^2}{SSD_t}))$

$t_{0.975}(n - 2) = 2.10092204024104$

$SSD_{02} = SSD_x - \frac{SPD_{xt}^2}{SSD_t} = 14.6382618 - \frac{12.6127432000001^2}{13.0554408} = 2.45320474477232$

estimat for varians

$s_{02}^2 = \frac{SSD_{02}}{n - 2} = 0.136289152487351 \sim\sim \sigma^2 \chi^2(f_{02})/f_{02}$

$StdError(\hat{\beta}) = \sqrt{\frac{s_{02}^2}{SSD_t}} = 0.102172701273739$

$StdError(\hat{\alpha}) = \sqrt{s_{02}^2 \cdot \left(\frac{1}{n} + \frac{\bar{t}.^2}{SSD_t}\right)} = 0.558217480365173$

$C_{95}(\beta) = \hat{\beta} \mp t_{0.975}(n - 2) \cdot StdError (\hat{\beta}) = 0.966090949606238 \mp 0.214656880016962 = [0.751434069589276; 1.1807478296232]$

$C_{95}(\alpha) = \hat{\alpha} \mp t_{0.975}(n - 2) \cdot StdError (\hat{\alpha}) = 0.810924162897653 \mp 1.17277140774701 = [-0.361847244849359; 1.98369557064466]$




In [35]:

printLinearRegressionBetaHypothesis(n = 20, Sx = 120.622, USSx = 742.121606, St = 108.068, USSt = 596.990072, SPxt = 664.381658, betaGuess = 1)




Error in linearRegressionBetaHypothesis(n, Sx, St, USSx, USSt, SPxt, betaGuess): object 's_03Start' not found
Traceback:

1. printLinearRegressionBetaHypothesis(n = 20, Sx = 120.622, USSx = 742.121606,
.     St = 108.068, USSt = 596.990072, SPxt = 664.381658, betaGuess = 1)
2. linearRegressionBetaHypothesis(n, Sx, St, USSx, USSt, SPxt, betaGuess)




In [ ]: