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)) How to calculate the z-score in R dat %>% This indicate that z score is 4.249687 standard deviations above the average of population. 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. Nevertheless, reticulate allows you the flexibility of having both R and Python together without leaving RStudio. The package authors suggest using a Python editor for Python-only projects. Transmute(SEQN, Gender = RIAGENDR, BMI = BMXBMI)ġ0 41486 2 31.21 How to calculate the z-score for BMI There are different ways to use Python in RStudio’s IDE, including sourcing Python scripts, that can be found in the reticulate documentation. 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. 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. 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. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |