Home > database >  What are the R functions in normal distribution?
What are the R functions in normal distribution?

Time:12-14

The diastolic blood pressures (DBP) of a group of young women are Normally distributed with mean 67 mmHg and a standard deviation of 9 mmHg.

I am currently trying to analyze some data and am new to statistics with R.

Following above question , i want to see how to display using R, how the following statement are true or false.

  1. About 95% of the women have a DBP between 58 and 76 mmHg.

  2. About 50% of the women have a DBP of above 67 mmHg.

  3. About 2.5% of the women have DBP below 49 mmHg.

  4. What proportion of young women have a DBP between 58 mmHg and 85 mmHg?

I tried solving it manually . But want to display it using R.

CodePudding user response:

Here is code that illustrates some of these concepts. You can use the dnorm function inside the stat_function layer of ggplot2. I put the mean as 0 and standard deviation as 1, and calculated the z-scores bases on that. In your case, you could change the mean to 67 and sd to 9 and change the vertical lines for the z-scores accordingly. But you don't need to visualize this in R to find the answers. Try to familiarize yourself with the dnorm, pnorm, rnorm family of functions.

ggplot(data.frame(x = c(-4, 4)), aes(x))  
  stat_function(fun = dnorm,
                geom = "area", fill = '#ffe6b7', color = 'black', alpha = 0.5, 
                args = list(
                  mean = 0,
                  sd = 1))  
  labs(title = "Standard Normal Distribution", subtitle = "Standard Deviations and Z-Scores")  
  theme(plot.title = element_text(hjust = 0.5, face = "bold"))  
  theme(plot.subtitle = element_text(hjust = 0.5))  
  geom_vline(xintercept = 1, linetype = 'dotdash', color = "black")  
  geom_vline(xintercept = -1, linetype = 'dotdash', color = "black")  
  geom_vline(xintercept = 2, linetype = 'dotdash', color = "black")  
  geom_vline(xintercept = -2, linetype = 'dotdash', color = "black")  
  geom_vline(xintercept = 3, linetype = 'dotdash', color = "black")  
  geom_vline(xintercept = -3, linetype = 'dotdash', color = "black")  
  geom_text(aes(x=1, label="\n 1 σ", y=0.125), colour="#376795", angle=90, text=element_text(size=11))  
  geom_text(aes(x=2, label="\n 2 σ", y=0.125), colour="#376795", angle=90, text=element_text(size=11))  
  geom_text(aes(x=3, label="\n 3 σ", y=0.125), colour="#376795", angle=90, text=element_text(size=11))  
  geom_text(aes(x=-1, label="\n-1 σ", y=0.125), colour="#376795", angle=90, text=element_text(size=11))  
  geom_text(aes(x=-2, label="\n-2 σ", y=0.125), colour="#376795", angle=90, text=element_text(size=11))  
  geom_text(aes(x=-3, label="\n-3 σ", y=0.125), colour="#376795", angle=90, text=element_text(size=11)) 

enter image description here

  • Related