Showing posts with label Statistics. Show all posts
Showing posts with label Statistics. Show all posts

Hypothesis testing

Thursday
Hypothesis testing
Null hypothesis
Alternative hypothesis
Type I and Type II error
Special Situations and Best Test Rules
Population Proportion
(i) Sample size small; Binomial Test
(ii) Sample size large (around 30); Z Test
2. Population Mean
(i) Population variance known; Z test
(ii) Population variance unknown; t test
Read more ...

Probability

Sunday
The theory of probability deals with measurement of the chances of a event to occur out of a set of all possible outcomes.  The probability is defined as a number between 0 and 1, computed by statistical number of outcome considered divided by the number of all possible outcomes.
Random Variables
A random variable is a variable whose values subject to varies and assumes to depend on the outcome of an "experiment” (e.g., survey or just observing). A random variable assigns a numerical value to each of outcomes by the number of all outcomes. 
The random variables can be classified as discrete or continuous. The discrete random variables has possible values from a specified list of exact values viz finite or countably infinite. Usually the random variable arises out the counting. On other hand, the continuous random variables can have any numerical value in an interval or collection of intervals. Usually, the continuous random variables arises while measuring certain things. 
The mathematical function describing the possible values of a random variable and their associated probabilities is known as a probability distribution.

Expected Value 
The expected value of a random variable is the weighted average of all possible values of random variables with the probability of the value. The expectation of a discrete random variable with possible discrete values x1, x2... together with respective probabilities p1, p2,...

E(X) = ∑ (xi * pi)

Variance of a random variable X is defined as below

 V(X) = E [(X - E(X)) ^ 2] 
 V(X) = E(X^2) - (E(X))^2

Squared root of the variance is the standard deviation of a random variable.
The binomial distribution is the discrete probability distribution of the number of successes in a sequence of n Bernoulli trials. Bernoulli trials are independent experiments with exactly two outcomes viz success and falilure. The probability of success of each trail is p and that of a failure is q = 1 - p in each trial.
Expected value for a random variable with binomial distribution = n * p
Variance for a random variable with binomial distribution = n * p * (1-p)

Poisson Distribution
The Poisson distribution is a discrete probability distribution that expresses the probability of a given number of events occurring in a fixed interval of time and/or space if these events occur with a known average rate and independently of the time since the last event. The Poisson distribution can also be used for the number of events in other specified intervals such as distance, area or volume.
Let X = number of successes in an interval of time or a specific region of space. Then possible values of X are : 0,1,2,… The Poisson probability distribution of X with parameter λ



Normal Distribution
The normal distribution is a continuous probability distribution that has bell-shared probability density function given by following equation:

According to Central Limit Theorem, no matter what a population distribution (relative frequency histogram) is, the sum or average of observations in a random sample taken from the population has approximately normal distribution. This theorem makes the normal distribution to be a most prominently used probability distribution in statistics.


Read more ...

Cause and effect: Regression Analysis

Wednesday

Cause and effect

The correlation theory of statistics is used to model the cause and effect among variables. The causation implies correlation, but correlation along does not implies caustion. A correlation between two variables alone cannot prove that there is a causation effect. The correlation is only a mathematical relationship and it does not necessarily signify a cause and effect relationship between the variables. For any two correlated variables A and B, the following relationships are possible:
  1. A causes B
  2. B causes A
  3. Both A and B are affected by a common cause (third variable)  but do not cause each other
  4. Both A and B are mutually affecting each other so than neither of them could be designated as a cause or effect
  5. No connection between A and B, the correlation may be due to random or chance factors
The correlation is only a mathematical relationship and it does not necessarily signify a cause and effect relationship between the variables.
  

Simple Linear Regression

Regression Analysis deals in establishing statistical model of relationship of a variable with the explanatory variables. Following are the steps in this process.
Step 1 : Choose predictor or explanatory variables. The correlation analysis is done to choose the predictor model. The pair of two variables with higher coefficient of correlation indicates strong relation. The coefficient of correlation varies between -1.0 to 1.0


Many times, time is also one of the variables but it may just be a proxy for other variables. Time should be considered as predictor variable when there is a seasoning affect to be accounted.

Step 2: Regression Analysis -> confidence level & prediction
Define a regression model between the variables. The Simple Linear Regression model predict the variables  by following equation

Yi = m Xi + c
[c= intercept, m = sensitivity of Xi]

The difference between the observed value and the predicted value from regression model is termed as residual.
residual = actual - predicted value of the variable
standard residual = (residual - mean of residuals) / standard deviation of residuals
SST = sum of squared differences between observed value and mean value
SSR = sum of squared differences between predicted value and mean value
SSE = sum of squared differences between observed value and predicted value
SST = SSR + SSE
Note: [sum of squared of deviation] varies in 0 to 1
Standard error of estimate is similar to standard deviation but it measures the variations around prediction line (not around mean value) = Square root of (SSE / count)
R2 (Coefficient of Determination) is the proportion of variation in Y explained by variation in
explanatory variable(s) through regression relation.
R2 = SSR / SST
Square-root of R2 gives the correlation between actual and predicted values and termed as Multiple-R


Step 3: Summarize all (all predictor variables) the models in terms of three measures which are Adjusted R square, Durbin Watson, and MAPE. Based on this choose the best model that can predict best results.

Adjusted R2: Modified version of R2 which penalizes a model for including redundant the explanatory variables. It is a proportion of variation in Y explained by variation in X. It is a measure of goodness of model. The value more closer to 1 mean more tighter prediction of the variable by the model. Adjusted R2 is more often used (compared to R2)

Durbin-Watson Statistics
If you plot residuals against predicted values, it should be random. For the time-series based data, Durbin-Watson statistics is used to evaluate the randomness of the residuals. DW is sum of squares of current and previous residuals divided by sum of squares of residuals. DW varies between 0 to 4. The value between 1.5 to 2.5 indicated errors are serially uncorrelated. 

Absolute percentage error = (Actual - Predicted) / Actual value of the variable

Mean absolute percentage error (MAPE) is a average of absolute percentage error. It is used to measure a predictive ability of a model.


Additional read:
Dummy variable correlation analysis: http://en.wikipedia.org/wiki/Dummy_variable_(statistics)
Read more ...

Introduction to Statistics

Sunday
In business world, Statistics is primarily used for summarizing the business data, for drawing conclusion from those data, for making reliable forecasts about business activities and for improving the business processes.

Terminology
  • Variable is a characteristic of an item or individual
  • Data are the different values associated with a variable
  • Population is a set of all data that you want to draw conclusion about
  • Sample is a portion of population selected for analysis
Types of Data
1.      Categorical or Qualitative
2.      Numerical or Quantitative
·         Continuous
·         Discrete

Various Measurement Scales
Stanley Smith Stevens proposed his theory in a 1946 Science article titled "On the theory of scales of measurement". Stevens claimed that all measurement in science was conducted using four different types of scales. Stevens unified both qualitative (which are described by his "nominal" scale) and quantitative (to a different degree, all the rest of his scales).

1)      Non-metric Scale
a)      Nominal Scale: Qualitative type of data e.g. gender is measured on nominal scale. It includes both dichotomous and non- dichotomous nominal. One can assign the numbers on this scale but these are just the labels
b)      Ordinal Scale: Ordinal scales record information about the rank order of scores. Ordinal measurements describe order, but not relative size or degree of difference between the items measured
2)      Metric Scale
a)      Interval Scale: Interval scales tell us about the order of data points, and the size of the intervals in between data points. Quantitative attributes are all measurable on interval scales, as any difference between the levels of an attribute can be multiplied by any real number to exceed or equal another difference. Zero is relative. E.g. temperature, rating.
b)      Ratio Scale: A ratio scale is an interval scale with a true zero point. Most measurement in the physical sciences and engineering is done on ratio scales. Zero is zero – absolute. E.g. Sales

Organization of Numerical Data
1)      Ordered Array:
a)      Stem and leaf display: A basic stem-and-leaf display contains two columns separated by a vertical line. The left column contains the stems and the right column contains the leaves. Stem-and-leaf displays are useful for displaying the relative density and shape of the data. They are also useful for highlighting outliers and finding the mode. However, stem-and-leaf displays are only useful for moderately sized data sets (around 15-150 data points).
2)      Frequency Distributions:
a)      Tables
b)      Histograms: Histogram is one of the tool of Seven Basic Tools of Quality


Read more ...

Summary Measures

Sunday
Summary measures in descriptive statistics are used to summarize a set of observations, commonly, in following ways
  1. Measures of central tendency like mean, median, mode, geometric mean, harmonic mean
  2. Measures of dispersion like range, variance, standard deviation
  3. Measures of the shape of the distribution like skewness or kurtosis
  4. Measures of dependence like correlation coefficient 
Measures of central tendency
Measures the tendency of data values to group around a central value.
  • Mean, commonly known as average, is the sum of all values divided by the number of cases. This is also known as arithmetic mean. 
  • Mode is the most frequent value in a data distribution. The mode is suitable for all types of data (nominal to ratio data). In practice, the mode is suitable only for variables with limited values
  • Median is the value that exactly divides an ordered set of data into equal halves. If the size of ordered data is odd number then middle number will be median whereas if its even number then average of middle two numbers gives the median. The median is not affected by extreme values. The median is suitable for ordinal data and cannot be used for nominal data
  • Geometric mean is nth-root of product of all values in data-set. The geometric mean is suitable for ratio data. This more appropriate than arithmetic mean of proportional growth e.g. CAGR.
  • Harmonic mean is calculated by taking the reciprocal of average of reciprocal of data. Harmonic mean is appropriate for calculating the average of rates. Unlike arithmetic mean which gives greater weightage to large data points than to small data points, harmonic mean gives equal weightage to all data points.
Measures of dispersion (variation)
Measures the spread or dispersion of values in a data set.
  • Range is the difference of largest value and smallest value in the data set. It measures the total spread in the set of data.
  • Inter Quartile Range IQR (mid-range) is the difference between values at the 25th and the 75th percentiles in the data set. This is more stable than the range but is of limited use.
  • Sum of squares is the sum of the squared deviations of set of data from the mean of the set. This is also known as Variation.
  • Variance is the mean of the squared deviations.
  • Standard deviation is the square root of the variance. This is a most commonly used measure of dispersion.
  • Coefficient of variation expresses the standard deviation in percentage of mean.
  • Z-Score is the difference between the value and the mean, divided by the standard deviation. This is used to locate the outliers in the data-set. The larger the Z-score the greate the distance from the mean.
Measures of Shape
Measures the shape or pattern of distribution of data values through out the range.
  • Uni-modal - the distribution had only a single value that occurred most frequently
  • Symmetrical - the left side of the distribution of values mirrored the right side
  • Skewed - when left side and right-side of distribution does not mirror each other. It can be skewed to the left or skewed to the right
  • Bell-shaped - the frequencies of cases declined toward the extreme values in the right and left tails, so that the distribution had the appearance of a "bell".
It can be symmetric or skewed distribution around the mean value of data set.
  • Skewness measures the extent to which a set of data is not symmetric.
  • Kurtosis measures the relative concentration of values in the center of distribution. It measures the peakness of the distribution
Measures of dependence
Measures the cause and effect relation among the variables.
  • Covariance measures the strength of the linear relationship between two numerical variables
  • Coefficient of correlation measures the relative strength of the linear relationship between two numerical variables
Read more ...