Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [r]

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

20
votes
0answers
1k 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 ...
16
votes
0answers
523 views

Fitting custom distributions by MLE

My question relates to fitting custom distributions in R but I feel it has enough of a probability element to remain on CV. I have an interesting set of data which has the following characteristics: ...
11
votes
0answers
869 views

Implementation of CoVaR (a systemic risk measure) in R

I'm trying to estimate CoVaR using bivariate DCC GARCH in R. The concept of CoVaR is the dependence adjusted of VaR, which was first introduced by Adrian and Brunnermeier (2011). However, this ...
11
votes
0answers
1k 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 ...
11
votes
0answers
4k views

How to compute confidence interval in ANOVA with repeated measures?

I made a model using repeated measures univariate ANOVA in R. ...
11
votes
0answers
957 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 ...
9
votes
0answers
4k views

Specify correlation structure for different groups in mixed-effects model (lme4/nlme)

I am trying to account for spatial autocorrelation in a linear mixed-effects model in R with measurements repeated in time. BodyMass has been collected once per <...
9
votes
0answers
2k views

Gamma hurdle model for continuous response

I am modelling invertebrate.biomass ~ habitat.type * calendar.day + habitat.type * calendar.day ^ 2, with a random intercept of transect.id (50 transects were repeated 5 times) My response is zero-...
8
votes
0answers
686 views

Compute partial $\eta^2$ for all fixed effects anovas from a lme4 model

Disclamer: I wasn't sure where to post this question: CV or SO, but eventually decided to try here first I've been asked by one of the reviewers to add effects sizes (preferably $\eta^2_p$ which is ...
8
votes
0answers
462 views

The Regularization Path for Smoothing Splines

I've got a potentially interesting question. Does anyone know if R already has a package for calculating the entire regularization path of the smoothing spline? That is, for: $$\hat{f}_{\lambda}=...
8
votes
0answers
2k 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 ...
7
votes
0answers
889 views

How to generate 2 correlated Beta random variables

I was wondering if it might be possible to generate 2 correlated $Beta$ random variables? In other words, I want to generate two Beta random variables which can be said to have come from two Beta ...
7
votes
0answers
2k views

Comparing two ECDFs using Kolmogorov-Smirnov test (alternative hypothesis)

I am taking measurements of a computer system performance over time and I'd like to understand if the performance is degrading or improving as time passes.. After doing some research, I picked the KS ...
7
votes
0answers
2k views

How to use formative indicators in covariance-based SEM with lavaan?

I'm trying to build a covariance-based structural equation model (SEM) using both reflective and formative specifications of latent variables. I use the sem ...
7
votes
0answers
3k views

lmer() parametric bootstrap testing for fixed effects

I am performing a parametric bootstrap to test whether I need a specific fixed effect in my model or not. I have mainly done this for exercise and I am interested if my procedure so far is correct. ...
7
votes
0answers
2k views

Interpretation of crossed random effect interactions in lme4

I'm considering a model in lme4 in which I am estimating random effects for two crossed factors, very similar to the Machines example in Bates' 2010 draft book (http://lme4.r-forge.r-project.org/lMMwR/...
6
votes
0answers
381 views

How to estimate random-effects for new subjects for predictions (example in GNU R's lme4)

I'm wondering how to make predictions for new subjects from a fitted mixed-effects model (in a frequentist framework). Specifically, we have multiple observations on a set of subjects to which we can ...
6
votes
0answers
3k views

How to choose bootstrap confidence interval type from boot.ci in R?

The boot.ci documentation in R says there are five different types of confidence interval that boot.ci will return: norm (normal approximation) basic stud (...
6
votes
0answers
495 views

How good is an optimal design (DOE)?

I am looking at an experiment with 5 factors (4 numeric and one nominal) with three levels for each numeric and 2 levels for the nominal. Instead of the 162 runs, I am interested in a small design (30 ...
6
votes
0answers
261 views

Mixed models formulation (GAMM, GLS, nlme): from R to mathematical notation

I have just finalised the analysis of a dataset fitting Generalised additive mixed models (GAMMs) with mgcv package in R v3.3.0. But I am having trouble in writing my models into their correct ...
6
votes
0answers
1k views

Interpolation with radial basis functions (RBF) is failing for some reason

This is not a pure programming question. I am trying to understand what's going on when I try to use RBF with 5 centers. I am using R to exemplify, see below. My data set: ...
6
votes
0answers
444 views

How should I include age in this mixed-effects model?

I've got repeated measures of hearing thresholds for a set of patients who each have a different inner ear measurement. This data is unbalanced, there are a varied number of measurements at varied ...
6
votes
0answers
827 views

How to fit a function to a CDF in R?

Background: I've been given a dataframe that contains data for a CDF. The column X contains the 250 $X$ values, and the column P ...
6
votes
0answers
775 views

Confidence interval of the mean response from nonlinear model

My problem (question at the end) is to calculate confidence interval (CI) (NOT prediction interval) of the response of a nonlinear model. I am working with R but this question is not R-specific. I ...
6
votes
0answers
1k views

Relationship between Gumbel and Weibull distribution, accelerated failure time models, and Survreg using R

I have three questions concerning accelerated failure time models (AFT), one statistical, one regarding how to implement these models in R, and one related to finding out information about what R is ...
6
votes
0answers
1k views

“weight” input in glm.nb function in R. How exactly does the weight affect the likelihood?

I would like to understand how the weight argument of glm.nb is affecting the likelihood function. I understand that glm.nb find the MLE in an alternating iteration process where for a given theta the ...
6
votes
0answers
2k views

Interpreting and reporting gamm4 result

I am new to gam, and most of my knowledge comes from this document http://www3.nd.edu/~mclark19/learn/GAMS.pdf. Now I am using generalized addictive model with random effects to model some data, where ...
6
votes
0answers
7k views

covariate selection for a cox model by Lasso using glmnet

I would like to use model selection through shrinkage (Lasso) using glmnet. So far I did the following: ...
6
votes
0answers
1k 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: ...
6
votes
0answers
776 views

Optimization in R vs Python, constrained, unconstrained and automatic differentiation?

I am an economics/stat guy who uses quite a bit of optimization (maximum likelihood, simulated maximum likelihood), constrained optimization (mathematical programming w/ equilibrium conditions), ...
6
votes
0answers
1k views

R model.matrix and makeContrast. Understanding model and possible contrast

I have measurements from 12 mice, grouped in two conditions. I each mouse I have measurements from 4 tissues. The design is not balanced, 5 mice in condition1 and 7 in condition2. After reading the ...
6
votes
0answers
2k views

Appropriate negative eigenvalue correction for PCoA of genetic distances

I am trying to find the best way to represent genetic distances in a plane so that they may use them as response variables in canonical redundancy analysis (using ...
6
votes
0answers
2k views

Hyper-prior for negative binomial in hierarchical model using JAGS/BUGS

Below I'm using a negative binomial because it is more flexible than a simple poisson model. The data are counts $y$ of events for 16 individuals $x$. There are 14 counts (i.e. counting periods) for ...
6
votes
0answers
3k views

Confidence interval for the restricted mean in survival analysis

What is the recommended way of calculating confidence intervals for the restricted mean in survival analysis? Here are some example data, taken from the paper Chris Barker (2009), The Mean, Median, ...
6
votes
0answers
2k views

How to simplify coxme survival models?

I have some questions about specifying a coxme (mixed-effects Cox proportional hazards) model in R and then simplifying it after reading the ...
6
votes
0answers
2k views

Time series clustering: Fourier transform and PCA

I have biological time series (9 years long) of the biomass of species which logically exhibit a seasonal pattern. I would like to cluster them into a few groups based on their typical seasonal ...
6
votes
0answers
497 views

Calculate goodness-of-fit (with deviance) to compare averaged models?

I need to compare the goodness of fit of several averaged logistic regression models by calculating the deviance explained. I'm using the MuMIn package in R to ...
6
votes
0answers
271 views

Numerical properties of the logistic growth model for non-linear regression

I am using the nls procedure in R to fit a logistic growth model. In their SSlogis function, José Pinheiro and Douglas Bates chose the formulation ...
6
votes
0answers
91 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
452 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 ...
6
votes
0answers
103 views

How to form a confidence band around the trend fitted from time series data

I have a time series data set. I can decompose it and get the trend but I would like to put confidence ranges around the trend (past) not the forecast-ed component. The decompose function also doesn'...
6
votes
0answers
796 views

Marginal effects with logistic generalized additive model in R

I am currently working with a logistic semi-parametric model in R using the mgcv package. The output from the model gives the standard log-odds coefficients; however, reviewers have requested ...
6
votes
0answers
538 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 ...
6
votes
0answers
442 views

Programming a new random effects structure in lme

I am seeking advice on programming a new random effects variance-covariance matrix/structure (pdmat) in R for use in lme()? I've checked out the lme source code (as suggested if you want to program ...
6
votes
0answers
5k views

When to use longitudinal (panel) weights vs cross-section weights in complex surveys

I'm currently working with a longitudinal dataset, the Kauffman Firm Survey. The survey tracks about 5000 firms starting from 2004 - 2009. Firms die out over the years. It has both cross-sectional ...
6
votes
0answers
805 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 ...
5
votes
0answers
180 views

Why do PCA and PCoA give the same components but different explained variances?

I'm quite familiar with Principal Component Analysisis, as I use it to study genetic structure. Lately, I was revisiting some of the functions I was using in R (...
5
votes
0answers
40 views

Compare if two regression model behaves similarly

this is my first asking question here... forgive me if my question is not clear enough. I have two datasets; one is ground truth dataset and another is perturbed version of the same dataset. I want ...
5
votes
0answers
45 views

Non-uniform p-values from hoeffd function in Hmisc when data sets are independent

When using the function hoeffd in the CRAN package Hmisc I get unusual p-values for pairs of data sets that are independent. The function hoeffd is an implementation of Hoeffding's $D$ statistic. ...
5
votes
0answers
100 views

Why does “mixtools” return the model with highest AIC as the “winner” if lower AIC is better?

Mixtools package is used to fit mixtures of normal/regressions. The package documentation is given here The regmixmodel.sel fits the mixture model for varying ...