-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d614756
commit 58465b7
Showing
5 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
export(NRDD) | ||
export(nrdbw) | ||
export(nrddgp) | ||
export(nrdse) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#' Standard error for nonlinear RDD | ||
#' | ||
#' Calculates the standard error for the semiparametric estimates in the nonlinear structural function in RDD | ||
#' | ||
#' @param df Data frame whose columns are outcome Y, treatment Treat, and running variable R, respectively. | ||
#' @param gamma Value of the parameters in the structural function. | ||
#' @param t Treatment value for calculating the marginal effect. | ||
#' @param e Value of the error term for calculating the marginal effect. | ||
#' @examples | ||
#' \donttest{ | ||
#' n <- 500 | ||
#' set.seed(123) | ||
#' data <- nrddgp(n) | ||
#' nrdse(data,c(1,1,1),.5,.5) | ||
#' } | ||
#' @export | ||
|
||
nrdse <- function(df,gamma,t,e){ | ||
Y <- df[,1] | ||
Treat <- df[,2] | ||
R <- df[,3] | ||
n <- nrow(df) | ||
R0 <- R[R<0] | ||
R1 <- R[R>0] | ||
T0 <- Treat[R<0] | ||
T1 <- Treat[R>0] | ||
Y0 <- Y[R<0] | ||
Y1 <- Y[R>0] | ||
df.below <- df[df[,3]<0,] | ||
df.above <- df[df[,3]>0,] | ||
m1 <- lpcde::lpcde(T0,Y0) | ||
est1 <- m1$Estimate[,3] | ||
m0 <- lpcde::lpcde(T1,Y1) | ||
est0 <- m0$Estimate[,3] | ||
fR <- rddensity::rddensity(df[,3])$hat[[1]] | ||
se <- 10 *sum((est1 - est0)^2) / fR | ||
value <- c(1,t,e) | ||
M <- outer(value,value) | ||
se <- se * M | ||
return(se) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.