The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Package {linearModel}


Type: Package
Title: Linear Model Functions
Version: 1.1.1
Date: 2026-10-13
Author: Jared Studyvin [aut, cre]
Depends: R (≥ 3.6.0)
Imports: stats, utils, methods
Maintainer: Jared Studyvin <studyvinstat@gmail.com>
Description: Functions to access and test results from a linear model.
License: MIT + file LICENSE
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2026-10-14 20:55:21 UTC; jaredstudyvin
Repository: CRAN
Date/Publication: 2026-10-14 21:22:07 UTC

ANOVA Table

Description

Produces the overall ANOVA table where the model sum of squares are not partioned into their parts.

Usage

anovaTable(object, ...)

Arguments

object

lm or aov model object

...

currently ignored

Value

Object of class anova and data.frame

Examples

data(depression)

## MLR model
modMLR <- lm(depress~trauma+control,data=depression)
anovaTable(modMLR)

## ANOVA model
depression$gender <- factor(depression$gender)
depression$history <- factor(depression$history)
modAOV  <- lm(depress~-1+gender+history+gender:history,data=depression)
anovaTable(modAOV)


Cell Means

Description

Extract cell means and other information from a linear model.

Usage

cellMeans(object, factors = NULL, var.equal = TRUE, ...)

Arguments

object

lm or aov model object

factors

character vector providing the model terms (factors/categorical predictors) to obtain the means for each level or level combinations

var.equal

currently ignored

...

currently ignored

Details

The purpose of this function is to summarize results from a linear model in preperation to test contrast(s) with a call to the contrast function.

The weights of the linear model object are currently being ignored.

Value

Object of class anova and data.frame

See Also

contrast

Examples

data(genericData)

mod <- lm(Y~A+B+A*B,data=genericData)
cellMeans(mod, factors='A')
cellMeans(mod)


Contrasts

Description

Contrast testing function. Designed to test contrasts of parameter estimates from a linear model.

Usage

contrast(cm, C = NULL, adjust = c("hsd", "scheffe", "bonferroni", "lsd"), ...)

Arguments

cm

cellMeans object

C

numeric matrix, each row is a contrast that should sum to zero, see details

adjust

character, indicating which testing method should be used, see details

...

currently ignored

Details

The test argument can be one of the following: 'scheffe','bonferroni','hsd', or 'lsd'. 'hsd' is the Tukey HSD test. 'lsd' is th Fisher LSD test. The other two are the Scheffe test and Bonferroni adjustment.

The matrix C is the contrast matrix. Each row is a separate contrast. The number of columns of C must be equal to the number of means in the cm object. Row names for C are retained in the output, but they are not required.

This is a wrapper function and the workhorse is the testContrast function.

Value

Object of class anova and data.frame

See Also

cellMeans

Examples

data(genericData)

mod <- lm(Y~A, data=genericData)
cm <- cellMeans(mod)

contrast(cm=cm) ## pairwise tukey 

## each group vs the mean of the other two
C <- rbind(c(1,-0.5,-0.5),c(-0.5,1,-0.5),c(-0.5,-0.5,1))
## row names are not required but are helpful
row.names(C) <- c('1 vs 2+3','2 vs 1+3','3 vs 1+2')
contrast(cm=cm, C=C, adjust='scheffe')


Self Reported Depression

Description

Self reported level of depression and other associated metrics.

Usage

data(depression)

Format

An object of class data.frame with 50 rows and 13 columns.

Details

This is a fictious dataset useful for teaching how to use and interpret linear statistical models. The variables are:

educate

Level of Education: (1) professional degree (non-college), (2) 2 years of college, (3) 2+ years of college, but not a BS degree, (4) BS degree, (5) MS degree

income

Annual Income: 1 = $10,0001 to $19,999; 2 = $20,000 to $29,999; ... 9 = $90,000 to $99,999; 10 = $100,000 or more

trauma

Experience of Trauma; Percent of Life Events Viewed as Traumatic: 0 = 0%, 1 = 10%, 2= 20%, ..., 9 = 90%, 10 = 100%

satisfac

Satisfied with your Life: 0 = No, 1 = Yes

control

Feeling of Control; How much do you feel in control: 0 = Not at all, 1 = A Little, 2 = Some, 3 = A Lot, 4 = Completely

history

Family History of Depression: 0 = No, 1 = Yes

exercise

Weekly Amount of Exercise: 0 = None, 1 = 1 Hour, 2 = 2 Hours, 3 = 3 Hours, 4 = 4 Hours, 5 = 5 or more Hours

mhpg

3-methoxy-4-hydroxyphenylethyleneglycol, Depression Related Chemical Secreted in Urine; milligrams secreted per 24 hour period, labeled as mg/24h: 0 = 0 mg/24h, 1 = 100 mg/24h,..., 9 = 900 mg/24h, 10 = 1000+ mg/24h

sleep

Amount of Sleep Problems: 0 = None, 1 = 10% of the time, ... , 9 = 90% of the time, 10 = 100% of the time

depress

Perceived Level of Depression: 0 = None, 1 = 10% of the time, ... , 9 = 90% of the time, 10 = 100% of the time

depressYes

Do I consider myself depressed: 0 = No, 1 = Yes

welbeing

Feeling of Well Being; how often do you feel good about yourself: 0 = None, 1 = 10% of the time, ... , 9 = 90% of the time, 10 = 100% of the time

gender

Your Sex: 0 = Male, 1 = Female


Generic Data Set

Description

Generic data set with four ratio predictors (X1,X2,X3,X4), two categorical predictors (A,B) and one ratio response variable (Y).

Usage

data(depression)

Format

An object of class data.frame with 60 rows and 7 columns.

Details

This is a fictious dataset useful for teaching how to use and interpret linear statistical models.


Print cellMeans object

Description

Print cellMeans object.

Usage

## S3 method for class 'cellMeans'
print(x, ...)

Arguments

x

A cellMeans object.

...

Currently ignored.

Details

see cellMeans

Value

Print for cellMeans object


Test Contrasts

Description

Contrast testing function. Designed to test contrasts of parameter estimates from a linear model.

Usage

testContrast(
  estVec,
  n,
  dfModel,
  dfError,
  mse,
  C = NULL,
  adjust = c("hsd", "scheffe", "bonferroni", "lsd"),
  ...
)

Arguments

estVec

numeric vector of parameter estimates for comparison

n

numeric vector indicating the sample size for the parameter estimates, if a single value is given it is assumed to apply to all estiamtes

dfModel

numeric value for the model degrees of freedom

dfError

numeric value for the error or residual degrees of freedom

mse

numeric value for the mean squared error from the model

C

numeric matrix, each row is a contrast that should sum to zero, see details

adjust

character, indicating which testing method should be used, see details

...

currently ignored

Details

The adjust argument can be one of the following: 'scheffe','bonferroni','hsd', or 'lsd'. 'hsd' is the Tukey HSD test. 'lsd' is th Fisher LSD test. The other two are the Scheffe test and Bonferroni adjustment.

The matrix C is the contrast matrix. Each row is a separate contrast. The number of columns of C must be equal to the length(estVec). Row names for C are retained in the output, but they are not required.

This is the workhorse function. The work flow is designed that a user calls cellMeans and contrast functions.

Value

Object of class anova and data.frame

See Also

cellMeans contrast

Examples

data(genericData)

mod <- lm(Y~A,data=genericData)
dfModel <- anovaTable(mod)['Model','df']
dfError <- anovaTable(mod)['Residual','df']
mse <- anovaTable(mod)['Residual','MS']
meanVec <- aggregate(Y~A,FUN=mean,data=genericData)$Y
n <- aggregate(Y~A,FUN=length,data=genericData)$Y

## can add names for ease of interpretation with the output
names(meanVec) <- c('group 1','group 2','group 3')
testContrast(estVec=meanVec,n=n,dfModel=dfModel,dfError=dfError,mse=mse,adjust='hsd')

## each group vs the mean of the other two
C <- rbind(c(1,-0.5,-0.5),c(-0.5,1,-0.5),c(-0.5,-0.5,1))
## row names are not required but are helpful
row.names(C) <- c('1 vs 2+3','2 vs 1+3','3 vs 1+2')
testContrast(estVec=meanVec,n=n,dfModel=dfModel,dfError=dfError,mse=mse,C=C,adjust='scheffe')

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.