Calculate p-value in Linear Regression

This tutorial shows how you can calculate p-value for linear regression. It includes formulas and data examples in Python. Formulas for p-value in Linear Regression We can estimate the regression coefficient B using the following formula. Where, Such calculation only generates regression coefficients but no p-values. To calculate the p-value, you need to calculate the … Read more

One Sample t-test in R

The following is the core R syntax to do one sample t-test in R. In particular, Method 1 uses built-in R function, whereas method 2 writes the function to test one sample t-test in R from scratch. Method 1: t.test(vector_name, mu = value_to_compare, alternative = “two.sided”) Method 2: (mean(vector_name)-value_to_compare)/(sd(vector_name)/sqrt(number_of_observation)) Data Example for One Sample t-test … Read more

Linear Regression: Python Numpy Implementation from Scratch

This tutorial shows how you can conduct linear regression Python Numpy from scratch. 1. Math and Matrix of Linear Regression We can use just use pure matrix calculation to estimate the regression coefficients in a linear regression model. Below is the process. Thus, we can simplify the function above to the function below. We can … Read more

Python: Type I, Type II, and Type III ANOVA

1. Introduction Type I, Type II, and Type III ANOVA are 3 different ways of calculating sum of squares in ANOVA. Type I ANOVA: SS(A) for factor A SS(B | A) for factor B SS(AB | A, B) for interaction AB Type II ANOVA: SS(A | B) for factor A SS(B | A) for factor … Read more

Use sklearn for Linear Regression in Python

Introduction We can use sklearn.linear_model.LinearRegression to do linear regression in Python. The following is the core syntax of using sklearn. lm.fit(IVs, DV) Where, IVs: the independent variables DV: the dependent variable Example for Linear Regression Model The following is the linear regression model, including household income as IVs and purchase intention as DV. The following … Read more

nltk: How to Remove Stop words in Python

This tutorial shows how you can remove stop words using nltk in Python. Stop words are words not carrying important information, such as propositions (“to”, “with”), articles (“an”, “a”, “the”), or conjunctions (“and”, “or”, “but”). We first need to import the needed packages. We can then set the language to be English. Before removing stop … Read more

What is One-way ANOVA? Formula and Example

One-Way ANOVA is to compare the means of different groups, to see whether the mean difference is statistically significant. For instance, you would like to compare the average household size of three cities. You can collect 3 samples from these three cities and conduct a one-way ANOVA to check the difference. Formulas of One-way ANOVA … Read more

Correlation: Definition, Formula, and Examples

What is Correlation? Correlation is a statistical measure of the relationship between two variables, X and Y. For instance, you can measure to what extent temperature (X) is related to the production of ice cream (Y). You probably would expect that higher temperatures correspond with higher production of ice cream. On the plot shown below, … Read more