faris
faris

Reputation: 51

how to find p-values from the correlation raster

I would like to calculate p-value and merge it with the correlation raster map but I have no idea how to calculate raster p-value and marge it with the correlation raster map. My R programming code is shown as below

 r.stack <- stack
(y13,y14,y15,y16,y17,y18,y19,y20,y21,y22,y23,y24,y1,y2,y3,y4,y5,y6,y7,y8,y9,y10,y11,y12)
z1 <- r.stack[[1:12]]
z2 <- r.stack[[13:24]]
z3 <- stack(z1,z2)


r <- calc(z3, fun=function(x) cor(x[1:12], x[13:24], method='pearson'))

plot(r,col=colorRampPalette(c("red", "yellow", "blue"))(255))

# I have no idea how to get P- value from the Correlation #

while y1 to y12 are Drought (SEPI) raster image and y 13 to 24 are NDVI raster image

Thank you in advance for any help.....

Upvotes: 0

Views: 732

Answers (1)

faris
faris

Reputation: 51

I have got the answer already and hopefully it may help other people too. I the corLocal intend of corr . The code is shown below,

r.stack <- stack (y13,y14,y15,y16,y17,y18,y19,y20,y21,y22,y23,y24 ,y3, y4,y5,y6, y7,y8,y9,y10,y11,y12,y1,y2)

z1 <- r.stack[[1:12]] z2 <- r.stack[[13:24]] z3 <- stack(z1,z2)

r <- corLocal(r.stack[[1:12]], r.stack[[13:24]], test=TRUE ) plot(r) # r and p-value map will be shown

# only correlation cells where the p-value < 0.05 will be ommited

r.mask <- mask(r[[1]], r[[2]] < 0.05, maskvalue=FALSE)

plot(r.mask)

Upvotes: 2

Related Questions