If you calculate the mean and standard deviation of the zscore above, you will find that mean is 0, and standard deviation is 1. Now we see the z-score for each individual, and the values corresponded to what we calculated above. Mutate(zscore = (BMI - mean(BMI))/sd(BMI)) So to convert a value to a Standard Score ('z-score'): first subtract the mean, then divide by the standard deviation. In this example, the value 1.7 is 2 standard deviations away from the mean of 1.4, so 1.7 has a z-score of 2. How to calculate the z-score in R dat %>% How many standard deviations a value is from the mean. This indicate that z score is 4.249687 standard deviations above the average of population. The mean for the standard normal distribution is zero, and the standard deviation is one. The calculation will be: I take the actual BMI (58.04), substract the mean (25.70571), and divide the difference by the standard deviation (7.608628). Suppose we want to calculate the z-score of the first and third participant in the dataset `dat`. To calculate the z-score of BMI, we need to have the average of BMI, the standard deviation of BMI. Transmute(SEQN, Gender = RIAGENDR, BMI = BMXBMI)ġ0 41486 2 31.21 How to calculate the z-score for BMI Loading packages and creating the dataset: library(tidyverse)ĭat = nhanes_load_data("DEMO_E", "2007-2008") %>% In the example below, I am going to measure the z value of body mass index (BMI) in a dataset from NHANES. The test has a mean () of 150 and a standard deviation () of 25. In short, the z-score is a measure that shows how much away (below or above) of the mean is a specific value (individual) in a given dataset. For example, let’s say you have a test score of 190. As usual, I will use the data from National Health and Nutrition Examination Survey ( NHANES). In this post, I will explain what the z-score means, how it is calculated with an example, and how to create a new z-score variable in R. The calculation of z-score is simple, but less information we can find on the web for its purpose and mean. Sometimes it is necessary to standardize the data due to its distribution or simply because we need to have a fair comparison of a value (e.g, body weight) with a reference population (e.g., school, city, state, country). Are you interested in guest posting? Publish at DataScience+ via your RStudio editor.
0 Comments
Leave a Reply. |