poissonconsulting/tmbr

coin example

Opened this issue · 2 comments

data <- data.frame(Throws = 8, Heads = 1)

ml <- "
#include <TMB.hpp>

template<class Type>
Type objective_function<Type>::operator() () {

DATA_VECTOR(Throws);
DATA_VECTOR(Heads);

PARAMETER(bHeads);

vector<Type> pHeads = Heads;

ADREPORT(pHeads)

Type nll = 0.0;

for(int i = 0; i < Heads.size(); i++){
  pHeads(i) = invlogit(bHeads);
  nll -= dbinom(Heads(i), Throws(i), pHeads(i), true);
}
return nll;
}"

ml %<>% model(gen_inits = function(data) list(bHeads = 0), derived = "pHeads")
ml %<>% analyse(data = data)
coef(ml, param_type = "derived")

why

# A tibble: 1 × 7
        term estimate    sd zscore lower upper pvalue
  <S3: term>    <dbl> <dbl>  <dbl> <dbl> <dbl>  <dbl>
1     pHeads        1     0    Inf     1     1      0

is the sd 0 and the estimate 1?