2016-05-16 18 views
2

Ich persönlich mag die Auge Visualisierung von Cumming Katze, die eine Stichprobenverteilung über eine Punktschätzung überlagert: enter image description hereSuperimpose posteriori Verteilung auf mittleres wie Augen Visualisierung Katze aus Cumming

Ich würde auch mit der hinteren Verteilung dies zu tun, dass wird durch die Scripts von Kruschke (2015) erhalten:

plotMCMC(mcmcCoda , data=myData , 
     compValMu=100.0 , ropeMu=c(99.0,101.0) , 
     compValSigma=15.0 , ropeSigma=c(14,16) , 
     compValEff=0.0 , ropeEff=c(-0.1,0.1) , 
     pairsPlot=TRUE , showCurve=FALSE , 
     saveName=fileNameRoot , saveType=graphFileType) 

# Set up window and layout: 


openGraph(width=6.0,height=8.0*3/5) 
    layout(matrix(c(2,3,5, 1,4,6) , nrow=3, byrow=FALSE)) 
    par(mar=c(3.5,3.5,2.5,0.5) , mgp=c(2.25,0.7,0)) 
    # Select thinned steps in chain for plotting of posterior predictive  curves: 
    nCurvesToPlot = 20 
    stepIdxVec = seq(1 , chainLength , floor(chainLength/nCurvesToPlot)) 
    # Compute limits for plots of data with posterior pred. distributions 
    y = data 
    xLim = c(min(y)-0.1*(max(y)-min(y)) , max(y)+0.1*(max(y)-min(y))) 
    xBreaks = seq(xLim[1] , xLim[2] , 
       length=ceiling((xLim[2]-xLim[1])/(sd(y)/4))) 
    histInfo = hist(y,breaks=xBreaks,plot=FALSE) 
    yMax = 1.2 * max(histInfo$density) 
    xVec = seq(xLim[1] , xLim[2] , length=501) 
    #----------------------------------------------------------------------------- 
    # Plot data y and smattering of posterior predictive curves: 
    histInfo = hist(y , prob=TRUE , xlim=xLim , ylim=c(0,yMax) , breaks=xBreaks, 
        col="red2" , border="white" , xlab="y" , ylab="" , 
        yaxt="n" , cex.lab=1.5 , main="Data w. Post. Pred.") 
    for (stepIdx in 1:length(stepIdxVec)) { 
    lines(xVec, dt((xVec-mu[stepIdxVec[stepIdx]])/sigma[stepIdxVec[stepIdx]], 
        df=nu[stepIdxVec[stepIdx]])/sigma[stepIdxVec[stepIdx]] , 
      type="l" , col="skyblue" , lwd=1) 
    } 
    text(max(xVec) , yMax , bquote(N==.(length(y))) , adj=c(1.1,1.1)) 
    #----------------------------------------------------------------------------- 
    histInfo = plotPost(mu , cex.lab = 1.75 , showCurve=showCurve , 
         compVal=compValMu , ROPE=ropeMu , 
         xlab=bquote(mu) , main=paste("Mean") , 
         col="skyblue") 
    #----------------------------------------------------------------------------- 
    histInfo = plotPost(sigma , cex.lab=1.75 , showCurve=showCurve , 
         compVal=compValSigma , ROPE=ropeSigma , cenTend="mode" , 
         xlab=bquote(sigma) , main=paste("Scale") , 
         col="skyblue") 
    #----------------------------------------------------------------------------- 
    effectSize = (mu - compValMu)/sigma 
    histInfo = plotPost(effectSize , compVal=compValEff , ROPE=ropeEff , 
         showCurve=showCurve , cenTend="mode" , 
         xlab=bquote((mu - .(compValMu))/sigma), 
         cex.lab=1.75 , main="Effect Size" , 
         col="skyblue") 
    #----------------------------------------------------------------------------- 
    postInfo = plotPost(log10(nu) , col="skyblue" , # breaks=30 , 
         showCurve=showCurve , 
         xlab=bquote("log10("*nu*")") , cex.lab = 1.75 , 
         cenTend="mode" , 
         main="Normality") # (<0.7 suggests kurtosis) 

die wie folgt für die mittlere enter image description here

am Ende aussieht, ist es möglich, das Histogramm auf dem m zu überlagern Ean wie Cumming macht es?

Antwort

0

Ich habe eine Funktion namens plotViolin für eine andere Anwendung erstellt, die tun sollte, was Sie wollen, oder zumindest leicht an die Besonderheiten Ihrer Anwendung angepasst werden kann. Sie können die Funktion etwa auf halbem Weg nach unten des R-Skripts finden, das hier verlinkt ist: https://osf.io/wt4vf/

+0

In Übereinstimmung mit dieser Antwort hat 'ggplot2' eine' geom_violine', die dies tut. –