Type 3 ANOVA in R (with Examples)

Type 3 ANOVA in R can be calculated using Anova() function from CAR. The following shows the steps of doing it in R. Step 1: Prepare data in R The data has two categorical IVs (cities and stores) and one DV (sales). x_1 = rep(c(‘City1′,’City2’),each=5) x_2 = rep(c(‘store1′,’store2’), 5) sales=c(10,20,20,50,30,10,5,4,12,4) df <- data.frame (cities = … Read more

Categories R

Type 2 ANOVA in R (with Examples)

This tutorial shows how you can calculate Type 2 ANOVA in R with an example. Anova() in the package of Companion to Applied Regression (CAR) can be used to calculate Type 2 ANOVA in R. Note that, Anova() in CAR only provides options of Type 2 and Type 3 ANOVA. It is different from another function … Read more

Categories R

Type 1 ANOVA in R (with Examples)

This tutorial shows how to do Type 1 ANOVA in R. There are two functions in R that can be used to calculate Type 1 ANOVA, anova() or aov(). Note that, anova() here is different from Anova() in Companion to Applied Regression (CAR). Anova() in CAR can be used only for Type 2 and Type … Read more

Categories R

What is dnorm in R (Examples)

This tutorial shows how you can use dnorm() in R with examples. The following is the syntax of dnorm(). dnorm(x, mean = 0, sd = 1, log = FALSE) mean: The mean of the normal distribution sample data. The default value is 0. sd: The standard deviation. The default value is 1. log: logical; if TRUE, returned log() value … Read more

Categories R

Linear Regression with Categorical Variables in R (4 Steps)

For linear regression models, IVs can be either categorical, numerical, or a combination of them. This tutorial focuses on linear regression with categorical variable as IVs in R. For instance, the dependent variable Y is sales, whereas the independent variable X is City. City is a categorical variable with two levels, namely City1 and City2. … Read more

Categories R

How to Use pnorm in R (Examples)

This tutorial shows the definition of pnorm() in R and how to use it with examples. pnorm() is used to return probability (p) for the given quantile (q). pnorm(q, mean, sd, lower.tail = TRUE, log.p = FALSE) q: the quantile (value on the x-axis) mean: The mean of the sample data. The default value is 0. sd: The standard deviation. The … Read more

Categories R

Introduction of Normal Distribution Functions in R (Examples)

The tutorial provides examples for each of these 4 normal distribution functions in R. R has 4 normal distribution functions, including rnorm, dnorm, pnorm, and qnorm. The following table provides a summary for each of these 4 normal distribution functions in R. Syntax of R functions Definitions Examples rnorm(n, mean, sd) Generate a sample of … Read more

Categories R

Probability Density Functions in R (Examples)

The tutorial shows examples of how you can use built-in Probability Density Functions (PDF) in R, including PDF for normal distribution (dnorm), uniform distribution (dunif), and exponential distribution (dexp). Example 1: PDF for Normal Distribution Normal distribution PDF dnorm() in R returns the density of probability at 2. Note that it is standard normal distribution … Read more

How to Use rnorm in R (Examples of Simulate Normal Distribution)

rnorm() in R can be used to simulate a sample of normal distribution data. This tutorial uses 3 examples showing how you can simulate normal distribution sample using rnorm(). In particular, rnorm has the following statement. rnorm(n, mean=0, sd=1) n: The number of observations, namely the sample size mean: The mean of the normal distribution sample data. The default … Read more

Categories R