ComenzarEmpieza gratis

Paired t-test

In the video, you learned how paired t-tests can be more powerful than regular t-tests. During this exercise, you will see an example demonstrating this. The first step will be to simulate data. Similar data might come from a people's weights before or after a drug treatment or amount of money spent by a customer before or after a seeing a commercial.

Simulated data allows you to know the properties of the data and check to see if your model behaves as expected. R comes with many distributions including the normal. Your simulated data will have unequal variance (that is, the standard deviations will be different). The second step will be to analyze the data with both a paired and regular t-test. Last, you will be asked about the results from the paired t-tests.

As part of the first step, you will "set the seed" for R's random number generator. This ensures you get the same numbers each time you run the code and DataCamp's software correctly scores your code.

Este ejercicio forma parte del curso

Hierarchical and Mixed Effects Models in R

Ver curso

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# Set the seed to be 345659
set.seed(___)

# Model 10 individuals 
n_ind <- ___

# simulate before with mean of 0 and sd of 0.5
before <- rnorm(n = n_ind, mean = ___, sd = ___)
# simulate after with mean effect of 4.5 and standard devation of 5
after  <- ___ + rnorm(n = n_ind, mean = ___, sd = ___)
Editar y ejecutar código