# All posts by: Santos

## MCAR and MNAR

MCAR is an acronym for Missing Completely at Random MNAR means Missing not at Random When you have data missing you may try to check if this missing data is random or not. Usually this is done by checking the […]

By: | Uncategorized| Tags: | Comments: 0

## Sensitivity and Specificity

Sensitivity (also called the true positive rate, or the recall in some fields) measures the proportion of positives that are correctly identified as such (e.g., the percentage of sick people who are correctly identified as having the condition). Specificity (also […]

By: | Biostatistics| Tags: | Comments: 0

## How to calculate chi square value in R

Command qchisq returns the value of chi square distribution for a certain value of probability. qchisq(c(0.025), df=286, lower.tail=TRUE) For plotting the graph the command is: local({ + .x <- seq(213.788, 371.301, length.out=1000) + plotDistr(.x, dchisq(.x, df=286), cdf=FALSE, xlab=”x”, ylab=”Density”, + […]

By: | R| Tags: | Comments: 0

## Satisfaction

On satisfaction questions sometimes the questions are influenced by the others.   In a small enterprise with 3 departments the persons from one department give on average 1 value less (in 5) to the restaurant but that was caused by […]

By: | Pratical issues| Tags: | Comments: 0

## Difference between Pearson and Spearman correlation

Spearman rank correlation method Better use when: variables are not normally distributed or the relationship between the variables is not linear

By: | Uncategorized| Tags: | Comments: 0

## Remove a column from a R dataframe

To remove a column from a R dataframe you have to check what is the column number and then give command like data<-data[,-1] The number will be the column to be deleted.

By: | Uncategorized| Tags: | Comments: 0

## Correlation in R

The correlation coefficient of two variables in a data sample is their covariance divided by the product of their individual standard deviations. It is a normalized measurement of how the two are linearly related with values beetween -1 and 1. To calculate […]

By: | Uncategorized| Tags: | Comments: 0

## Format output of summary

You can use function lapply() to apply function summary() to each column and then cbind() to show data as column. lapply(dataFrame,function(x) cbind(summary(x))) From http://stackoverflow.com/questions/14791075/r-format-data-frame-summary

By: | Uncategorized| Tags: | Comments: 0

## Better way to present correlations

http://www.r-bloggers.com/more-on-exploring-correlations-in-r/ cor() – table of correlations cor.prob() – Replaces the upper triangul with the significance flattenSquareMatrix(cor.prob(mydata)) – makes a table out of it   flattenSquareMatrix <- function(m) { if( (class(m) != “matrix“) | (nrow(m) != ncol(m))) stop(“Must be a square […]

By: | Uncategorized| Tags: | Comments: 0

## Dataframe to matrix

To pass a dataframe in R to matrix as.matrix(mtcars) Some commands work over matrix and not over dataframes

By: | Uncategorized| Tags: | Comments: 0