# 3 Latent Repeated Measures ANOVA

## 3.1 Arguments

The input for semnova is very similar to the car package for analysis of variance (Fox & Weisberg, 2019). It takes the following arguments:

• formula: A formula object.
• idesign: A design object describing the factorial design.
• idata: A table mapping the dependent variables to the experimental conditions.
• data: A dataset.
• mmodel (optional): A measurement model mapping the variables from the dataset to the variables in the formula object. If not given, the variables from the formula object will be used.

### formula

The formula object contains the names of the dependent variables (i.e., the combinations of the levels of the factors).

formula <- cbind(NN, PN, NP, PP) ~ 1

NN, for instance, represents the condition Peer = negative and Human = negative.

### idata

The idata object is a dataframe that has as many rows as variables in the formula object. The columns represent the experimental factors. The rows represent the possible combinations of the factor levels.

idata <- expand.grid(Peer = c("negative", "positive"),
Human = c("negative", "positive"))

idata
##       Peer    Human
## 1 negative negative
## 2 positive negative
## 3 negative positive
## 4 positive positive

The idata object maps the combinations of the factorial levels to the variables in the formula object.

### idesign

The design object is a formula object that represents the effects of interest. That is, when expanded, the formula contains the terms (i.e., the main and interaction effects) that the user is interested in. Currently, semnova can only model saturated models, that is, all possible terms are inlcuded. Subsets are currently not possible, but will this feature will be added in the future.

idesign <- ~Peer*Human

### mmodel

The measurement model is optional. If the dependent variables are measure via multiple indicators, the create_mmodel() can be used to map variables from the dataset to the variables from the formula object. By default, the effects-coding indentification method introduced by Little et al. (2006) is used. If you prefer the referent-indicator method, add the argument lv_scaling = "referent.

library(semnova)

mmodel <- create_mmodel(
NN = c("S1NN", "S2NN"),
PN = c("S1PN", "S2PN"),
NP = c("S1NP", "S2NP"),
PP = c("S1PP", "S2PP")
)

## 3.2 The First Analysis

The function semnova() performs the analysis and takes the aforementioned arguments:

library(semnova)

fit <- semnova(
formula = cbind(NN, PN, NP, PP) ~ 1,
data = d_wide,
idata = idata,
idesign = idesign,
mmodel = mmodel
)

Hypothesis tests of default main and interaction effects can be printed using the summary() function:

summary(fit)
## ------------------------------------------
##
## term: (Intercept)
##
## Response transformation matrix:
##                   (Intercept)
## negative.negative         0.5
## positive.negative         0.5
## negative.positive         0.5
## positive.positive         0.5
##
## multiv. tests:
##       Df test stat approx F num Df den Df Pr(>F)
## Wald   1   0.85307  0.85307      1     25 0.3645
## Wilks  1   0.96595  0.88125      1     25 0.3568
##
## univ. test:
##        Sum Sq num Df Error SS den Df F value Pr(>F)
## F-test 0.7295      1   20.695     25  0.8812 0.3568
##
## ------------------------------------------
##
## term: Peer
##
## Response transformation matrix:
##                   Peer1
## negative.negative  -0.5
## positive.negative   0.5
## negative.positive  -0.5
## positive.positive   0.5
##
## multiv. tests:
##       Df test stat approx F num Df den Df Pr(>F)
## Wald   1   0.18200  0.18200      1     25 0.6733
## Wilks  1   0.99124  0.22083      1     25 0.6425
##
## univ. test:
##          Sum Sq num Df Error SS den Df F value Pr(>F)
## F-test 0.045471      1   5.1477     25  0.2208 0.6425
##
## ------------------------------------------
##
## term: Human
##
## Response transformation matrix:
##                   Human1
## negative.negative   -0.5
## positive.negative   -0.5
## negative.positive    0.5
## positive.positive    0.5
##
## multiv. tests:
##       Df test stat approx F num Df den Df    Pr(>F)
## Wald   1   22.6149   22.615      1     25 7.021e-05 ***
## Wilks  1    0.5058   24.431      1     25 4.322e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## univ. test:
##        Sum Sq num Df Error SS den Df F value    Pr(>F)
## F-test 13.782      1   14.102     25  24.431 4.322e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## ------------------------------------------
##
## term: Peer:Human
##
## Response transformation matrix:
##                   Peer1:Human1
## negative.negative          0.5
## positive.negative         -0.5
## negative.positive         -0.5
## positive.positive          0.5
##
## multiv. tests:
##       Df test stat approx F num Df den Df Pr(>F)
## Wald   1   0.06643 0.066430      1     25 0.7987
## Wilks  1   0.99670 0.082832      1     25 0.7759
##
## univ. test:
##          Sum Sq num Df Error SS den Df F value Pr(>F)
## F-test 0.015346      1   4.6316     25  0.0828 0.7759
##
## ------------------------------------------

The output is very similar to the output produced by the car package. The contrast matrix (or response transformation matrix) as well as test statistics for each of the effects are printed. Univariate and multivariate statistics are given. As latent RM-ANOVA relys on structural equation modeling, maximum likelihood is used for estimating the model parameters. The Wald test is a common test for testing parameters in the structural equation modeling framework. Wilk’s lambda is based on the means and variances of the effect variables (i.e., contrasts). That is, Wilk’s lambda is not based on an OLS estimator, but on the maximum likelihood estimates. This is also valid for the univariate test statistics.