M7777 Applied Functional Data Analysis 10. Functional Response with Functional Covariate Jan Koláček (kolacek@math.muni.cz) Dept. of Mathematics and Statistics, Faculty of Science, Masaryk University, Brno Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 1/49 Functional Response Models 1. The Concurrent Model Let us recall model (1) with scalar covariates K y/(0 = A>(0 + Yl PjMzu + e'(0- 7=1 We can extend (1) to allow for functional covariates as follows K y/(t) = A>(0 + #(0*1/(0 + £'(0- 7=1 (O (2) Model (2) is called concurrent because it only relates the value of y;(t) to the value of z,y(t) at the same time points t. Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 2 / 49 Functional Response Models Example Canadian Weather We would like to predict log10 of Precipitation in relation to Temperatu We consider a model y/(t) = p0(t) + Pi(t)zi(t) + 67(f), / = 1,... ,35, where • z,-(t) . . .smoothed annual temperature at the /-th station • y/(t) .. .smoothed log10 of precipitation at the /-th station • /3o(t),/3i(t) ...regression parameters Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 3 / 49 Functional Response Models c o 2 O CD O O O) o place — Arvida — Quebec — Bagottville ■ — Regina — Calgary — Resolute — Dawson - — Sherbrooke — Edmonton - Scheffervll — Fredericton - — St. Johns — Halifax — Sydney - Charlottvl — The Pas — Churchill — Thunder Bay — Inuvik - Toronto — Iqaluit — Uranium City — Kamloops — Vancouver — London - — Victoria — Montreal — Whitehorse — Ottawa - — Winnipeg - Pr. Albert — Yarmouth — Pr. George - — Yellowknife — Pr. Rupert 0 100 200 300 Days log10 of Precipitation Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 4 / 49 Functional Response Models c o 2 g. 0 pointwise CI for ý; 0 01 "o O Churchill Regina /_\ / place Churchil Regina 100 200 300 0 Days 100 200 300 Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 9 / 49 Functional Response Models Assessing the fit Residuals CO "O CD place — Arvida - Quebec — Bagottville - Regina — Calgary - Resolute — Dawson - — Sherbrooke — Edmonton - Scheffervll — Fredericton - - St. Johns — Halifax - Sydney — Charlottvl - The Pas — Churchill — Thunder Bay — Inuvik — Toronto — Iqaluit - Uranium City — Kamloops Vancouver — London - - Victoria — Montreal - — Whitehorse — Ottawa — Winnipeg — Pr. Albert — Yarmouth — Pr. George - — Yellowknife — Pr. Rupert Days Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 10 / 49 Functional Response Models Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 11 / 49 Functional Response Models F-statistic To test significance, we can define a point-wise F-statistic Var(y(t)) F(t) = — i=l indicates where there is a large amount of signal relative to variance. Test over-all regression significance based on F* = maxF(t). Practical implementation is based on the permutation test. Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 12 / 49 Functional Response Models Canadian Weather b = 200, pb = 0 2.5 2.0 1.5 0 C/5 as 1 1.0 0.5 0.0 1 1 ( ) 100 200 Days 300 Koláček (SCI MUNI) M7777 Applied FDA Observed statistic pointwise 0.05 critical value maximum 0.05 critical value Fall 2019 13 / 49 Functional Response Models Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 14 / 49 Functional Response Models Canadian Weather F* = 2.47, F0*95 = 0.274 2.5 2.0 1.5 x as 1.0 0.5 0.0 50 Observed maximum F* maximum 0.05 critical value Sample maximum F* 100 Sample 150 200 Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 15 / 49 Functional Response Models Another Approach for Canadian Weather (Ramsey et al. 2005) They combined the original model y/(t) = p0(t) + Pi(t)zi(t) + 67(f), / = 1,... ,35, where • z,-(t) . . .smoothed annual temperature at the /-th station • y/(t) .. .smoothed log10 of precipitation at the /-th station with fANOVA for regions, where z,y(t) = ji{t) + otj{t) + e,y(t). Thus they considered a model yij{t) = ii{t) + aj(t) + P(t)eij(t) + eu{t), j = 1,..., 4, where e,y(t) . . .the residual temperature at the /-th station after removing the temperature effect of climate zone j by using fANOVA. Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 16 / 49 Functional Response Models Fitted Model Churchill 100 200 300 Days Precipitation estimates Jan Koláček (SCI MUNI) M7777 Applied FDA Functional Response Models Confidence Interval for parameter ß 0.050 0.025 m o.ooo -0.025 Beta Days Model parameters estimates, ß(t) Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 18 / 49 Functional Response Models Assessing the fit Residuals 0.5 H 0.0 + "O CD -0.5 A -1.0H place — Arvida - Quebec — Bagottville - Regina — Calgary - Resolute — Dawson - — Sherbrooke — Edmonton - Scheffervll — Fredericton - - St. Johns — Halifax - Sydney — Charlottvl - The Pas — Churchill — Thunder Bay — Inuvik — Toronto — Iqaluit - Uranium City — Kamloops Vancouver — London - - Victoria — Montreal - — Whitehorse — Ottawa — Winnipeg — Pr. Albert — Yarmouth — Pr. George - — Yellowknife — Pr. Rupert 100 200 Days Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 19 / 49 Functional Response Models Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 20 / 49 Functional Response Models Canadian Weather b = 200, pb = 0 o 00 2 as W 1 100 Observed statistic pointwise 0.05 critical value maximum 0.05 critical value 200 300 Days Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 21 / 49 Functional Response Models 2. Fully Functional Regression Model Let us recall the concurrent model (2) K y/(t) = + Yl #(0*1/(0 + £/(0- 7=1 We can generalize (2) for K —>> oc yi(t) = Po(t)+ p1{t,s)zi(s)ds + ei{t), (3) where • fit = {^|s < £} ... historical linear model • fit = {s unconstrained} .. full integration regression • /3i(t, s) . .. defines the dependence of y;(t) on covariate z/(s) at each time t (z,-(s) need not be defined over the same range as y/(t)) Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 22 / 49 Functional Response Models Example Canadian Weather We consider a model y/(t) = A)(t) + / £i(t, s)z/(s)cfe + e/(t), / = 1,... ,35, where • z,-(t) . . .smoothed annual temperature at the /-th station • y;(t) .. .smoothed log10 of precipitation at the /-th station • /3o(t),/3i(t, s) ...regression parameters Parameters of smoothing • "Full" basis, i.e. 65 Fourier basis for z(t),y(t) =4> overfitted model • "Restricted" basis, i.e. 21, 11 Fourier basis for z(t),y(t)f respectively quite satisfactory compromise Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 23 / 49 Functional Response Models Fitted Model - full basis Churchill 0 100 200 300 0 Days Jan Koláček (SCI MUNI) Precipitation estimates M7777 Applied FDA Functional Response Models Parameters 0 100 200 300 beta(t.s) time t [days] Model parameter estimate, /3i(t, s) Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 25 / 49 Functional Response Models ritted Model - restricted basis 0.4 0.2 O -0.2 -0.4 Churchill // 77 \\ > 0 100 200 300 0 Days Jan Koláček (SCI MUNI) Precipitation estimates M7777 Applied FDA Functional Response Models Functional Response Models Assessing the fit Residuals 0.4-r 0.2 4 M 0.0 "O 'to CD -0.2 H -0.4 H place — Arvida - Quebec — Bagottville - Regina — Calgary - Resolute — Dawson - — Sherbrooke — Edmonton - Scheffervll — Fredericton - - St. Johns — Halifax - Sydney — Charlottvl - The Pas — Churchill — Thunder Bay — Inuvik — Toronto — Iqaluit - Uranium City — Kamloops Vancouver — London - - Victoria — Montreal - — Whitehorse — Ottawa — Winnipeg — Pr. Albert — Yarmouth — Pr. George - — Yellowknife — Pr. Rupert 100 200 Days Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 28 / 49 Functional Response Models Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 29 / 49 Functional Response Models Functional Response Models Example Swedish Mortality Data • Log hazard rates calculated from tables of mortality at ages 0 throug 80 for Swedish women. • Data available for birth years 1751 through 1894. • Interest in looking at mortality trends. 0 20 40 60 80 Age Clear over-all reduction in mortality; but effects common to adjacent cohorts? Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 31 / 49 Functional Response Models We consider a functional auto-regressive model y/+i(t) = + J £i(t, s)y/(s)cfe + 67(f), / = 1,..., 143, Parameters of smoothing • 85 B-spline basis of order 6 for y(t), data smoothed with parameter A = 10-7 and M{y) = f[D*y(t)]2dt Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 32 / 49 Functional Response Models Fitted Model N tö X O) O 1810 1860 20 40 60 80 0 Age 20 40 60 80 Log hazard estimates Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 33 / 49 Functional Response Models Parameters 0 Age t [yrs] Model parameter estimate, /3i(t, s) Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 34 / 49 Functional Response Models Assessing the fit 0.2 4 0.0 4- -0.2 H Residuals 40 Days 60 Year - 1810 - 1860 80 Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 35 / 49 Functional Response Models Functional Response Models Problems to solve O Gait Data Load the variable gait from the f da package. These data consist of the angles formed by the hip and knee of each of 39 children over each child's gait cycle. • Smooth the data by Fourier bases with harmonic acceleration penalties and plot all hip and knee curves (see Figure 1). • A question of interest is the extent to which the hip angle can explain the knee angle. Let us consider a model of the form Yi(t) = p0(t) + p1(t)Xi(t) + ei(t). Estimate parameters of the model and plot them (see Figure 2). • Plot predictions for the first two boys with its bootstrap pointwise confidence bands (see Figure 3). • Asses the model by the permutation test for F-statistic and plot the result (see Figure 4). • Plot Po(t) together with mean curve for knee angle and Pi(t) together with functional R2 of the model (see Figure 5). Could we interpret it? Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 38 / 49 Problems to solve © Simulation • Using the attached script generate 30 curves x/(t) with its sample points. • Smooth them using cubic B-spline bases with GCV optimal A. • Consider a fully functional regression model y/(t) = /3o(t) + J I31(t,s)xi(s)ds + ei{t). Generate sample points for 30 curves y-,{t) with A)(t) = l + 2t/30- (t/30)2, /3i(t,s) = sin(2p/(x-y)/365) and Sj{t) ~ A/(0,10). For an example of generated curves see Figure 6. • Smooth yi by the same way as x; (see Figure 7). • Estimate parameters of the model and compare them with original (see Figure 8 for (3o(t) comparison). Try several choices of nbasis for /3's estimation. • Plot predictions for the first two curves together with originals (see Figure 9). • Plot functional R2 of the model (see Figure 10) and interpret it. Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 39 / 49 Problems to solve Jan Koláček (SCI MUNI) M7777 Applied FDA Problems to solve 75 50 0 + 0.0 + Slope 0 5 10 15 20 0 5 Time 10 15 20 Figure 2. Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 41 / 49 Problems to solve boy1 Figure Jan Koláček (SCI MUNI) M7777 Applied FDA Problems to solve Observed statistic pointwise 0.05 critical value maximum 0.05 critical value 0 5 10 15 20 Time Figure 4. Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 43 / 49 Problems to solve 40 20 0 Intercept 0.8- t" i \ \ i i i i f i / i I \ \ \ . \ \ i i 1 i I i 1 i I \ i \ \ \ i \ i \ i 0.6- 1 ; i j i / i / \ 1 I 1 1 1 l i i / if il il I i 1 i 1 i 1 i 1 i 0.4- *■» *^ ✓ V 1 i 1 i 1 i 1 \ 1 i / / / / / N \ \ N — X 1 \ I i I \ 1 \ I \ i x 0.2- 0 5 10 15 20 Time Figure Jan Koláček (SCI MUNI) M7777 Applied FDA Problems to solve 0.8 H .SS 0.4 4 O.OH 0 100 200 300 0 100 200 300 Time Figure 6. Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 45 / 49 Problems to solve Figure 7. Jan Koláček (SCI MUNI) M7777 Applied FDA Problems to solve 0 100 200 300 Time Figure 8. Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 47 / 49 Problems to solve Jan Koláček (SCI MUNI) Figure 9. M7777 Applied FDA Fall 2019 48 / 49 Problems to solve Figure 10 Jan Koláček (SCI MUNI) M7777 Applied FDA Fall 2019 49 / 49