Compute linear estimates, i.e. L %*% beta for a range of models. One example of linear estimates is population means (also known as LSMEANS).

linest(object, L = NULL, level = 0.95, ...)

# S3 method for class 'linest_class'
confint(object, parm, level = 0.95, ...)

# S3 method for class 'linest_class'
coef(object, ...)

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

Arguments

object

Model object

L

Either NULL or a matrix with p columns where p is the number of parameters in the systematic effects in the model. If NULL then L is taken to be the p times p identity matrix

level

The level of the (asymptotic) confidence interval.

...

Additional arguments; currently not used.

parm

Specification of the parameters estimates for which confidence intervals are to be calculated.

confint

Should confidence interval appear in output.

Value

A dataframe with results from computing the contrasts.

See also

Author

Søren Højsgaard, sorenh@math.aau.dk

Examples


## Make balanced dataset
dat.bal <- expand.grid(list(AA=factor(1:2), BB=factor(1:3), CC=factor(1:3)))
dat.bal$y <- rnorm(nrow(dat.bal))

## Make unbalanced dataset
#   'BB' is nested within 'CC' so BB=1 is only found when CC=1
#   and BB=2,3 are found in each CC=2,3,4
dat.nst <- dat.bal
dat.nst$CC <-factor(c(1,1,2,2,2,2,1,1,3,3,3,3,1,1,4,4,4,4))

mod.bal  <- lm(y ~ AA + BB * CC, data=dat.bal)
mod.nst  <- lm(y ~ AA + BB : CC, data=dat.nst)

L <- LE_matrix(mod.nst, effect=c("BB", "CC"))
#> List of 2
#>  $ new.fact.lev:List of 2
#>   ..$ BB: chr [1:3] "1" "2" "3"
#>   ..$ CC: chr [1:4] "1" "2" "3" "4"
#>  $ grid.data   :'data.frame':	12 obs. of  2 variables:
#>   ..$ BB: chr [1:12] "1" "2" "3" "1" ...
#>   ..$ CC: chr [1:12] "1" "1" "1" "2" ...
linest( mod.nst, L )
#>    BB CC estimate std.error statistic df p.value    lwr  upr
#> 1   1  1   0.7452     0.634    1.1755 10   0.267 -0.667 2.16
#> 2   2  1       NA        NA        NA NA      NA     NA   NA
#> 3   3  1       NA        NA        NA NA      NA     NA   NA
#> 4   1  2       NA        NA        NA NA      NA     NA   NA
#> 5   2  2   0.2024     1.098    0.1843 10   0.857 -2.244 2.65
#> 6   3  2  -1.3982     1.098   -1.2733 10   0.232 -3.845 1.05
#> 7   1  3       NA        NA        NA NA      NA     NA   NA
#> 8   2  3  -0.7211     1.098   -0.6567 10   0.526 -3.168 1.73
#> 9   3  3  -0.0317     1.098   -0.0288 10   0.978 -2.478 2.41
#> 10  1  4       NA        NA        NA NA      NA     NA   NA
#> 11  2  4  -0.1158     1.098   -0.1054 10   0.918 -2.562 2.33
#> 12  3  4       NA        NA        NA NA      NA     NA   NA