Commit f5275bbe authored by Simon Ciranka's avatar Simon Ciranka

i did some model comparison on the MarbleData and made everything appear a little nicer.

parent b50172c0
# before i turn everything into functions again.
#for (i in 1:nrow(subjectLevel)){
#reset shape paramters
load("RobertsMarbleDf.RData")
data$sub.id<-as.numeric(data$sub.id)
Subs<-unique(data$sub.id)
data$sequence.marbles.color1<-as.character(data$sequence.marbles.color1) #blue
data$sequence.marbles.color2<-as.character(data$sequence.marbles.color2) #red
sub.list<-list()
subjectLevel<-data[data$sub.id==Subs[1],]
i=3
priorMu=0.5;
priorSig=1;
obs=NA;
mus=rep(0,46);
mus[1]=priorMu;
sig=mus;
sig[1]=priorSig;
s=10;
hazard=1;
# here i need to make my outcomes sequential.
red<-strsplit(subjectLevel$sequence.marbles.color2[i],"")
red<-as.numeric(unlist(red))#prepre the array
blue<-strsplit(subjectLevel$sequence.marbles.color1[i], "")
blue<-as.numeric(unlist(blue))
for(k in 1:length(red)){
obs=c(obs,sample(c(rep(1,blue[k]),rep(0,red[k]))));
}
sigma<-obs
sigma[1]=priorSig
mu<-obs
mu[1]=priorMu;
precision[1]<-1
#obs<-obs[!is.na(obs)]
lr<-0.2;
for (j in 2:length(obs)){
p=sigmoid(mu[j-1])#likelihood.
precision[j]=(1/s)+(1/sigma[j-1]+p*(1-p))
sigma[j]=1/precision[j]
mu[j]=mu[j-1]+(sigma[j-1])*(obs[j]-p)
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment