check.hom: Check linear models for homoscedasticity

View source: R/check.hom.R

check.homR Documentation

Check linear models for homoscedasticity

Description

This function takes a linear model object as an argument and checks whether the residuals are homoscedastic, in relation to a stratification variable, that is given as an argument.

Usage

check.hom(obj, var)

Arguments

obj

a linear model object fitted with lm()

var

a vector containing a stratification variable

Details

The function fits a gls with same structure as the input model, together with a heteroscedastic gls, where residuals are allowed to assume a different variance for each level of the stratification variable. The two models are compared by a LRT

Value

LRT

the value of LRT

LRT

the P-value of LRT

aovtable

a summary table for the LRT

modHet

the gls object containing the heteroscedastic fit

Author(s)

Andrea Onofri

Examples

fileName <- "https://www.casaonofri.it/_datasets/FGP_rape.csv"
library(aomisc)
dataset <- read.csv(fileName)
dataset[,1:5] <- lapply(dataset[,1:5], factor)
mod <- lm(FGP ~ Genotype * Run, data = dataset)
check <- check.hom(mod, Run)
check$aovtable

OnofriAndreaPG/aomisc documentation built on Feb. 26, 2024, 8:21 p.m.