Displaying 20 results from an estimated 6000 matches similar to: "lmer(): nested and non-nested factors in logistic regression"
2006 May 20
5
Can lmer() fit a multilevel model embedded in a regression?
I would like to fit a hierarchical regression model from Witte et al.
(1994; see reference below). It's a logistic regression of a health
outcome on quntities of food intake; the linear predictor has the form,
X*beta + W*gamma,
where X is a matrix of consumption of 82 foods (i.e., the rows of X
represent people in the study, the columns represent different foods,
and X_ij is the amount of
2006 Jan 28
1
yet another lmer question
I've been trying to keep track with lmer, and now I have a couple of
questions with the latest version of Matrix (0.995-4). I fit 2 very
similar models, and the results are severely rounded in one case and
rounded not at all in the other.
> y <- 1:10
> group <- rep (c(1,2), c(5,5))
> M1 <- lmer (y ~ 1 + (1 | group))
> coef(M1)
$group
(Intercept)
1 3.1
2
2006 May 02
2
evaluation of expressions
Hi, all. I'm trying to automate some regression operations in R but am
confused about how to evaluate expressoins that are expressed as
character strings. For example:
y <- ifelse (rnorm(10)>0, 1, 0)
sex <- rnorm(10)
age <- rnorm(10)
test <- as.data.frame (cbind (y, sex, age))
# this works fine:
glm (y ~ sex + I(age^2), data=test, family=binomial(link="logit"),
2006 Feb 01
1
student-t regression in R?
Is there a quick way to fit student-t regressions (that is, a regression
with t-distributed error, ideally with the degrees-of-freedom parameter
estimated from the data)? I can do it easily enough in Bugs, or I can
program the log-likelihood in R and optimize using optim(), but an R
version (if it's already been written by somebody) would be convenient,
especially for teaching purposes.
2006 May 01
3
pulling items out of a lm() call
I want to write a function to standardize regression predictors, which
will require me to do some character-string manipulation to parse the
variables in a call to lm() or glm().
For example, consider the call
lm (y ~ female + I(age^2) + female:black + (age + education)*female).
I want to be able to parse this to pick out the input variables
("female", "age",
2007 Feb 11
2
problem with Matrix package
I decided to update my packages and then had a problem with loading the
Matrix package
http://cran.at.r-project.org/bin/windows/contrib/2.4/Matrix_0.9975-9.zip
This is what happened when I tried to load it in:
> library("Matrix")
Error in importIntoEnv(impenv, impnames, ns, impvars) :
object 'Logic' is not exported by 'namespace:methods'
Error:
2006 Feb 10
1
mcmcsamp shortening variable names; how can i turn this feature off?
I have written a function called mcsamp() that is a wrapper that runs
mcmcsamp() and automatically monitors convergence and structures the
inferences into vectors and arrays as appropriate.
But I have run into a very little problem, which is that mcmcsamp()
shortens the variable names. For example:
> set.seed (1)
> group <- rep (1:5,10)
> a <- rnorm (5,-3,3)
> y <-
2006 Jan 08
1
lmer with nested/nonnested groupings?
I'm trying to figure out how to use lmer to fit models with factors that
have some nesting and some non-nested groupings. For example, in this
paper:
http://www.stat.columbia.edu/~gelman/research/published/parkgelmanbafumi.pdf
we have a logistic regression of survey respondents' political
preferences (1=Republican, 0=Democrat), regressing on sex, ethnicity,
state (51 states within 5
2006 Jan 10
1
another question about lmer, this time involving coef()
I'm having another problem with lmer(), this time something simpler (I
think) involving the coef() function for a model with varying
coefficients. Here's the R code. It's a simple model with 2
observations per group and 10 groups:
# set up the predictors
n.groups <- 10
n.reps <- 2
n <- n.groups*n.reps
group.id <- rep (1:n.groups, each=n.reps)
# simulate the varying
2006 May 09
1
trying to use standard notation
Hi, all. In setting up my package for post-processing regression
models, I am trying to use standard notation as much as possible: thus,
I use coef() to access estimated coefficients. I wrote a function
called se.coef() to grab standard errors, and se.fixef() and se.ranef()
to grab se's from coefficients estimated from lmer().
I also need a function to access sigma-hat (the residual sd
2007 Dec 03
1
difficulties getting coef() to work in some lmer() calls
I'm working with Andrew Gelman on a book project and we're having some
difficulties getting coef() to work in some lmer() calls.
Some versions of the model work and some do not. For example, this works
(in that we can run the model and do coef() from the output):
R2 <- lmer(y2 ~ factor(z.inc) + z.st.inc.full + z.st.rel.full + (1 + factor(
z.inc) | st.num),
2006 Jun 20
1
Bayesian logistic regression?
Hi all.
Are there any R functions around that do quick logistic regression with
a Gaussian prior distribution on the coefficients? I just want
posterior mode, not MCMC. (I'm using it as a step within an iterative
imputation algorithm.) This isn't hard to do: each step of a glm
iteration simply linearizes the derivative of the log-likelihood, and,
at this point, essentially no
2007 Apr 27
1
Example of mcmcsamp() failing with lmer() output
Hi,
I would appreciate help with the following model
<<1>>=
gunload <- read.table(hh('datasets/gunload.dat'), header = T)
gunload$method <- factor(gunload$method, labels = c('new', 'old'))
gunload$physique <- factor(gunload$group, labels = c('slight',
'average', 'heavy'))
gunload$team9 <- factor(rep(1:9, each = 2))
@
This
2008 Dec 20
2
Problems installing lme4 on Ubuntu
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
While I'm not an R expert, I have used R on Windows XP. Now I've moved
to Ubuntu (Intrepid), and I'm trying to configure R to work with the
Gelman and Hill _Data Analysis Using Regression and
Multilevel/Hierarchical Models_. So far, it's not working.
I start by following the instructions for installing arm and BRugs at
2008 Apr 13
2
prediction intervals from a mixed-effects models?
How can I get prediction intervals from a mixed-effects model?
Consider the following example:
library(nlme)
fm3 <- lme(distance ~ age*Sex, data = Orthodont, random = ~ 1)
df3.1 <- with(Orthodont, data.frame(age=seq(5, 20, 5),
Subject=rep(Subject[1], 4),
Sex=rep(Sex[1], 4)))
predict(fm3, df3.1, interval='prediction')
# M01 M01
2008 Aug 09
1
Converting nested "for" loops to an "apply" function(s)
Hello,
I would like to know more about how to use the "apply" family and have attempted to convert nested "for" loops in example code from Contributed Documentation ("The Friendly Beginners' R Course? by Toby Marthews (ZIP, 2007-03-01)") to an "apply" function(s). The relevant code is:
distances=c(51,65,175,196,197,125,10,56) #distances of 8 houses
2009 May 25
3
Interpolating variables within (RODBC library) SQL statements for MySQL
Hi everyone,
I am desperately looking for a method to interpolate strings within an SQL
statement as follows:
I get a lot of rows out of a database (in my example POSITION_to_ZIPCODE
Database with holds records for German ZIP Code <--> Gauss-Krueger
Coordinate System ) and want this to be selected and computed individually
row by row as follows:
library(RODBC)
channel <-
2005 May 16
1
A question about bugs.R: functions for running WinBUGs from R
Dear R users,
I've found bugs.R : the functions for running WinBUGs from R that is
writen by Dr. Andrew Gelman who is a professor from Columbia University.
The bugs.R would be very useful for me, and I think many of you know it
as well. I followed the instuctions on Dr. Gelman's web to install all
of documents that bugs.R needs, but when I try to run the school example
the web posted in
2011 Jan 01
3
Plot symbols: How to plot (and save) a graphic symbols originating from a table
Dear all,
Please, I have a doubt regarding symbol plotting
with data originating from a table.
Please, see below:
I have a tab delimited file called table1.txt with 4 columns:
ypos animal var1 var2
5 cat gina <= lady gina \u2264 lady
7 dog bill >= tony bill \u2265 tony
9 fish dude <= bro dude \u2264 bro
#I then load in the data to R:
table1<-read.table("table1.txt",
2010 Dec 02
4
2D Random walk
I've wrote some code to simulate a random walk in 2 dimensions on a lattice.
Basically I want to add something in to make it plot it point by point so
you can see what is going on.
Heres my code for the random walk in 2d
RW2D<-function(N)
{
i<-0
xdir<-0
ydir<-0
xpos<-vector()
xpos[1]<-xdir
ypos<-vector()
ypos[1]<-ydir
for (i in 1:N-1)