Learn R Programming

freqweights (version 0.0.1)

lmfreq: lmfreq is used to fit linear models with frequency tables

Description

To fit linear models with data grouped in frequency tables.

Usage

lmfreq(formula, data, freq = ~freq)

## S3 method for class 'lmfreq': logLik(object, ...)

## S3 method for class 'lmfreq': extractAIC(fit, scale = 0, k = 2, ...)

## S3 method for class 'lmfreq': AIC(object, ..., k = 2)

## S3 method for class 'lmfreq': summary(object, ...)

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

## S3 method for class 'summary.lmfreq': print(x, digits = getOption("digits") - 3, ...)

## S3 method for class 'lmfreq': predict(object, ...)

Arguments

formula
an object of class formula
data
a data frame that must contain all variables present in formula and freq
freq
a one-sided, single term formula specifying frequency weights
object
a lmfreq object
...
See Details
fit
a lmfreq object
scale
not used
k
penalty parameter
x
a lmfreq object
digits
digits

Value

  • It returns an object of class lmfreq, very similar to lm

Details

It computes the linear model of a frequency table. See lm for further details.

Any variables in the formula are removed from the data set.

See Also

tablefreq

Examples

Run this code
l0 <- lm(Sepal.Length ~ Sepal.Width,iris)
summary(l0)

tt <- tablefreq(iris[,1:2])
lf <- lmfreq(Sepal.Length ~ Sepal.Width,tt)
summary(lf)

all.equal(coef(lf),coef(l0))
all.equal(AIC(lf),AIC(l0))

newdata <- data.frame(Sepal.Width=c(1,NA,7))
predict(lf, newdata)

if(require(MASS)){
   stepAIC(lf)
}

Run the code above in your browser using DataLab