Categorical contrast not working

56 views
Skip to first unread message

George Peck

unread,
Sep 1, 2016, 11:25:15 PM9/1/16
to Stan users mailing list
Question about categorical analysis:
I get the same slope values when exchanging categorical variables.  I expect differences (since the data suggest that the UV will have the largest lambda, and trap catch count means were certainly not equal):

unique(d$trap) #BG (default intercept category), EVS, UV, CDC
d$trap.EVS <- ifelse( d$trap=="2" , 1 , 0 ) #"2" used to match cvs file
d$trap.UV <- ifelse( d$trap=="3", 1 , 0)
d$trap.CDC <- ifelse( d$trap=="4" , 1 , 0)
# Got a = 4.49 (mean) using BG as default intercept

#when I redo same calculation using EVS:
d$trap.BG <- ifelse( d$trap=="1" , 1 , 0 ) #EVS now default slope "a"
d$trap.UV <- ifelse( d$trap=="3", 1 , 0)
d$trap.CDC <- ifelse( d$trap=="4" , 1 , 0)
# Got a = 4.49 (mean) using EVS as default inercept

#model follows:
NAM1.0 <- map(
  alist(
    count ~ dpois( lambda ),
    log(lambda) <- a + bt.BG*trap.EVS + bt.UV*trap.UV + bt.CDC*trap.CDC,
    a ~ dnorm(0,10), 
    bt.BG ~ dnorm(0,1),
      bt.UV ~ dnorm(0,1),
      bt.CDC ~ dnorm(0,1)
  ),
  data = d)
precis(NAM1.0)

#Results for letting BG = intercept default
> precis(NAM1.0)
        Mean StdDev  5.5% 94.5%
a       4.49   0.04  4.43  4.55
bt.EVS -0.97   0.07 -1.08 -0.85
bt.UV   0.58   0.05  0.51  0.66
bt.CDC  0.10   0.05  0.01  0.18

#Results for letting EVS =  intercept default
> precis(NAM1.0)
        Mean StdDev  5.5% 94.5%
a       4.49   0.04  4.43  4.55
bt.BG  -0.97   0.07 -1.09 -0.86
bt.UV   0.58   0.05  0.50  0.65
bt.CDC  0.09   0.05  0.01  0.17

Please advise.

Daniel Lee

unread,
Sep 1, 2016, 11:33:56 PM9/1/16
to stan-users mailing list
Hi George,

Did you send this to the right list? I don't see anything directly relevant to Stan in your post.


Daniel


--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+unsubscribe@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Lee

unread,
Sep 1, 2016, 11:53:28 PM9/1/16
to stan-users mailing list
Hi George,

Inferring from your other post to stan-users and Andrew, is this the result of some model in the rethinking package in R?


Daniel

George Peck

unread,
Sep 1, 2016, 11:55:10 PM9/1/16
to stan-...@googlegroups.com
Hi Daniel,

I am following the examples in the "Statistical Rethinking" text written by Richard McElreath.  His package, rethinking R ( http://xcelab.net/rm/software/ ) interacts with rstan.   I should probably contact him directly with my questions. Yes?

George  

--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/snp1BPtu98o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@googlegroups.com.

Daniel Lee

unread,
Sep 2, 2016, 12:02:27 AM9/2/16
to stan-users mailing list
Hi George,

Richard or someone else that knows the package might be on this list. My guess is that reaching out to Richard directly will get you a faster response. 

If it had to do with the packages that the Stan development team work on directly, this would definitely be the quickest way to get a response. (It's faster than writing to any of us directly.) If you're willing to dig into the math and write out a Stan program directly, that I could help with.



Daniel


Bob Carpenter

unread,
Sep 2, 2016, 7:08:24 AM9/2/16
to stan-...@googlegroups.com
Richard's on the list, and the rethinking GitHub page
is here:

https://github.com/rmcelreath/rethinking

and the home page for the product is here:

http://xcelab.net/rm/statistical-rethinking/

but I didn't see a mailing list.

I don't mind people posting here about various packages that
use Stan or RStan, but the Stan developers are probably not
the best ones to answer most of these questions unless they
can be reduced to Stan itself as Daniel says.

- Bob
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
> To post to this group, send email to stan-...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/snp1BPtu98o/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
> To post to this group, send email to stan-...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
> To post to this group, send email to stan-...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages