GLM: General Linear Model similar to SAS PROC GLM

View source: R/GLM.R

GLMR Documentation

General Linear Model similar to SAS PROC GLM

Description

GLM is the main function of this package.

Usage

  GLM(Formula, Data, BETA=FALSE, EMEAN=FALSE, Resid=FALSE, conf.level=0.95,
      Weights=1)

Arguments

Formula

a conventional formula for a linear model.

Data

a data.frame to be analyzed

BETA

if TRUE, coefficients (parameters) of REG will be returned. This is equivalent to the SOLUTION option of SAS PROC GLM

EMEAN

if TRUE, least square means (or expected means) will be returned. This is equivalent to the LSMEANS statement of SAS PROC GLM

Resid

if TRUE, fitted values (y hat) and residuals will be returned

conf.level

confidence level for the confidence limit of the least square mean

Weights

weights for the weighted least squares. This should be a scalar or a vector of the same length as the number of rows of Data. Observations with nonpositive weights are excluded from the analysis as SAS does.

Details

It performs the core function of SAS PROC GLM. Least square means for the interaction term of three variables are not supported yet.

Value

The result is comparable to that of SAS PROC GLM.

ANOVA

ANOVA table for the model

Fitness

Some measures of goodness of fit such as R-square and CV

Type I

Type I sum of squares table

Type II

Type II sum of squares table

Type III

Type III sum of squares table

Parameter

Parameter table with standard error, t value, p value. TRUE is 1, and FALSE is 0 in the Estimable column. This is returned only with the BETA=TRUE option.

Expected Mean

Least square (or expected) mean table with confidence limits. This is returned only with the EMEAN=TRUE option.

Fitted

Fitted values or y hat in the original scale, as SAS OUTPUT P= does, even with Weights. This is returned only with the Resid=TRUE option.

Residual

Residuals in the original scale, as SAS OUTPUT R= does, even with Weights. This is returned only with the Resid=TRUE option.

Author(s)

Kyun-Seop Bae k@acr.kr

See Also

REG, aov1, aov2, aov3, LSM, PDIFF

Examples

GLM(uptake ~ Type*Treatment + conc, CO2[-1,]) # Making data unbalanced
GLM(uptake ~ Type*Treatment + conc, CO2[-1,], BETA=TRUE)
GLM(uptake ~ Type*Treatment + conc, CO2[-1,], EMEAN=TRUE)
GLM(uptake ~ Type*Treatment + conc, CO2[-1,], Resid=TRUE)
GLM(uptake ~ Type*Treatment + conc, CO2[-1,], BETA=TRUE, EMEAN=TRUE)
GLM(uptake ~ Type*Treatment + conc, CO2[-1,], BETA=TRUE, EMEAN=TRUE, Resid=TRUE)

sasLM documentation built on June 15, 2026, 9:07 a.m.