Skip to content

Commit

Permalink
version 0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Haitian Xie authored and cran-robot committed Nov 27, 2023
1 parent d614756 commit 58465b7
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 5 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: NonlinearRDD
Title: Nonlinear Regression Discontinuity Design
Version: 0.0.3
Version: 0.0.4
Authors@R: c(person("Haitian", "Xie", role = c("aut", "cre","cph"),
email = "xht@gsm.pku.edu.cn"))
Description: Estimation of the possibly nonlinear and non separable structural function in regression discontinuity designs with a continuous treatment variable. The method is based on Xie (2022) <arXiv:2204.08168>.
Expand All @@ -9,8 +9,8 @@ Encoding: UTF-8
RoxygenNote: 7.2.3
Imports: quantreg, Rfast, rdrobust, rddensity, lpdensity, lpcde, copula
NeedsCompilation: no
Packaged: 2023-10-27 02:15:37 UTC; haitianxie
Packaged: 2023-11-26 11:27:21 UTC; haitianxie
Author: Haitian Xie [aut, cre, cph]
Maintainer: Haitian Xie <xht@gsm.pku.edu.cn>
Repository: CRAN
Date/Publication: 2023-10-27 07:50:05 UTC
Date/Publication: 2023-11-26 11:50:02 UTC
6 changes: 4 additions & 2 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
61596f92bf7fd40d9ae0d2edca0d58f5 *DESCRIPTION
71f3e775aa717766d318c32b04a885ec *NAMESPACE
f062fe03390aaa7faedde3eab6a4aa28 *DESCRIPTION
581488d0f18b908b8fee95831211dcb2 *NAMESPACE
95f0e1bc3ab57c6c59078fc1b170b6b6 *R/D.R
17ebcad795a34740436280dcb49115b8 *R/K_Y.R
cedf71be42584833d60bb5971e695442 *R/NRDD.R
Expand All @@ -9,6 +9,7 @@ da16809f41d527fa46508b8b67fa3b28 *R/g.R
891b9dc3d211807c59deb5628fc10875 *R/k.R
f5186f2020d471015cf7b63995214ed2 *R/nrdbw.R
351bacc881c5db882af1e5b99c845758 *R/nrddgp.R
308968b671a7c99dbf8c1d3ad473ef31 *R/nrdse.R
5a01d2f19db581efec33d4501b8f64ac *man/D.Rd
012f9276981d49e6ea73d75ce2bffca6 *man/K_Y.Rd
fb6e17f1084cddb215657568c5d2852d *man/NRDD.Rd
Expand All @@ -18,3 +19,4 @@ dd261f73230830eae1554c6a4d890bdf *man/g.Rd
c3d77b7401d35b099e471205515504c7 *man/k.Rd
2165745fb0e872c3fe9239d9a3e0645d *man/nrdbw.Rd
2238c383c344cea53af61b439e6b8939 *man/nrddgp.Rd
ef218c94e2be7aef2a07a0c41d9a8ce3 *man/nrdse.Rd
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
export(NRDD)
export(nrdbw)
export(nrddgp)
export(nrdse)
41 changes: 41 additions & 0 deletions R/nrdse.R
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)
}
28 changes: 28 additions & 0 deletions man/nrdse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 58465b7

Please sign in to comment.