CI: Estimating a linear combination of treatment effects and...

Description Usage Arguments Details Value See Also Examples

View source: R/CI.R

Description

This function is used for estimating a linear combination of treatment effects and its confidence regions in functional data analysis. It can be used for testing for the significance of the linear comination of effects.

Usage

1
CI(fit, L, alpha)

Arguments

fit

an object of output obtained by function "fanova".

L

a numeric contrast vector corresponding to the design matrix in "fanova", which specifies the linear combination of the parameters of interest. Users can use the design matrix output from the function fanova( ), to idenfity the value of L. See the example part for details.

alpha

a positive small number between 0 and 1. 1-alpha gives the confidence level. In default, alpha = 0.05.

Details

We can estimate a linear combination of treatment effects and its confidence regions with the function ``CI (fit, L …)", where fit is the output from "fanova (…)", and L is a contrast vector under the Fanova model specifying the linear combination of the parameters of interest. The parameter estimation \hat{β} (see β from the example in the detail part) is implemented by the function "fanova ( …)" in our package. By specifying the linear vector L, the estimated linear combination of effects at time t is:

\hat{τ}(t) = L\otimes B'(t) \hat{β},

where “\otimes" is the Kronecker product, and B(t) = (B_{d,1}(t), B_{d,2}(t), …, B_{d,K}(t))'. Here d is the order of the B-spline basis function and K is the rank of the B-spline basis function. More details can be found in the help documentation for function “fanova".

In the example part, we study the relationship between the plant sizes and treatments using functional data models. Let y_i(t) be the size of the ith plant measured at time t, where i = 1,…,9. We treat genotype and block as fixed effects. There are 3 different genotypes (1,2,3) and 3 blocks (1,2,3) in this study. We can use G_i= (G_{ik})_{k=2}^{3} as the categorical indicator of the ith plant genotype. Specifically, G_{ik} is set to one if the plant has the kth genotype; otherwise, G_{ik}=0, and the 1st genotype is set as the baseline. Similarly, P_i = (P_{ik})_{k=2}^3 is defined to represent the block that the ith plant belongs to, and the first block is set as the baseline. The model can be written as:

y_i(t_{ij}) = μ(t_{ij})+ ∑_{k=2}^{3} G_{ik} g_k(t_{ij})+∑_{k=2}^3 P_{ik}p_k(t_{ij}) +ε_i(t_{ij}),

where μ(t) is the growth function of the plant with the 1st genotype (Genotype 1) from the 1st block, g_k(t)s are the genotype effect functions, p_k(t)s are the fixed block effect functions, and the residuals ε_i(t)s are modeled by independent random processes with mean zeros. Use B-spline to model μ(t), g_k(t) and p_k(t) as μ(t) = ∑_{v=1}^{K}β_{μ,v}B_{d,v}(t) , g_{k}(t) = ∑_{v=1}^{K}β_{g_k,v}B_{d,v}(t), p_{k}(t) = ∑_{v=1}^{K}β_{p_k,v}B_{d,v}(t), where \{B_{d,v}(t)\}_{v = 1}^{K} are order d B-spline basis functions, and \{β_{μ,v}\}_{v = 1}^{K}, \{β_{g_k,v}\}_{v = 1}^{K} and \{β_{p_k,v}\}_{v = 1}^{K} are the corresponding coefficients. Hence, in this example, the B-spline coefficients, β = (β_{μ}', β_{g2}', β_{g3}', β_{p2}', β_{p3}')', where β_{μ} = (β_{μ,1}, … ,β_{μ,K})', β_{g2} = (β_{g2,1}, … ,β_{g2,K})', ... , etc.

Using the function CI (…), we can estimate a linear combination of treatment effects, including estimating the average growth curve of a particular genotype over all the blocks. In the example part, we use this function to estimate the average growth curve of Genotype 1 over three blocks.

Value

trt

a t by 1 vector giving the estimated linear combination of coefficients at t observation time points.

ub

A t by 1 vector which indicates the upper bound of the (1-alpha) confidence band at different time points.

lb

A t by 1 vector which indicates the lower bound of the (1-alpha) confidence band at different time points.

See Also

fanova

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#load the data
data_new = read.csv(system.file("extdata","data.csv",
                                 package = "implant", mustWork = TRUE))
#The first three columns of data_new refer to the original position of the observations from the
#original dataset, genotype and block, respectively
Y = data_new[,-c(1:3)]
#This step is to factorize each factor
Genotype = as.factor(data_new$Genotype)
Block = as.factor(data_new$Block)
X = data.frame(Genotype,Block)
formula = "~ Genotype + Block"
tt = seq(from = 0, to = 44,by = 2)
#fit the model
fit = fanova(Y.na.mat = Y, X = X, tt = tt, formula, K.int = 6, order = 4, lower = -10, upper = 15)
fit$design_mat
> fit$design_mat
       (Intercept) Genotype2  Genotype  Block2  Block3
1           1          0           1      0      0
2           1          0           0      0      0
3           1          1           0      0      0
4           1          1           0      1      0
5           1          0           1      1      0
6           1          0           0      1      0
7           1          0           1      0      1
8           1          1           0      0      1
9           1          0           0      0      1
#We want to estimate the growth curve of genotype 1 averaging over three blocks,
#that is, we are interested in the 1st, the 4th and the 5th column of the design matrix.
#Therefore, we can define:
L1 = c(1, 0, 0, 1/3, 1/3)
ci1 = CI(fit = fit, L = L1, alpha = 0.05)
plot(tt,ci1$trt,type = "l")
lines(tt,ci1$lb, col = "blue")
lines(tt,ci1$ub, col = "blue")

rwang14/implant documentation built on Sept. 6, 2020, 3:21 a.m.