Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Use this tag for any *on-topic* question that (a) involves `R` either as a critical part of the question or expected answer, & (b) is not *just* about how to use `R`.
4
votes
How to interpret a negative correlation of random effects in a mixed-effects model (in R)?
In addition to the explanation @BenBolker provided, you might find this graph on "Covariance between intercepts and slopes" by the Centre for Multilevel Modelling useful.
7
votes
Accepted
Is it possible to construct a discrete-time multilevel hazard model in R?
Yes, you can use R and lme4 for fitting discrete-time multilevel hazard models. According to Hox (2010, p. 163) "[t]he discrete or grouped survival model extends readily to multilevel models [...]". … Please find below the table from Hox' book:
And here is the corresponding R code and the results based on lme4. …
2
votes
After trying various optimzers, model simplification running more iterations, when fitting G...
Variable Set has only 6 categories. My guess is that this is not enough information to appropriately estimate the variance of the random effects. Most books on multilevel modeling suggest sample sizes …
6
votes
Accepted
Forest plot for meta-analysis displaying the mean ES with and without outliers
Here is an update of the R code and the plot:
library(metafor)
data(dat.bcg)
## REM (k = 13)
res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, measure="RR",
slab=paste(author, …
5
votes
Accepted
Get a desired percentage of censored observations in a simulation of Cox PH Model
with:
## R: A p x p correlation matrix
## mu: Vector of means
## SD: Vector of standard deviations
## S: Variance-covariance matrix
R <- matrix(c(rep(r, p^2)), ncol = p)
diag(R … ) <- 1
R
mu <- rep(0, p)
SD <- rep(1, p)
S <- R * (SD %*% t(SD))
X <- mvrnorm(n, mu, S)
cov(X)
cor(X)
sqrt(diag(cov(X)))
## Calculate survival times
T <- (-log( …
7
votes
Discrete-Time Event History (Survival) Model in R
For most book chapters there is R sample code (see chapters 11ff) available that demonstrates how your data has to be structured ("person-period format") and how to analyze that kind of data. …
6
votes
Accepted
Using glmer to replicate result from lmer for mulitlevel modelling in R
Did you check the help page of lmer? It is pretty clear about the relationship between lmer and glmer:
The ‘lmer’ and ‘glmer’ functions are nearly interchangeable. If
‘lmer’ is called with a no …
4
votes
Accepted
R software implementation of combining mixed treatment comparisons and meta-regression
I cannot help you with an R implementation of the Nixon et al. paper. …
4
votes
Estimating population average models in lmer or geepack
You might want to search for R packages that can fit generalized estimating equations (GEE), for example the package geepack or gee. …
7
votes
Accepted
Multilevel regression using lmer function in R and Stata
Fitting varying intercept/slope models in Stata and R
@Jens already has pointed out how to write Stata's xtmixed model in R. … to estimate simple MLMs in Stata and R. …
2
votes
Accepted
Test in R of whether three or more correlations from independent samples are equal
Most meta-analysis packages in R can do this test, for instance, meta or metafor. … I will provide an example for the meta package (differences are due to rounding errors):
library(meta)
library(psychometric)
dfr <- data.frame(r=c(0.2, 0.5, 0.6), n=c(200, 150, 75))
dfr$z <- r2z(dfr$r …
14
votes
Are misses in my data distributed completely at random?
The second question is about (an) appropriate R package(s). … ]
(2) (Some) Missing data related R packages
Some of these packages also have functions to explore patterns of missingness (e.g., missing.pattern.plot() in the mi package). …
23
votes
Accepted
Boxplot with respect to two factors using ggplot2 in R
I can think of two ways to accomplish this:
1. Create all combinations of f1 and f2 outside of the ggplot-function
library(ggplot2)
df <- data.frame(f1=factor(rbinom(100, 1, 0.45), label=c("m","w" …
4
votes
Accepted
Checking $R$ functions arguments
You could use something like formals() or args(), e.g. formals(glm) gives:
> formals(glm)
$formula
$family
gaussian
$data
$weights
$subset
$na.action
$start
NULL
$etastart
$mustart
$o …
20
votes
Accepted
R package for multilevel structural equation modeling?
It seems that OpenMx (based on Mx but it's now an R package) can do what you are looking for: "Multi Level Analysis" …