-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathstartvals.Rout.save
58 lines (52 loc) · 1.9 KB
/
startvals.Rout.save
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
R Under development (unstable) (2012-07-27 r60013) -- "Unsuffered Consequences"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i686-pc-linux-gnu (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(bbmle)
>
> ## copied from emdbook
> dbetabinom <- function (x, prob, size, theta, shape1, shape2, log = FALSE)
+ {
+ if (missing(prob) && !missing(shape1) && !missing(shape2)) {
+ prob = shape1/(shape1 + shape2)
+ theta = shape1 + shape2
+ }
+ v <- lchoose(size, x) - lbeta(theta * (1 - prob), theta *
+ prob) + lbeta(size - x + theta * (1 - prob), x + theta *
+ prob)
+ if (log)
+ v
+ else exp(v)
+ }
>
> ss <- data.frame(taken=c(0,1,2,5),available=c(5,5,5,5),
+ dist=rep(1,4))
>
> SP.bb=mle2(taken~dbetabinom(prob,theta,size=available),
+ start=list(prob=0.5,theta=1),data=ss)
Warning messages:
1: In lbeta(theta * (1 - prob), theta * prob) : NaNs produced
2: In lbeta(size - x + theta * (1 - prob), x + theta * prob) :
NaNs produced
> SP.bb.dist=mle2(taken~dbetabinom(prob,size=available,theta),
+ parameters=list(prob~dist-1,theta~dist-1),
+ start=as.list(coef(SP.bb)),data=ss)
>
> SP.bb.dist2=mle2(taken~dbetabinom(prob,size=available,theta),
+ parameters=list(prob~dist - 1,theta~dist - 1),
+ start=as.list(coef(SP.bb)),data=ss)
>
>
> proc.time()
user system elapsed
0.808 1.072 1.743