Statistical inference for functional and longitudinal data