Learn R Programming

sparsereg (version 1.2)

difference: Plotting difference in posterior estimates from a sparse regression.

Description

Function for plotting differences in posterior density estimates for separate parameters from sparse regression analysis.

Usage

difference(x,type="mode",var1=NULL,var2=NULL,plot.it=TRUE, main="Difference",xlabel="Effect", ylabel="Density")

Arguments

x
Object of class sparsereg.
type
Whether to difference the posterior mode or posterior mean. Options are "mode" and "mean".
var1, var2
Variables names for the effects to difference.
plot.it
Whether to plot the density of the difference.
main, xlabel, ylabel
Main title, x-axis label, and y-axis label.

Details

Generates a density of the estimated posterior of the difference between the effects of two variables.

References

Ratkovic, Marc and Tingley, Dustin. 2015. "Sparse Estimation with Uncertainty: Subgroup Analysis in Large Dimensional Design." Working paper.

See Also

sparsereg, plot.sparsereg, summary.sparsereg, violinplot, print.sparsereg

Examples

Run this code
## Not run: 
#  set.seed(1)
#  n<-500
#  k<-100
#  Sigma<-diag(k)
#  Sigma[Sigma==0]<-.5
#  X<-mvrnorm(n,mu=rep(0,k),Sigma=Sigma)
#  y.true<-3+X[,2]*2+X[,3]*(-3)
#  y<-y.true+rnorm(n)
# 
# 
# 
# ##Fit a linear model with five covariates.
#  s1<-sparsereg(y,X[,1:5])
#  difference(s1,var1=1,var2=2)
# ## End(Not run)

Run the code above in your browser using DataLab