What is Linear Regression Model? Definition and Example

1. Definition of Linear Regression Model Multiple linear regression is a linear model accessing the relationship between a dependent variable (DV, or Y) and multiple intendent variables (IV, or X). For instance, you might want to test how consumer purchase intention can be impacted by price as well as by household income. In this case, … Read more

How to Use numpy.random.seed()

numpy.random.seed() provides a seed, which acts as a starting point number generator algorithm. For the same seed, we will always get the same set of random numbers on any machine. If you prefer to have different sets of random numbers every time you run the code, do not set the seed. In contrast, if you … Read more

How to Write Null and Alternative Hypothesis for Two-Way ANOVA

This tutorial shows how to write null and alternative hypothesis for two-way ANOVA. It is an extension of my other tutorial on this same topic. 1. Introduction A two-way ANOVA is used to test whether the means from the two or more categorieal variables are significantly different from one another. For instance, below, there are two categorical variables, … Read more

Calculate Means Group by Two Columns in Pandas (3 Examples)

The following provides 3 different methods of calculating means group by two Columns in Python. Method 1: df.groupby([“column_1″,”column_2”]).mean() Method 2: df.groupby([“column_1″,”column_2”]).agg(‘mean’) Method 3: pd.crosstab(index=df[‘column_1’], columns=df[‘column_2’],values=df[‘dv’],aggfunc=’mean’) Prepare the data Output: city store sales 0 City1 store1 10 1 City1 store2 20 2 City1 store1 20 3 City1 store2 50 4 City1 store1 30 5 City2 store2 10 … Read more

Calculate Sum of Squares Total (SST) in R (2 Examples)

This tutorial shows how to calculate Sum of Squares Total (SST) in R. The following is the data being used. The hypothetical data being used has two categorical IVs (cities and stores) and one DV (sales). Note that, while it has two IVs, the calculation of SST actually does not need to use these two … Read more

Overview of Type I, Type II, and Type III ANOVA in R (with Examples)

This tutorial explains what Type I, Type II, and Type III ANOVA are. Further, it provides examples showing how you can do Type I, Type II, and Type III ANOVA in R. 1. Introduction Type I, Type II, and Type III ANOVA are 3 different ways of calculating sum of squares in ANOVA. Type I … Read more

Categories R

Why Type I ANOVA is Sequential Sum of Squares (R code example)

Type 1 ANOVA is also called sequential sum of squares, because it considers the order effect of entering factors into the model. If you change the order of the factors in the model, the results will be different. The following uses an example in R to explain this. Step 1: Prepare the data The following is … Read more

How to Interpret Type 1, Type 2, and Type 3 ANOVA

1. Introduction What are the meanings of different types of ANOVA? In other words, what are Type 1 (Type I), Type 2 (Type II), and Type 3 (Type III) ANOVA? The following uses the model of factors A and B, and its interaction A*B as an example to explain the difference of Type 1 (Type … Read more

How to Conduct Two-Way ANOVA in R

This tutorial shows how you can do two-way ANOVA in R with examples. A two-way ANOVA is used to test whether the means from the two or more categorieal variables are significantly different from one another. For instance, below, there are two categorical variables, namely city (city 1 and city 2) and store (store 1 and store 2). … Read more

Categories R