test.CausalANOVA: Estimating the AMEs and AMIEs after Regularization with the...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/test.CausalANOVA.R

Description

test.CausalANOVA estimates the AMEs and AMIEs with confidence intervals after regularization with CausalANOVAfunction.

Usage

1
2
3
4
5
6
7
8
test.CausalANOVA(
  fit,
  newdata,
  collapse.level = TRUE,
  diff = FALSE,
  pair.id = NULL,
  cluster = NULL
)

Arguments

fit

The output from CausalANOAV function.

newdata

A data frame to use for re-estimating the AMEs and AMIEs with confidence intervals.

collapse.level

A logical indicating whether to collapse insignificant levels within factors as suggested by the CausalANOVA output users provide.

diff

A logical indicating whether the outcome is the choice between a pair. If diff=TRUE, pair.id should specify a pair of comparison. Default is FALSE.

pair.id

(optional).Unique identifiers for each pair of comparison. This option is used when diff=TRUE.

cluster

Unique identifies with which cluster standard errors are computed.

Details

See Details in CausalANOVA.

Value

fit

The output of class CausalANOVA.

Author(s)

Naoki Egami and Kosuke Imai.

References

Egami, Naoki and Kosuke Imai. 2019. Causal Interaction in Factorial Experiments: Application to Conjoint Analysis, Journal of the American Statistical Association. http://imai.fas.harvard.edu/research/files/int.pdf

Lim, M. and Hastie, T. 2015. Learning interactions via hierarchical group-lasso regularization. Journal of Computational and Graphical Statistics 24, 3, 627–654.

Post, J. B. and Bondell, H. D. 2013. “Factor selection and structural identification in the interaction anova model.” Biometrics 69, 1, 70–79.

See Also

CausalANOVA.

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
## ####################################### 
## With Screening and Collapsing
## #######################################
data(Carlson)
## Specify the order of each factor
Carlson$newRecordF<- factor(Carlson$newRecordF,ordered=TRUE,
                            levels=c("YesLC", "YesDis","YesMP",
                                     "noLC","noDis","noMP","noBusi"))
Carlson$promise <- factor(Carlson$promise,ordered=TRUE,levels=c("jobs","clinic","education"))
Carlson$coeth_voting <- factor(Carlson$coeth_voting,ordered=FALSE,levels=c("0","1"))
Carlson$relevantdegree <- factor(Carlson$relevantdegree,ordered=FALSE,levels=c("0","1"))

## Sample Splitting
train.ind <- sample(unique(Carlson$respcodeS), 272, replace=FALSE)
test.ind <- setdiff(unique(Carlson$respcodeS), train.ind)
Carlson.train <- Carlson[is.element(Carlson$respcodeS,train.ind), ]
Carlson.test <- Carlson[is.element(Carlson$respcodeS,test.ind), ]
 
#################### AMEs and two-way AMIEs ####################
fit.r2 <- CausalANOVA(formula=won ~ newRecordF + promise + coeth_voting + relevantdegree,
                      data=Carlson.train, pair.id=Carlson.train$contestresp,diff=TRUE,
                      screen=TRUE, collapse=TRUE,
                      cluster=Carlson.train$respcodeS, nway=2)
summary(fit.r2)

## refit with test.CausalANOVA
fit.r2.new <- test.CausalANOVA(fit.r2, newdata=Carlson.test, diff=TRUE,
                               pair.id=Carlson.test$contestresp, cluster=Carlson.test$respcodeS)

summary(fit.r2.new)
plot(fit.r2.new)
plot(fit.r2.new, type="ConditionalEffect", fac.name=c("newRecordF","coeth_voting"))
ConditionalEffect(fit.r2.new, treat.fac="newRecordF", cond.fac="coeth_voting")

FindIt documentation built on Nov. 21, 2019, 1:07 a.m.