The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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.

6,600 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1k views

3k views

How to predict state probabilities or states for new data with DepmixS4 package, for Hidden Markov Models

It seems like I can learn the parameters just fine and find the posterior probabilities for the training data but I have no clue on how to make new predictions on new data. The problem in particular ...
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 ...
1k 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 ...
1k views

Comparing two multinomial distributions

Background: Imagine a pizza cut into 8 slices. On each straight edge of the slice, I insert a magnet with opposite polarities facing outwards. If I separate these components, prevent flipping and ...
4k views

How to determine weights for WLS regression in R?

I am trying to predict age as a function of a set of DNA methylation markers. These predictors are continuous between 0 and 100. When performing OLS regression, I can see that variance increases with ...
1k views

How to test for the difference in skewness of two samples?

I have two samples. From looking at their densities, one appears symmetrical and the other from some right-tailed distribution. I would like to test that the two do not have the same skewness (...
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 ...
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 ...
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/...
744 views

Using Google Causal Impact package to assess the significance of a planned intervention

I am using the Causal Impact package in R to infer the causal effect of an intervention in some data which are highly correlated and seasonal. Specifically, i got 17 days of hourly data, intervetion ...
710 views

Random Forest: Class specific feature importance

I'm using the bigrf R-package to analyse a dataset with ca. 50.000 observations x 120 variables, classified into two groups. After growing a forest of 1000 trees, ...
513 views

Hypergeometric: how do I construct a credibility interval around K (population successes) in R?

I have a problem for which I believe I should use the hypergeometric distribution, but I can't figure out how to do it in R. Say I have a bag of marbles with known number ($N$) of marbles, but the ...
749 views

forecast::auto.arima() is not returning a model with a differencing parameter when it should

I'm experiencing an issue in which it seems forecast::auto.arima() isn't returning a model with a differencing parameter when it should. Read through my reproducible example to arrive at the question. ...
702 views

Why are (almost) all of my corrected (Benjamini-Hochberg) p-values equal?

I have the following p-values: ...
473 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 ...
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 (...
145 views

How to analyse growth rate in R?

Within the framework of an experiment I followed to growth rate of bird nestlings. I measured them every day for weight and tarsus. I have a number of continuous and categorical explanatory variables, ...
533 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 ...
282 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 ...
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: ...
504 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 ...
862 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 ...
813 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 ...
481 views

Forecasting daily visits using ARIMA with external regressors

I have daily visitors data for the last 10 years. I want to do some basic tests like which is the busiest day, which is the busiest month, busiest week etc. I used ...
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 ...
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 ...
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 ...
8k 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: ...
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: ...
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 ...
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 ...
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 ...
789 views

Johansen test conditions and Breusch-Godfrey LM test

I am a student from Belgium and I am writing a thesis about the relationship between credit aggregates and property prices. I examine the Granger causality between the two variables and I also do some ...
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, ...
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 ...
3k 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 ...
510 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 ...