Please read the following few lines which explain the structure of the provided code:


The provided code can be used to analyse correlated functional data with a random intercept or a
crossed design structure and applies to data that are sampled irregularly or sparsely. It can, of course, 
also be used to analyse regular grid data, but it is designed for the irregular case and therefore 
not the most efficient way to analyse regular grid data.

Note, that the covariates may enter the mean function as varying coefficients, e.g. f(t)*x, 
or in simpler ways (e.g.~ t+x^T\beta or f(t)+x^T\beta).



The structure is as follows:

- exemplary data can be generated using function gendata() in file gendata.R that calls the function in gen_function.R.
  Note that with the defaults, this is only a small, exemplary data set and we cannot expect to obtain good results.
  More realistic and larger data can, of course, also be generated using this function, but will take longer in
  the estimation. Computation times for our real data analysis and simulations are given in the paper.

- the (real) phonetics data can be found in folder "data", where a readme-file especially for the data is provided.

- FLMM_sparse.R is the main file and can be used to specify and fit the functional linear mixed model. 
  All input variables are explained here and exemplarily given for the analysis of the phonetics data. 
  It is also documented which R-packages need to be installed and loaded. 
  Note that certain versions of the packages are necessary as bugs had to be fixed.

- in FLMM_sparse.R, the function call_functions() is called, that can be found in file call_all_functions.R. 
  It calls functions in which the mean and covariate effects are estimated (in mean_estimation.R), 
  the cross products are built (in prep_covariance.R and functions.R), followed by the 
  estimation of the auto-covariances (in covariance_estimation.R). In a next step, 
  the eigenvalues and eigenfunctions are extracted and the basis weights are predicted (in fpc_estimation.R).
  If specified (use_pffr=TRUE), the algorithm re-estimates the mean and covariate effects and predicts the
  basis weights using the representation as a functional additive mixed model (in fpc_famm_estimation.R).


The output returned in FLMM_sparse.R is a list (named 'results'), the structure of which is also described in the
file FLMM_sparse.R.



Note that the curve-specific deviations are denoted by U (rather than E) in the code. Moreover, the eigenvalues are denoted by lambda_B,
lambda_C, and lambda_U, respectively.





If there are any questions or difficulties, please let us know.

