Skip to contents

Exam2.B.1 is used to visualize the effect of lm model statement with Gaussian data and their design matrix

References

  1. Stroup, W. W. (2012). Generalized Linear Mixed Models: Modern Concepts, Methods and Applications. CRC Press.

See also

Author

  1. Muhammad Yaseen (myaseen208@gmail.com)

  2. Adeela Munawar (adeela.uaf@gmail.com)

Examples

#-----------------------------------------------------------------------------------
## Linear Model  discussed in Example 2.B.1 using simple regression data of Table1.1
#-----------------------------------------------------------------------------------

data(Table1.1)

Exam2.B.1.lm1 <- lm(formula = y~x, data = Table1.1)
summary(Exam2.B.1.lm1)
#> 
#> Call:
#> lm(formula = y ~ x, data = Table1.1)
#> 
#> Residuals:
#>     Min      1Q  Median      3Q     Max 
#> -4.0909 -0.9727 -0.2182  0.8364  4.3455 
#> 
#> Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)  -1.2727     1.4066  -0.905 0.389136    
#> x             1.4364     0.2378   6.041 0.000193 ***
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> Residual standard error: 2.494 on 9 degrees of freedom
#> Multiple R-squared:  0.8022,	Adjusted R-squared:  0.7802 
#> F-statistic:  36.5 on 1 and 9 DF,  p-value: 0.0001925
#> 
library(parameters)
model_parameters(Exam2.B.1.lm1)
#> Parameter   | Coefficient |   SE |        95% CI |  t(9) |      p
#> -----------------------------------------------------------------
#> (Intercept) |       -1.27 | 1.41 | [-4.45, 1.91] | -0.90 | 0.389 
#> x           |        1.44 | 0.24 | [ 0.90, 1.97] |  6.04 | < .001
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a Wald t-distribution approximation.

DesignMatrix.lm1 <- model.matrix (object = Exam2.B.1.lm1)
DesignMatrix.lm1
#>    (Intercept)  x
#> 1            1  0
#> 2            1  1
#> 3            1  2
#> 4            1  3
#> 5            1  4
#> 6            1  5
#> 7            1  6
#> 8            1  7
#> 9            1  8
#> 10           1  9
#> 11           1 10
#> attr(,"assign")
#> [1] 0 1