myLM: myLM

Description Usage Arguments Value Examples

View source: R/myLM.R

Description

Implementing a Linear Regression Model.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
myLM(
  formula,
  data = NULL,
  weights = NULL,
  subset = NULL,
  na.actions = NULL,
  method = "qr",
  model = TRUE,
  x = FALSE,
  y = FALSE,
  qr = TRUE,
  contrasts = NULL
)

Arguments

formula

an object of class "formula": a symbolic description of the model to be fitted. A 1-D vector of response is expected.

data

an optional data frame, list or environment containing the variables in the model. Default to NULL and then the variables are taken from formula.

weights

an optional vector of weights to be used in the fitting process, default to NULL. If non-NULL, weighted least squares is used with weights, otherwise ordinary least squares is used.

subset

an optional string specifying a subset of observations to be used in the fitting process, default to NULL.

na.actions

an user specified action when dealing with NA values, can be viewed by getOption("na.action").

method

the method to be used when fitting the model, defaulted and currently only supported with "qr". method = "model.frame" returns the model frame without fitting the model.

model, x, y, qr

logicals. Will return the corresponding components of the fit if TRUE.

contrasts

an optional list, whose entries are values to be used as replacement values for the contrasts replacement function and whose names are the names of columns of data containing factors.

Value

lm returns an object of class "lm". If not assigned to anything, myLM will print the function and the coefficients of the model fitted.

An object of class "lm" is a list containing at least the following components:

coefficients

a named vector of coefficients.

residuals

a named vector of residuals.

effect

a named vector of effects that are the uncorrelated single-degree-of-freedom values obtained by projecting the data onto the successive orthogonal subspaces generated by the QR decomposition during the fitting process.

rank

the numeric rank of the fitted linear model.

fitted.values

the fitted mean values.

assign

an integer vector with an entry for each column in the matrix giving the term in the formula which gave rise to the column.

qr

if requested, the QR decomposition of the design matrix.

df.residual

the residual degrees of freedom.

call

the matched call.

terms

the terms object for the formula.

contrasts

(only where relevant) the contrasts used.

model

if requested, the model frame used, including the intersections.

x

if requested, the design matrix used.

y

if requested, the response used.

na.action

(only where relevant) if not default, the assigned na.action

F-statistics

The F-statistics and associated p-value

Examples

1
2
3
4
5
6
data("iris")
x = iris$Petal.Width
y = iris$Petal.Length
myLM(y~x)
# Equivalently
myLM(Petal.Length~Petal.Width, data = iris)

wjhlang/myLM documentation built on Dec. 23, 2021, 5:16 p.m.