Search found 6 matches

by wfleming
Tue Apr 20, 2021 2:05 pm
Forum: R2MLwiN user forum
Topic: Interaction plots for mlwinfitMCMC fixed effects
Replies: 2
Views: 1062

Re: Interaction plots for mlwinfitMCMC fixed effects

Thanks Chris this worked well. Wouldn't have worked it out without you.

Only change I made was to use bayestestR::hdi() to get credible intervals instead of the usual quantiles.
by wfleming
Wed Apr 07, 2021 4:05 pm
Forum: R2MLwiN user forum
Topic: Interaction plots for mlwinfitMCMC fixed effects
Replies: 2
Views: 1062

Interaction plots for mlwinfitMCMC fixed effects

Any recommendation for the best way to plot fixed interaction effects from mlwinfitMCMC objects? Model is simple like: m <- runmlwin(y ~ 1 + lev1x*lev1x + (1 | lev2id) + (1 | lev1id), estoptions = list(EstM = 1)) and want to plot the lev1x*lev1x Would usually use plot_model from 'sjPlot' for lm obje...
by wfleming
Mon Aug 31, 2020 11:44 am
Forum: R2MLwiN user forum
Topic: storing fitted values (propensity scores) from mlwinfitMCMC object
Replies: 7
Views: 2703

Re: storing fitted values (propensity scores) from mlwinfitMCMC object

I ran these examples and they all worked no problem so after a bit of trial and error I discovered the only reason it wasn't working is because one of the model variables was a character vector. Transforming it to factor and then running the full model allowed predict() to work. What a load of work ...
by wfleming
Thu Aug 27, 2020 8:12 pm
Forum: R2MLwiN user forum
Topic: storing fitted values (propensity scores) from mlwinfitMCMC object
Replies: 7
Views: 2703

Re: storing fitted values (propensity scores) from mlwinfitMCMC object

Here is model spec, basically just default with a bigger chain. Full formula does include a lot of variables and data is relatively large (>15k rows). f <- logit(treatment, cons) ~ 1 + level1_var + level2_var + (1 | lev2) mcmc1 <- runMLwiN(Formula = f, D = "Binomial", data = dat, estoption...
by wfleming
Thu Aug 27, 2020 2:54 pm
Forum: R2MLwiN user forum
Topic: storing fitted values (propensity scores) from mlwinfitMCMC object
Replies: 7
Views: 2703

Re: storing fitted values (propensity scores) from mlwinfitMCMC object

Thanks for getting back, Chris. I worked around the immediate need by just calculating predictions in MLwiN UI then exporting worksheet back into R but this is obviously far from ideal. I probably should have given more info in my first post but I've tried both predict, fitted and augment and receiv...
by wfleming
Thu Aug 13, 2020 9:25 pm
Forum: R2MLwiN user forum
Topic: storing fitted values (propensity scores) from mlwinfitMCMC object
Replies: 7
Views: 2703

storing fitted values (propensity scores) from mlwinfitMCMC object

I have fitted a 2-level binomial model using mcmc. I wish to use the estimated probabilities in a matching algorithm (propensity score matching). How can I extract the fitted propensity scores (the estimated prob of Y for all obs) from a mlwinfitMCMC object into a numeric object? In base R the comma...