Load the sample data.

`weight`

contains data from a longitudinal study, where 20 subjects are randomly assigned to 4 exercise programs, and their weight loss is recorded over six 2-week time periods. This is simulated data.

Store the data in a table. Define `Subject`

and `Program`

as categorical variables.

Fit a linear mixed-effects model where the initial weight, type of program, week, and the interaction between the week and type of program are the fixed effects. The intercept and week vary by subject.

Compute the fixed-effects coefficient estimates.

fe = *9×1*
0.6610
0.0032
0.3608
-0.0333
0.1132
0.1732
0.0388
0.0305
0.0331

The first estimate, 0.6610, corresponds to the constant term. The second row, 0.0032, and the third row, 0.3608, are estimates for the coefficient of initial weight and week, respectively. Rows four to six correspond to the indicator variables for programs B-D, and the last three rows correspond to the interaction of programs B-D and week.

Compute the 95% confidence intervals for the fixed-effects coefficients.

fecI = *9×2*
0.1480 1.1741
0.0005 0.0059
0.1004 0.6211
-0.2932 0.2267
-0.1471 0.3734
0.0395 0.3069
-0.1503 0.2278
-0.1585 0.2196
-0.1559 0.2221

Some confidence intervals include 0. To obtain specific $$p$$-values for each fixed-effects term, use the `fixedEffects`

method. To test for entire terms use the `anova`

method.