Question

Consider the anorexia dataset in the MASS package. This data considers two treatments for anorexia, one...

Consider the anorexia dataset in the MASS package. This data considers two treatments for anorexia, one based on Cognitive Behavorial Treatment (CBT) sessions from a professional therapist and another based on family oriented treatment sessions (FT). The Treat variable is a factor with three levels: Cont (control, no treatment), CBT, and FT. For each subject two weights (in lbs) were measured, one before (Prewt) and one after (Postwt) treatment.
(a) Create a new variable, Outcome, that indicates if the post-weight is higher than the pre-weight, thus denoting whether or not the treatment was successful. Design a figure that compares the success of the three treatment groups graphically (e.g. a barplot).
(b) Using a uniform prior, compute and plot the posterior densities of the proportion of successes for each treatment level.
(c) Use Monte Carlo with your posterior distributions to obtain confidence/credible intervals for the difference in success proportions when comparing CBT to Cont and FT to Cont. What can you conclude in terms of the data?

Homework Answers

Answer #1

> library(MASS)
> d=anorexia
> Outcome=ifelse(d$Postwt>d$Prewt,1,0)
> d1=cbind(d,Outcome)
> d2=d1[which(d1$Treat=="Cont"),]
> d3=d1[which(d1$Treat=="CBT"),]
> d4=d1[which(d1$Treat=="FT"),]
> s1=sum(d2$Outcome);s2=sum(d3$Outcome);s3=sum(d4$Outcome)
> s=c(s1,s2,s3)
> S=c(dim(d2)[1],dim(d3)[1],dim(d4)[1])
> b1=barplot(as.matrix(t(cbind(s,S))),xlab = "trt")
> b1
[1] 0.7 1.9 3.1

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions