0

I want to test my dataset for normal distribution. I get the same results with every dataset. What is wrong? why do the results of the diverse test for normal distribution of different temperature raster stacks have the same values (p-value nearly zero p-value< 2.2e-16?)

library(raster)
library(rgdal)
library(nortest)

# load files
files <- list.files("C:/Users/cathe/Documents/Cropped_raster_Gewässerläufe", include.dirs = F, full.names = T)


#stack raster
rasterstack <- stack(lapply(files, raster))
r <- rasterstack
r[] <- 1:length(r)

## crop and mask
r2 <- crop(r, extent(shp))
r3 <- mask(r2, shp)


rc <- crop(rasterstack, extent(r3))
rcm <- mask(rc, shp)

as.vector(rcm)
x <- as.vector(rcm)

nortest::ad.test(x) 

cvm.test(x)

ks.test(x, "pnorm", mean(x, na.rm=TRUE), sd(x, na.rm=TRUE))  

#RESULTS

Anderson-Darling normality test

data: x A = 2422.3, p-value < 2.2e-16

cvm.test(x)

Cramer-von Mises normality test

data: x W = 416.03, p-value = 7.37e-10

Warnmeldung: In cvm.test(x) : p-value is smaller than 7.37e-10, cannot be computed more accurately

ks.test(x, "pnorm", mean(x, na.rm=TRUE), sd(x, na.rm=TRUE))

One-sample Kolmogorov-Smirnov test

data: x D = 0.048852, p-value < 2.2e-16 alternative hypothesis: two-sided

enter image description here

4
  • 1
    We can't help much without some information about your data since we can't run your code or know anything at all about your data. We don't know how many files you have, how many layers they are etc. Please try and make your question as simple as possible - so if you are finding that all your answers are the same, show us two things being the same and get rid of all the loops and processing concerned with the general case.
    – Spacedman
    Aug 7 '20 at 20:36
  • 1
    I cannot tell from your code what you are doing here so, cannot provide any trouble shooting but, if you are trying to evaluate if an entire raster (all cell values) is normal then you will almost certainly find that this is the case every time. Raster data tends to adhere to the rule of large numbers and converges on a global Gaussian distribution thus, making this not the most sensible test. If you are in doubt, take a look at 'plot(density(x[]))' for single raster. If you have a stack index a single raster using x[[1]][] Aug 7 '20 at 21:08
  • @spacedman: i have 56 layers with landsurfacetemperatures. i stacked and cropped them. after that i run these tests to check if they are normal distributed. in the results p-values are always the same. the A value in the anderson darling test is different. Aug 8 '20 at 7:53
  • @jeffrey evans: thanks. i will tesrt it. there are a lot of NA in my data. maybe this is the reason why the data are not normal distributed? Aug 8 '20 at 8:01
3

Aside from how the rule of large numbers come into play in that you no longer are working with a sample but rather a population. Conceptually, here is another good example on why what you are trying is not a stable approach.

I am simulating a very skewed distribution. As you will see, the mean and standard deviations are rather meaningless (as central tendency or spread) in relation to the underlying distribution thus, the measures of normality are also not correct.

library(raster)
r <- raster(nrow=1000,ncol=1000)
  r[] <- rbeta(ncell(r),1,8)

plot(density(r[]))
  abline(v=mean(r[],na.rm=TRUE))
  abline(v=mean(r[],na.rm=TRUE) - sd(r[],na.rm=TRUE),col="red")
  abline(v=mean(r[],na.rm=TRUE) + sd(r[],na.rm=TRUE),col="red")

ks.test(r[], "pnorm", mean(r[], na.rm=TRUE), sd(r[], na.rm=TRUE))
goftest::cvm.test(r[])

raster pdf

1
  • I did the test with a single layer. The results from the Anderson-Darling normality test show still the same p-value data: x A = 64.347, p-value < 2.2e-16 Aug 8 '20 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.