Created
February 8, 2018 02:00
-
-
Save fernandojunior/843b49556c780a40550e2193234baaf9 to your computer and use it in GitHub Desktop.
normality measures in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages("nortest") | |
# install and import package needed for normality measures | |
install.packages("moments") | |
normality_measuares <- function (data) { | |
require("moments") | |
print(paste("skewness=", skewness(data), sep="")) | |
print(paste("kurtosis=", kurtosis(data), sep="")) | |
} | |
normality_tests <- function (data) { | |
library(nortest) | |
print(shapiro.test(data)) # Shapiro-Wilk normality test | |
print(ad.test(data)) # Anderson-Darling normality test | |
} | |
basic_plot <- function (data1, data2, xlab, ylab) { | |
# filename = paste(xlab, " x ", ylab, ".png", sep="") | |
# png(file=filename) # abrindo "cursor" | |
plot(data1, data2, xlab=xlab, ylab=ylab) | |
# dev.off() # "fechando" arquivo | |
} | |
fdp <- function(data, title) { | |
filename = paste(title, ".png", sep="") | |
# png(file=filename) # abrindo "cursor" | |
plot(density(data),main=title) | |
# linha normal | |
curve(dnorm(x, mean=mean(data), sd=sd(data)), add=TRUE, col="blue") | |
# dev.off() # "fechando" arquivo | |
} | |
qqnorm_plot <- function(data, title) { | |
# filename = paste(title, ".png", sep="") | |
# png(file=filename) # abrindo "cursor" | |
qqnorm(data, main=title); qqline(data) | |
# dev.off() # "fechando" arquivo | |
} | |
batch <- function (data, title) { # executa funcoes de normalidade e fdp | |
normality_measuares(data) | |
normality_tests(data) | |
fdp(data, paste("FDP:", title)) | |
# qqnorm_plot(data, paste("QQ-Norm:", title)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment