Skip to content

Commit d6ce10f

Browse files
committed
added risk difference to variane function
1 parent 6aed1d3 commit d6ce10f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

R/ALD_stats.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,17 @@ link_transform <- function(p, family) {
115115
#'
116116
link_transform_var <- function(y, N, family) {
117117
link <- family$link
118+
p <- y/N
118119

119120
if (link == "logit") {
120121
# log-OR
121122
return(1/y + 1/(N - y))
122123
} else if (link == "log") {
123124
# log-RR
124-
return(1/y)
125+
return((1-p)/(p*n))
126+
} else if (link == "log") {
127+
# log-RD
128+
return((1-p)/n)
125129
} else {
126130
##TODO: replace all? and move to trial_variance()
127131
(1 / (family$mu.eta(y/N)^2)) * family$variance(y/N) # delta method

0 commit comments

Comments
 (0)