Here is an example of how to create a regression discontinuity model in R using the Rdpack
package:
379 chars14 lines
This code first loads the Rdpack
package and the example data set cars
. It then creates a scatter plot of the data to visualize any potential discontinuity in the relationship between speed and stopping distance. Finally, it uses the rdd_data
function to fit a regression discontinuity model with a cutpoint of 20 (i.e. where the discontinuity is expected to occur). The model is then summarized using the summary
function.
gistlibby LogSnag