I want to compute a posterior density plot with conjugate prior
I have data with known parameters (mean =30 , sd =10)
I have two priors one with normal distribution with known parameter ( mean =10 , sd=5) and other with t distribution with same mean and sd but degree of freedom 4
I want a graph with density plots for prior,data and posterior ?
can you help me with r code for this problem ?
Plus I am getting wrong density function for posterior in my opinion..Here is my code so far
x=seq(from=-90, to=90, by= 1)
data=dnorm(x,mean=30,sd =10)
prior = dnorm(x,mean=10,sd =5)
posterior = dnorm(x,mean=10,sd =5)*dnorm(x,mean=30,sd =10) # prior* data #Prior*data
plot(x,data , type="l", col="blue")
lines(x,prior, type="l", col="red")
lines(x,posterior , type="l", col="green")