Hi Tom,

I would suggest using the MCMCglmm package.  Here is a minimal example
showing how you could use it to solve your goal:

# load the package
require(MCMCglmm)
# fit a model with a random intercept and slope, by grouping factor cyl
# idh() specifies separate effects but no covariance, like yours
m <- MCMCglmm(mpg ~ hp,
  random = ~ idh(1 + hp):cyl, data = mtcars,
  nitt = 1e5, thin = 100, burnin = 1e4, pr=TRUE, pl=TRUE)
# print model summary
summary(m)
## Iterations = 10001:99901
##  Thinning interval  = 100
##  Sample size  = 900
##  DIC: 173.4331
##  G-structure:  ~idh(1 + hp):cyl
##                 post.mean  l-95% CI  u-95% CI eff.samp
## (Intercept).cyl 1.288e+02 7.987e-17 2.642e+02    900.0
## hp.cyl          2.450e-04 1.945e-17 9.390e-04    598.7
##  R-structure:  ~units
##       post.mean l-95% CI u-95% CI eff.samp
## units     11.83    6.107    20.31    591.4
##  Location effects: mpg ~ hp
##              post.mean   l-95% CI   u-95% CI eff.samp  pMCMC
## (Intercept) 25.5884638 14.1612983 34.2822253    900.0 0.0133 *
## hp          -0.0382589 -0.0841277 -0.0002352    379.1 0.0600 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

# add two parameters, here just the intercept and slope
# but with an interaction, you could do what you want
# and calculate the HPD
HPDinterval(m$Sol[, 1] + m$Sol[, 2])
##         lower    upper
## var1 14.16873 34.27031
## attr(,"Probability")
## [1] 0.95

Cheers,

Joshua



On Wed, May 1, 2013 at 8:56 PM, Tomas Note <tomasnote@gmail.com> wrote:

> Dear list,
>
> I am fitting a model with lmer, using the following code:
>
> lmer(Y ~ b_0 + b_1*X1 + b_2*X2 + b_3*X1:X2 + (1  | groups) + (0 + X1  |
> groups), data=mydata)
>
> Where X2 is measured at the 2nd level (named groups in the code above).
>
> Then, I calculate the marginal fixed effects of X1:  b_1 + b_3*X2. But I
> would also like to calculate the HPD interval and the pMCMC for such
> marginal effect, similar to what the pvals.fnc function does for all the
> parameters of the lmer model. What would be the best way to do so, once
> pvals.fnc, mcmcsamp and HPDintervals only work with complete fitted models,
> not with particular singular values?
>
> Thanks for your time.
>
> Tom
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://joshuawiley.com/
Senior Analyst - Elkhart Group Ltd.
http://elkhartgroup.com

	[[alternative HTML version deleted]]

