[R] Plot MArginal distribution in the correct place
Pedro páramo
percentil101 at gmail.com
Thu Jun 8 19:50:00 CEST 2017
Many thanks Jim.
What I,m trying to show with the fhist plot is the empirical distribution
of the values of the left plot simulation.
You say:
However, I don't think that this plot illustrates quite what you think it
does.
Can you give me a clue to try to illustrate better if it is not showing
what I believe it shows a better way to show it?
Many thanks in advance.
El 7 jun. 2017 12:08, "Jim Lemon" <drjimlemon at gmail.com> escribió:
Hi Pedro,
As a one-off, you just shove the coordinates around a bit:
par(mar=c(11,0,6,6))
barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray",
ylim=c(0,24))
However, I don't think that this plot illustrates quite what you think it
does.
Jim
On Wed, Jun 7, 2017 at 4:01 PM, Pedro páramo <percentil101 at gmail.com> wrote:
> Please, I'm trying to put the right plot higher and centered on the left
> values but I don't achive.
>
> I would appreciate so much your help
>
> El 6 jun. 2017 22:37, "Pedro páramo" <percentil101 at gmail.com> escribió:
>
>> Hi all,
>>
>> I have this code, but the marginal distribution plot doesn´t appear
>> aligned with the left plot.
>>
>>
>> I think could be something about layout or par() mar.
>>
>> The code was programmed by me time ago.
>>
>> Can anyone help me to get the marginal distribution on the center (more
>> higher centered)
>>
>> id.txt
>>
>> Could have this code:
>>
>> 05/01/2016;9335,200195
>> 06/01/2016;9197,400391
>> 07/01/2016;9059,299805
>> 08/01/2016;8909,200195
>> 11/01/2016;8886,099609
>> 12/01/2016;8915,400391
>> 13/01/2016;8934,5
>> 14/01/2016;8787,700195
>> 15/01/2016;8543,599609
>> 18/01/2016;8469,299805
>> 19/01/2016;8554,900391
>> 20/01/2016;8281,400391
>> 21/01/2016;8444,200195
>> 22/01/2016;8722,900391
>> 25/01/2016;8567,700195
>> 26/01/2016;8692,5
>> 27/01/2016;8741
>>
>>
>>
>> g<-read.table("id.txt", col.names=c("Dateh","LAST"), sep=";", dec=",")
>>
>> N=5000
>> B=24
>> ghy<-nrow(g)
>> r<-as.numeric(as.character(g$LAST[ghy]))
>>
>>
>> nf<-layout(matrix(c(1,1,1,1,2,2),1,6,byrow=TRUE))
>>
>> par(mar=c(6,6,6,0.5))
>>
>> A<-matrix(1:B,B,N);
>>
>>
>>
>> sigma<-0.06;
>>
>>
>>
>> mu<-0.00;
>>
>>
>> Z<-r*exp((mu-0.5*((sigma)^2)*A) +sigma*(sqrt(A))*matrix( rnorm(N*B,0,1),
>> B, N))
>>
>> real1<-g$LAST[1:nrow(g)]
>>
>> real2<-matrix(NA,nrow(g),N-1)
>>
>> real<-cbind(real1,real2)
>>
>>
>>
>>
>> Po<-r*matrix(1,1,N);
>>
>>
>>
>> Sim<-rbind(Po,Z)
>> Simulation<-rbind(real,Z)
>>
>>
>>
>>
>>
>>
>> par(mar=c(10,6,6,6))
>> matplot(Simulation,type="l",ylim=c(0,40000))
>>
>> abline(h = 8000, lwd = 2, col = "black")
>>
>> abline(h = 12000, lwd = 2, col = "black")
>> title("Dinamic Montecarlo Simulation 2 years ahead",font=4)
>>
>> fhist<-hist(Simulation,plot=FALSE)
>> par(mar=c(6,0,6,6))
>> barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray")
>> grid()
>> title("Marginal Distribution",font=4)
>>
>>
>> rect(0, 0, 0, 0) # transparent
>>
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help
mailing list