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`.

learn more… | top users | synonyms

11
votes
0answers
386 views

What are the options in proportional hazard regression model when Schoenfeld residuals are not good?

I am doing a Cox proportional hazards regression in R using coxph, which includes many variables. The Martingale residuals look great, and the Schoenfeld residuals ...
8
votes
0answers
452 views

MLEs from glmer {lme4} in R

Numerically deriving the MLEs of GLMM is difficult and, in practice, I know, we should not use the brute force optimization (e.g., using optim in a simple way). But ...
8
votes
0answers
1k views

How to analyze longitudinal count data: accounting for temporal autocorrelation in GLMM?

Hello statistical gurus and R programming wizards, I am interested in modeling animal captures as a function of environmental conditions and day of the year. As part of another study, I have counts ...
7
votes
0answers
2k views

What does the anova() command do with a lmer model object?

Hopefully this is a question that someone here can answer for me on the nature of decomposing sums of squares from a mixed-effects model fit with lmer (from the ...
7
votes
0answers
234 views

p-value adjustment for Local Moran's I statistic (LISA)

I'm working with some exploratory spatial analysis in R using spdep package. I came across an option to adjust p-values of local indicators of spatial association (LISA) calculated using ...
7
votes
0answers
2k views

Unable to fit negative binomial regression in R (attempting to replicate published results)

Attempting to replicate the results from the recently published article, Aghion, Philippe, John Van Reenen, and Luigi Zingales. 2013. "Innovation and Institutional Ownership." American Economic ...
7
votes
0answers
405 views

Predicting count data with random forest

Can a Random Forest be trained to appropriately predict count data? How would this proceed? I have quite a extensive range of values so classification doesn't really make sense. If I would use ...
7
votes
0answers
370 views

Can these data be aggregated into a proportion for a binomial glm?

We asked 60 people to list as many restaurant franchises in Atlanta as they could. The overall list included over 70 restaurants, but we eliminated those that were mentioned by fewer than 10% of the ...
6
votes
0answers
83 views

What is the name of the density estimation method where all possible pairs are used to create a Normal mixture distribution?

I just thought of a neat (not necessarily good) way of creating one dimensional density estimates and my question is: Does this density estimation method have a name? If not, is it a special case of ...
6
votes
0answers
93 views

Why are confidence intervals for predicted values so large?

The data for this question can be downloaded with this code: ...
6
votes
0answers
293 views

Failing at linear regression / prediction on a real data set

I have a data set on which I'm trying to do regression, and failing. The situation: Thousands of battle robot operators are fighting battles among each other using battle robots. Some battle robots ...
6
votes
0answers
305 views

Lasso on Negative Binomial Regression Model

Is there anyway that I can perform LASSO with Negative Binomial Regression on R? I am performing a negative binomial regression on my dataset because the data are too dispersed to impose poisson ...
6
votes
0answers
413 views

Contrast matrix definition

What exactly is contrast matrix and how exactly is contrast matrix specified? I.e. what are columns, what are rows, what are the constraints on that matrix and what does number in column ...
6
votes
0answers
113 views

Standard errors from flexsurvreg

I'm using the flexsurv package (in R) to fit an exponential distribution to the veteran ...
6
votes
0answers
59 views

Territories from observations

I have a number of animal observations, and want to deduce the number of territories (i.e. the number of individual animals) from this. More formally, the problem can be stated as follows: Each ...
6
votes
0answers
2k views

Choosing complexity parameter in CART

In the rpart() routine to create CART models, you specify the complexity parameter to which you want to prune your tree. I have seen two different recommendations for choosing the complexity ...
6
votes
0answers
1k views

How to compute confidence interval in ANOVA with repeated measures?

I made a model using repeated measures univariate ANOVA in R. ...
6
votes
0answers
457 views

Modeling a spline over time — design matrix and survey of approaches

A response variable y is a nonlinear function of a number of predictor variables X (in my real data the response is binomially distributed, but here I'm using a normally-distributed value for ...
6
votes
0answers
527 views

Testing for a significant difference between ML estimates: Likelihood ratio or Wald test?

I am trying to test whether or not there is a significant difference between maximum likelihood estimates of two genetic parameters (selection and dominance) across two environments with genotype data ...
6
votes
0answers
258 views

Tree size in gradient tree boosting

Gradient tree boosting as proposed by Friedman uses decision trees with J terminal nodes (=leaves) as base learners. There are a number of ways to grow a tree with ...
6
votes
0answers
101 views

Is there an equivalent of ARMA for rank correlation?

I am looking at extremely non linear data for which the ARMA/ARIMA models do not work well. Though, I see some autocorrelation, and I suspect to have better results for non linear autocorrelation. 1/ ...
5
votes
0answers
204 views

glmer in R: Significance estimates are not robust to order of data frame

I'm using a mixed effects model with logistic link function (using lme4 version 1.1-7 in R). However, I noticed that the estimates of significance for fixed effects change depending on the order of ...
5
votes
0answers
115 views

How to deal with underdispersion with binomial data

I'm working with a pretty large dataset (n = 4,500) where 10% of my points (pixels in a GIS landscape) are 1s and the rest are 0s. The full model for my data looks something like this: ...
5
votes
0answers
170 views

How to create a multivariate Brownian Bridge

It is known, that a standard multivariate Brownian bridge $ y(\mathbf u) $ is a centered Gaussian process with covariance function $$ \mathbb E(y(\mathbf u) y(\mathbf v)) = \prod_{j=1}^d (u_j \wedge ...
5
votes
0answers
228 views

Comparing ISOMAP residual variance to PCA explained variance

I am using R princomp function (from stats package) to run a PCA on a data set and I want to compare its output to that of the ...
5
votes
0answers
565 views

Meaning of a convergence warning in glmer

I am using the glmer function from the lme4 package in R, and I'm using the bobyqa optimizer ...
5
votes
0answers
103 views

Compressed sensing: Optimization in $L_1$ norm and total variation with fourier coefficients

I'm reading the article Robust Uncertainty Principles: Exact Signal Reconstruction from Highly Incomplete Frequency Information (Candes, Romberg and Tao, 2004). In this article they are talking ...
5
votes
0answers
166 views

Structure of data and function call for recurrent event data with time-dependent variables

I'm attempting to estimate the effect of 2 drugs (drug1, drug2) on the likelihood of a patient falling (...
5
votes
0answers
166 views

Post hoc tests for robust mixed design ANOVA using R

Is it possible to compute the function mcp2atm with unequal sample size? I ran the robust Mixed Design ANOVA by using tsplit and ...
5
votes
0answers
528 views

Which model for panel data with dependent variables from [0,1]?

I'm stuck with a regression modeling problem. I have panel data where the dependent variable is a probability. Below is an excerpt from my data. The complete panel covers more countries and years, ...
5
votes
0answers
555 views

Bayesian analysis with histogram prior. Why draw simulations from the posterior?

This is a beginner’s question on an exercise in Jim Albert’s “Bayesian Computation with R”. Note that while this might be homework, in my case it is not, as I am learning Bayesian methods in R because ...
5
votes
0answers
455 views

Interpretation of Conditional Density Plots

I would like to know how to correctly interpret conditional density plots. I have inserted two below that I created in R with cdplot. For example, is the ...
5
votes
0answers
530 views

Stationarity tests for time series

I am currently working on time series modeling, especially on stationarity tests. For this purpose, I am extensively using Pfaff's book "Analysis of integrated and cointegrated time series with R" and ...
5
votes
0answers
458 views

The role of scale parameter in GEE

I am learning the generalized estimating equations (GEE) and the geepack R package. There are some questions that I am a little confused. In a GEE-constructed ...
5
votes
0answers
672 views

How to interpret coefficients of a multivariate mixed model in lme4 without overall intercept?

I'm trying to fit a multivariate (i.e., multiple response) mixed model in R. Aside from the ASReml-r and ...
5
votes
0answers
258 views

Average Structural Function Calculation

EDIT: I have solved this problem myself. The problem with the simulation below is that the omitted variable should not be included in the 'true model'. I have written a blog post with a more detailed ...
5
votes
0answers
550 views

Asynchronous (irregular) Time Series Analysis

I am trying to analyze the lead-lag between time series of two stock prices. In regular time series analysis, we can do Cross Correlaton, VECM (Granger Causality). However how does one handle the ...
5
votes
0answers
255 views

Regression line envelope from Census ACS data

Context: I’m working with the Census Bureau’s American Community Survey (ACS) data which are samples (not complete enumerations) aggregated at different spatial scales. Each ACS estimate is provided ...
5
votes
0answers
351 views

Binomial mid-p value

I've been under the impression that the mid-$p$ values generally control the Type I error, and consequently confidence intervals based on mid-$p$ values control the coverage. However I have checked ...
5
votes
0answers
250 views

Crossed random effects and unbalanced data

I am modeling some data where I think I have two crossed random effects. But the data set is not balanced, and I'm not sure what needs to be done to account for it. My data is a set of events. An ...
5
votes
0answers
681 views

Propagation of uncertainty/standard deviations in biological experiments

I am trying to work out how to propagate standard deviations in a biological experiment, but I have some difficulties. I have the following (semi)fictitious data originating from an image analysis ...
5
votes
0answers
912 views

Mixed model with repeated measures and both of two treatments with lme or lmer in R

I know just enough about lme() and lmer() to get myself by with simple models, and to get myself into trouble with more complex ...
5
votes
0answers
421 views

Fitting a special mixed model in R - alternatives to optim()

I would like to do something in R that SAS can do using SAS's proc mixed (there is some way to do in STATA es well), namely fitting the so called Bivariate model from Reitsma et al (2005). This model ...
5
votes
0answers
373 views

Canonical correlation analysis on a MICE data set

I am looking to do a canonical correlations analysis (CCA) in R, using the CCA package, on a multiply imputed dataset (obtained from the mice package). I know that ...
4
votes
0answers
29 views

Does Breiman's random forest use information gain or Gini index?

I would like to know if Breiman's random forest (random forest in R randomForest package) uses as a splitting criterion (criterion for attribute selection) information gain or Gini index? I tried to ...
4
votes
0answers
22 views

R HoltWinters - Odd dip in predictions

So, I have this time series that tracks the daily number of applications to a graduate program. Each application period is 64 days - so for each period, you start at zero and it goes up until the ...
4
votes
0answers
69 views

Correct standard errors for weighted linear regression

What is the correct way to calculate the standard errors of the coefficients in a weighted linear regression? The regression equation I am using is $y_i = a + bx_i$, and I have weights, $w_i = ...
4
votes
0answers
91 views

Bootstrap: estimate is outside of confidence interval

I did a bootstrapping with a mixed model (several variables with interaction and one random variable). I got this result (only partial): ...
4
votes
0answers
64 views

Test for trend (ordinal predictor, continuous outcome)?

I have measured a continuous outcome variable in three groups of patients, where the groups are related to the severity of disease (control, mild disease, severe disease). I would like to test for a ...
4
votes
0answers
77 views

Why is glmnet giving me different answers than ridge estimation

I'm using glmnet to calculate ridge regression estimates. I got some results that made me suspicious in that glmnet is really doing what I think it does. To check this I wrote a simple R script where ...