-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInfoDes.R
More file actions
17 lines (17 loc) · 706 Bytes
/
InfoDes.R
File metadata and controls
17 lines (17 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Fisher Information of design
#
# Returns the Fisher Information of a design, given parameter values.
# @inheritParams Modfed
# @param par A vector containing the parameter values
# @return Fisher Information matrix.
InfoDes <- function(par, des, n.alts) {
group <- rep(seq(1, nrow(des) / n.alts, 1), each = n.alts) #Vector to
#indicate the choice set
# probability
u <- des %*% diag(par) # X'B from the model
u <- .rowSums(u, m = nrow(des), n = length(par))
p <- exp(u) / rep(rowsum(exp(u), group), each = n.alts)
# information matrix
info.des <- crossprod(des * p, des) - crossprod(rowsum( des * p, group))
return(info.des)
}