Skip to contents

Returns coefficients with standard errors, t statistics and two-sided p-values, R^2 and adjusted R^2, the residual standard error and the overall F test – what summary(lm(...)) reports. Perfectly collinear predictors raise rather than silently returning one arbitrary solution out of infinitely many.

Usage

morie_ols(y, X, add_intercept = TRUE)

Arguments

y

numeric response

X

predictor matrix

add_intercept

prepend an intercept column

Value

list with coef, se, t, p_value, r_squared, adj_r_squared, sigma, f_statistic, f_p_value, residuals

Examples

if (requireNamespace("sandwich", quietly = TRUE)) {
  V <- c(1, 2, 3, 4, 5, 6, 7, 8)
  morie_ols(V, V)
}
#> $coef
#> [1] 1.054712e-15 1.000000e+00
#> 
#> $se
#>  (Intercept)              
#> 9.607180e-16 1.902505e-16 
#> 
#> $t
#>  (Intercept)              
#> 1.097837e+00 5.256228e+15 
#> 
#> $p_value
#>  (Intercept)              
#> 3.143675e-01 3.200801e-93 
#> 
#> $fitted
#> [1] 1 2 3 4 5 6 7 8
#> 
#> $residuals
#> [1] -1.110223e-15 -8.881784e-16 -8.881784e-16 -8.881784e-16 -8.881784e-16
#> [6] -8.881784e-16 -8.881784e-16 -1.776357e-15
#> 
#> $n
#> [1] 8
#> 
#> $k
#> [1] 2
#> 
#> $df_resid
#> [1] 6
#> 
#> $df_model
#> [1] 1
#> 
#> $rss
#> [1] 9.121204e-30
#> 
#> $tss
#> [1] 42
#> 
#> $sigma2
#> [1] 1.520201e-30
#> 
#> $sigma
#> [1] 1.232964e-15
#> 
#> $sigma2_ml
#> [1] 1.140151e-30
#> 
#> $beta
#> [1] 1.054712e-15 1.000000e+00
#> 
#> $se_beta
#>  (Intercept)              
#> 9.607180e-16 1.902505e-16 
#> 
#> $r_squared
#> [1] 1
#> 
#> $adj_r_squared
#> [1] 1
#> 
#> $f_statistic
#> [1] 2.762793e+31
#> 
#> $f_p_value
#> [1] 3.200801e-93
#> 
#> $XtX_inv
#>             (Intercept)            
#> (Intercept)   0.6071429 -0.10714286
#>              -0.1071429  0.02380952
#> 
#> $design
#>      (Intercept)  
#> [1,]           1 1
#> [2,]           1 2
#> [3,]           1 3
#> [4,]           1 4
#> [5,]           1 5
#> [6,]           1 6
#> [7,]           1 7
#> [8,]           1 8
#>