lm_summary: lm_summary

Description Usage Arguments Value Examples

View source: R/lm_summary.R

Description

Summary method for the result list of lm_fit.

Usage

1
lm_summary(object, correlation = FALSE)

Arguments

object

a result of lm_fit; only support cases when the input response variable is a vector or a n * 1 matrix and the method for fitting the model is "qr".

correlation

logical;if TRUE, the correlation matrix of the estimated parameters is returned and printed.

Value

lm_summary returns a list containing following response values.

residuals

a vector of residuals, which equals response minus fitted values.

coefficients

a named vector of coefficients.

aliased

a named logical vector showing if the original coefficients are aliased.

sigma

the square root of the estimated variance of the random error

df

degrees of freedom, a 3-vector (p, n-p, p*), the first being the number of non-aliased coefficients, the last being the total number of coefficients.

fstatistics

(for models including non-intercept terms) a 3-vector with the value of the F-statistic with its numerator and denominator degrees of freedom.

r.squared

R^2, the fraction of variance explained by the model.

adj.r.squared

adjusted R^2.

cov.unscaled

a p * p matrix covariances of the coefficients.

correlation

a p * p correlation matrix of the coefficients.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
n = 10; p = 5; q = 2;
x = matrix(rnorm(n * p), n, p) # no intercept
y1 = rnorm(n)
y2 = matrix(rnorm(n * q), n, q)

z1 = lm_fit(x = x, y = y1)
z2 = lm_fit(x = x, y = y2)

# no correlation matrix is returned
z_summary1 = lm_summary(z1)
z_summary2 = lm_summary(z1, correlation = TRUE) #return correlation matrix
# lm_summary function doesn't support cases lm_summary(z2)
# because the response value y2 is a matrix with more than 1 columns.

leyaozh/lm.hw4 documentation built on Dec. 3, 2019, 7:18 a.m.