# LSM: Least Square Means In sasLM: 'SAS' Linear Model

 LSM R Documentation

## Least Square Means

### Description

Estimates least square means using g2 inverse.

### Usage

```  LSM(Formula, Data, Term, conf.level=0.95, adj="lsd", hideNonEst=TRUE,
PLOT=FALSE, ...)
```

### Arguments

 `Formula` a conventional formula of model `Data` data.frame `Term` term name to be returned. If there is only one independent variable, this can be omitted. `conf.level` confidence level for the confidence limit `adj` adjustment method for grouping, "lsd"(default), "tukey", "bon", "duncan", "scheffe" are available. This does not affects SE, Lower CL, Upper CL of the output table. `hideNonEst` hide non-estimables `PLOT` whether to plot LSMs and their confidence intervals `...` arguments to be passed to `plot`

### Details

It corresponds to SAS PROC GLM LSMEANS. The result of the second example below may be different from `emmeans`. This is because SAS or this function calculates mean of the transformed continuous variable. However, `emmeans` calculates the average before the transformation. Interaction of three variables is not supported yet. For adjustmethod method "dunnett", see `PDIFF` function.

### Value

Returns a table of expectations, t values and p-values.

 `Group` group character. This appears with one-way ANOVA or `Term` or `adj` argument is provided. `LSmean` point estimate of least square mean `LowerCL` lower confidence limit with the given confidence level by "lsd" method `UpperCL` upper confidence limit with the given confidence level by "lsd" method `SE` standard error of the point estimate `Df` degree of freedom of point estimate

### Author(s)

Kyun-Seop Bae k@acr.kr

`PDIFF`, `Diffogram`

### Examples

```LSM(uptake ~ Type, CO2[-1,])
LSM(uptake ~ Type - 1, CO2[-1,])
LSM(uptake ~ Type*Treatment + conc, CO2[-1,])
LSM(uptake ~ Type*Treatment + conc - 1, CO2[-1,])
LSM(log(uptake) ~ Type*Treatment + log(conc), CO2[-1,])
LSM(log(uptake) ~ Type*Treatment + log(conc) - 1, CO2[-1,])
LSM(log(uptake) ~ Type*Treatment + as.factor(conc), CO2[-1,])
LSM(log(uptake) ~ Type*Treatment + as.factor(conc) - 1, CO2[-1,])
LSM(log(CMAX) ~ SEQ/SUBJ + PRD + TRT, BEdata)
LSM(log(CMAX) ~ SEQ/SUBJ + PRD + TRT - 1, BEdata)
```

sasLM documentation built on Sept. 5, 2022, 5:11 p.m.