[Gmm-commits] r177 - in pkg/causalGel: R vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Nov 5 16:23:38 CET 2020


Author: chaussep
Date: 2020-11-05 16:23:37 +0100 (Thu, 05 Nov 2020)
New Revision: 177

Modified:
   pkg/causalGel/R/causalGel.R
   pkg/causalGel/vignettes/causalGel.Rnw
   pkg/causalGel/vignettes/causalGel.pdf
Log:
added restrictLam to causalGEL and explained it in the vignette

Modified: pkg/causalGel/R/causalGel.R
===================================================================
--- pkg/causalGel/R/causalGel.R	2020-11-04 21:55:14 UTC (rev 176)
+++ pkg/causalGel/R/causalGel.R	2020-11-05 15:23:37 UTC (rev 177)
@@ -123,6 +123,24 @@
                   initTheta=initTheta, theta0=theta0,
                   lambda0=lambda0, vcov=getVcov, coefSlv=coefSlv,
                   lamSlv=lamSlv, tControl=tControl, lControl=lControl)
+    if (restrictLam)
+    {
+        spec <- modelDims(model)
+        nz <- (spec$k-1)/2
+        phi <- tail(coef(fit),nz)
+        if (length(phi) == 1)
+        {
+            phi <- matrix(c(1,phi,phi,phi),2,2)
+        } else {
+            phi <- rbind(c(1,phi), cbind(phi, diag(phi)))
+        }
+        pt <- getImpProb(fit)$pt
+        Z <- model.matrix(terms(model at X@reg), model at X@reg)
+        Y <- model.response(model at X@reg)
+        YZ <- colSums(pt*Y*Z) 
+        theta <- solve(phi, YZ)
+        fit at theta[1:(1+nz)] <- theta
+    }
     fit at call <- Call
     fit    
 }

Modified: pkg/causalGel/vignettes/causalGel.Rnw
===================================================================
--- pkg/causalGel/vignettes/causalGel.Rnw	2020-11-04 21:55:14 UTC (rev 176)
+++ pkg/causalGel/vignettes/causalGel.Rnw	2020-11-05 15:23:37 UTC (rev 177)
@@ -795,6 +795,43 @@
 
 The \textit{gelFit} method can then be applied to the restricted models.
 
+\subsection{Restricting the $\lambda$'s}
+
+For the moment conditions defined by Equations \ref{eq:13} and
+\ref{eq:8}, the analytical solution of the $\lambda$'s associated with
+the first two lines is exactly 0. However, the numerical solution is
+not exactly zero:
+
+<<>>=
+fit1 <- causalGEL(re78~treat, ~age+ed+black+hisp+re75, nsw, gelType="EL",
+                 momType="uncondBal")
+fit1 at lambda[1:2]
+@ 
+
+It may be faster and more precise to restrict these $\lambda$'s to be
+zero. If we set the option reatrictLam to TRUE, these lambda are fixed
+at 0 and the coefficients associated with the causal effect equation
+are computed by solving:
+\[
+\sum_{i=1}^n \hat{p}_i(\hat{\theta},\hat{\lambda})
+  \begin{pmatrix}
+    Y_i - \theta_1 - \tp{\theta_2} Z_i \\
+    (Y_i - \theta_1 - \tp{\theta_2} Z_i) Z_i \\
+  \end{pmatrix}\,.
+\]
+Notice that the implied probabilities do not depend on $\theta_1$ and
+$\theta_2$, which is why we can get them first and then solve for
+$\theta_1$ and $\theta_2$. We can see that the results are similar,
+but it may speedup estimation especially in simulation studies.
+
+<<>>=
+fit2 <- causalGEL(re78~treat, ~age+ed+black+hisp+re75, nsw, gelType="EL",
+                 momType="uncondBal", restrictLam=TRUE)
+rbind(coef(fit1), coef(fit2))
+rbind(fit1 at lambda, fit2 at lambda)
+@ 
+
+
 \bibliography{causal}
 
 \appendix

Modified: pkg/causalGel/vignettes/causalGel.pdf
===================================================================
(Binary files differ)



More information about the Gmm-commits mailing list