look at dev.new() to specify plot window size
and then ?layout to specify number and size of each plot in the window
Jiaqi.Zhang wrote> Hi, all,
>
> I am working on the following code to learn how to plot graphs together. I
> used the par(mfrow=c(1,3)) function to try to put all three plot() graphs
> together. But it always fail without any error message? Can anybody help
> me out?
>
> ################################################################
> ###### Synthetic Data Generation
> ################################################################
>
> n = 500
> x1 = rnorm(n, 1, 100)
> x2 = rnorm(n, 10, 100)
> x3 = rnorm(n, 5, 1)
> x4 = rnorm(n, 10, 10)
> x5 = rbinom(n, 1, .4)
> x6 = rnorm(n, 30, 5)
> treatment = rbinom(n, 1, .15)
> data = cbind(x1,x2,x3,x4,x5,x6, treatment)
> dim(data)
>
> ################################################################
> ###### Propensity score matching
> ###### nearest neighbor matching (1:1)
> ################################################################
>
> require(MatchIt)
> # data1 is the subset of data with only the selected variables mentioned
> below
> data1 =
data[,c("x1","x2","x3","x4","x5","x6",
"treatment")]
> # getting rid of missing values (below)
> data1 = as.data.frame(na.omit(data1))
> # matching is performed below using propensity scores given the covariates
> mentioned below
> m.out = matchit(treatment~x1+x2+x3+x4+x5+x6,method="nearest",
data=data1,
> ratio = 1)
> # check the sample sizes (below)
> m.out
> # Final matched data saved as final_data
> final_data = match.data(m.out)
> # (here distance = propensity score)
> # check balance (below)
> par(mfrow=c(1,3))
> plot(m.out) # covariate balance
> plot(m.out, type = "jitter") # propensity score locations
> plot(m.out, type = "hist") #check matched treated vs matched
control
>
> I hope to put
> plot(m.out), plot(m.out, type = "jitter"), and plot(m.out, type =
"hist")
> in one graph.
--
View this message in context:
http://r.789695.n4.nabble.com/How-can-I-plot-graphs-together-tp4658612p4658742.html
Sent from the R help mailing list archive at Nabble.com.