Skip to content
Prev 386971 / 398502 Next

How to generate SE for the proportion value using a randomization process in R?

Hello,

Inline.

?s 07:47 de 23/01/21, Marna Wagley escreveu:
No, we don't. var already divides by n, don't divide again.
This is the code, that can be seen by running the function name at a 
command line.


sd
#function (x, na.rm = FALSE)
#sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x),
#    na.rm = na.rm))
#<bytecode: 0x55f3ce900848>
#<environment: namespace:stats>
Try plotting the normal densities for both cases, the red line is 
clearly wrong.


f <- function(x, xbar, s){
   dnorm(x, mean = xbar, sd = s)
}

hist(b$t, freq = FALSE)
curve(f(x, xbar = b$t0, s = sd(b$t)), from = 0, to = 1, col = "blue", 
add = TRUE)
curve(f(x, xbar = b$t0, s = sd(b$t)/sqrt(R)), from = 0, to = 1, col = 
"red", add = TRUE)


Hope this helps,

Rui Barradas