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.595     0.432     1.376 10   0.199 -0.369 1.559
#> 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    1.048     0.749     1.400 10   0.192 -0.621 2.718
#> 6   3  2   -1.211     0.749    -1.617 10   0.137 -2.880 0.458
#> 7   1  3       NA        NA        NA NA      NA     NA    NA
#> 8   2  3   -0.083     0.749    -0.111 10   0.914 -1.752 1.586
#> 9   3  3    1.054     0.749     1.407 10   0.190 -0.615 2.723
#> 10  1  4       NA        NA        NA NA      NA     NA    NA
#> 11  2  4   -0.376     0.749    -0.501 10   0.627 -2.045 1.293
#> 12  3  4       NA        NA        NA NA      NA     NA    NA