getRes.CFA.Rd
get a particular parameter of interest from a cfa object
getRes.CFA(cfaobj, fun, se = T, ...)
cfaobj | a CFA object |
---|---|
fun | a function to apply for every value of the treatment in the cfaobj. The ccfa package provides several built-in functions: E (for expected value as a function of the treatment variable), Var (for the variance as a function of the treatment variable), IQR (the interquantile range as a function of the treatment variable), pov (the fraction of observations with outcomes below some threshold, as a function of the treatment variable), rich (the fraction of observations with outcomes above some threshold, as a function of the treatment variable), but other user-defined functions can be written. The requirement is that they need to take in an ecdf object and output a scalar result. |
se | whether or not to compute standard errors |
... | can pass additional arguments to fun using this argument |
CFASE object
data(igm) tvals <- seq(10,12,length.out=8) yvals <- seq(quantile(igm$lcfincome, .05), quantile(igm$lcfincome, .95), length.out=50) ## obtain counterfactual results cfaresults <- cfa(lcfincome ~ lfincome, tvals=tvals, yvals=yvals, data=igm, se=FALSE)#> Warning: the condition has length > 1 and only the first element will be used#> Warning: the condition has length > 1 and only the first element will be used#> Warning: the condition has length > 1 and only the first element will be used#> Warning: the condition has length > 1 and only the first element will be used#> Warning: the condition has length > 1 and only the first element will be used#> Warning: the condition has length > 1 and only the first element will be used#> Warning: the condition has length > 1 and only the first element will be used#> Warning: the condition has length > 1 and only the first element will be used## get the average outcome (lfincome) as a function of the treatment ## variable (lfincome) getRes.CFA(cfaresults, E, se=FALSE)#> $tvals #> [1] 10.00000 10.28571 10.57143 10.85714 11.14286 11.42857 11.71429 12.00000 #> #> $est #> [1] 10.40190 10.57407 10.71978 10.87070 10.99776 11.10878 11.23325 11.34513 #> #> $se #> NULL #> #> $c #> [1] 1.96 #> #> attr(,"class") #> [1] "CFASE"## get the variance of the outcomes as a function of the treatment ## variable getRes.CFA(cfaresults, Var, se=FALSE)#> $tvals #> [1] 10.00000 10.28571 10.57143 10.85714 11.14286 11.42857 11.71429 12.00000 #> #> $est #> [1] 0.3260844 0.3188939 0.2787215 0.2592972 0.2271978 0.2113896 0.1917693 #> [8] 0.1809423 #> #> $se #> NULL #> #> $c #> [1] 1.96 #> #> attr(,"class") #> [1] "CFASE"## get the inter-quantile range of outcomes as a function of the ## treatment variable getRes.CFA(cfaresults, IQR, se=FALSE, t1=0.9, t2=0.1)#> $tvals #> [1] 10.00000 10.28571 10.57143 10.85714 11.14286 11.42857 11.71429 12.00000 #> #> $est #> [1] 1.459724 1.588524 1.545591 1.416791 1.287992 1.245059 1.116260 1.030394 #> #> $se #> NULL #> #> $c #> [1] 1.96 #> #> attr(,"class") #> [1] "CFASE"