Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add p values for correlation coefficients plotted using splom in lattice?
    primarykey
    data
    text
    <p>I am making a scatterplot matrix using lattice and plotting the correlation coefficients of 12 variables in the upper half of the panel. I would also like to add the p values beneath the correlation coeffiecients or stars indicating their level of significance. Here is my R code. How can I achieve this? Many thanks in advance!</p> <p>Here is a sample of my data</p> <pre><code>d.corr1 = structure(list(maxt1.res = c(-0.944678376630112, 0.324463929632583, -1.18820341118942, -0.656600399095673, 0.332432965913295, 0.696656683837386 ), maxt2.res = c(1.81878373188327, -0.437581385609662, 0.305933316224282, -3.20946216261864, 0.629812177862245, -1.49044366233353), maxt3.res = c(-1.21422295698813, -1.31516252550763, 0.570370111383564, 1.73177495368256, 2.18742200139099, 0.413531254505875), mint1.res = c(0.783488332204165, 0.35387082927864, -0.528584845400234, 0.772682308165534, 0.421127289975828, 1.06059010003109 ), mint2.res = c(0.262876147753049, 0.588802881606123, 0.745673830291112, -1.22383100619312, -1.01594162784602, -0.135018034667641), mint3.res = c(0.283732674541107, -0.406567031719476, 0.390198644741853, 0.860359703924238, 1.27865614582901, 0.346477970454206), sr1.res = c(1.7258974480523, -1.71718783477085, 3.98573602228491, -4.42153098079411, 0.602511156003456, -3.07683756735513 ), sr2.res = c(9.98631829246284, -6.91757809846195, 0.418977023594041, -6.10811634134865, 14.6495418067316, 2.44365146778955), sr3.res = c(-3.8809447886743, 2.35230122374257, 2.8673756880306, 7.1449786041902, 2.07480997224678, 4.93316979213985), rain1.res = c(0.112986181584307, 0.0445969189874017, -0.446757191502526, 1.76152475011467, -0.395540856161192, -0.175756810329735 ), rain2.res = c(-0.645121126413379, 1.74415111794381, -0.122876137090066, 1.68048850848576, -0.570490345329031, 0.00308540146622738), rain3.res = c(-0.202762644577954, 0.0528174267822909, -0.0616752465852931, -0.167769364680304, -0.152822027502996, -0.139253335052929)), .Names = c("maxt1.res", "maxt2.res", "maxt3.res", "mint1.res", "mint2.res", "mint3.res", "sr1.res", "sr2.res", "sr3.res", "rain1.res", "rain2.res", "rain3.res" ), row.names = c(NA, 6L), class = "data.frame") attach(d.corr1) library(lattice) library(RColorBrewer) splom(~d.corr1[seq(1:12)], lower.panel = panel.splom, upper.panel = function(x, y, ...) { panel.fill(col = brewer.pal(9, "RdBu")[ round(cor(x, y) * 4 + 5)]) cpl &lt;- current.panel.limits() panel.text(mean(cpl$xlim), mean(cpl$ylim), round(cor(x, y),2), font=2) }, scales = list(x = list( draw = TRUE, cex=0.1)), type = c("g", "p", "smooth"),layout = c(1, 1), pscales=0, pch=".", main="correlation between the weather variables after removing district F.E and yearly trends") dev.off() detach(d.corr1) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload