We’re rewarding the question askers & reputations are being recalculated! Read more.

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,671 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
0answers
1k 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
807 views

Correlate bivariate Brownian bridges

Given two independently constructed Brownian bridges (from their marginal means and variances), is there a way to correlate the sample paths?
5
votes
0answers
2k views

Examples of spatial generalized linear models

I've been reading some materials on Spatial data analysis, and I've a good background in GLMs. Right now I'm looking to find an example in spatial generalized linear models, but so far I've not found ...
5
votes
0answers
419 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
2k views

What is the confidence interval calculated in a spectral density periodogram in R?

This question is similar to the one posed here: Testing significance of peaks in spectral density In that post, Pantera asks how to test whether a peak in a periodogram has a spike that is ...
5
votes
0answers
659 views

How to implement a two-stage hierarchical model of time series data in R?

I'm currently working with a data set that consists of a monthly case count for several sites, along with a number of site-specific covariates. We're trying to estimate the effect of one of them on ...
5
votes
0answers
1k 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
4k views

Calculate Mantel-Haenszel test in R

I would like to have a reality check of my understanding of the MH statistic. I have been trying to reproduce an example of the Mantel-Haenszel test provided in Conover (1999, p. 192-194). The data ...
5
votes
0answers
2k 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
419 views

CIR Process-Variance reduction

I'm trying to evaluate a path dependent function, $f(r_t)$, on a Cox-Ingersoll-Ross process: $$dr_t = \theta (\mu - r_t)dt + \sigma \sqrt r_t dW_t$$ by Monte Carlo simulation. Could anyone suggest ...
4
votes
0answers
91 views

How does random variable nesting in GAMs work (mgcv)?

Consider me very new to the world of GAMs, I am actually using it out of necessity rather than by choice but I thought it could be a chance to learn something new anyway. Originally I had hoped to ...
4
votes
0answers
96 views

Is this a random or a fixed effect?

I have a question about one of the variables in my study and whether or not it should be considered a random effect. I'm conducting a study of my school's 24 general learning outcomes (or "skills".) ...
4
votes
0answers
43 views

Implementation of EM algorithm confusion

Here EM algorithm manually implemented, there's a question of the implementation in R of the EM algorithm for 2 mixed gaussians. The answer has a supposedly correct implementation. However, don't the ...
4
votes
1answer
84 views

Should I use a linear mixed model or a generalized mixed model?

I have a test dataset with repeated measures, different individuals sampled at different time points, here measured in days. I want to know if I should use a GLMM or a LMM to see how well, if at all, ...
4
votes
1answer
89 views

If the quadratic term is significant but the linear term is not, we must add the linear term to the model too?

I have a linear mixed effect model and I add the quadratic term of time in my model and it was significant and improve the AIC & BIC of the model, but the problem is that the linear term of time ...
4
votes
0answers
260 views

Intraclass correlation coefficient (ICC) for two raters using a mixed effects model for a design with repeated measurements

I want to calculate the intraclass correlation coefficient (ICC) for an inter-rater assessment with two raters. The design is as follows: Each of the $n$ subjects were assessed by the same 2 raters on ...
4
votes
0answers
116 views

Mixed-effects logistic regression

I'm new to data analysis and I'm trying to perform a mixed-effect logistic regression. My data look like this: ...
4
votes
0answers
72 views

How to infer a prior belief after observing a behavior

My participant goes through a maze made of 32 T intersections. At each intersection he must choose whether to go either to the left or to the right: one option will lead to another T intersection, ...
4
votes
0answers
301 views

Simulate/Generate Data for Multinomial Logistic regression

How to simulate data for Multinomial Logistic regression? For Example i want to generate a high dimensional data set with 90 subjects and 500 independent predictors. The ratio of Classes should given ...
4
votes
0answers
179 views

Do results from the lme-function require adjustment of p-values?

If I run a linear mixed model with the lme() function and get results like these (comparing the score of 4 treatment groups against a placebo group): ...
4
votes
0answers
82 views

3 outcomes: one ordinal regression or two logistic regressions?

Imagine, for example, I am fitting a model with the following data: ...
4
votes
0answers
236 views

Why are the prediction error estimate and the true prediction error negatively correlated?

Section 12.2 of Computer Age Statistical Inference reports simulation results that indicate that the cross-validated estimate of the prediction error for a given prediction rule is negatively ...
4
votes
0answers
350 views

How to handle crossed and nested terms in a crossover design

Here comes my case: I conducted an experiment with the following design: 30 participants, each with a unique id, were screened and classified according to a trait. Then, all participants were tested ...
4
votes
0answers
1k views

Generate Beta distribution from Uniform random variables

I need to generate random numbers from Beta distribution using random variables from Uniform distribution. If I have two random variables $Y_1=U_1^{1/\alpha}$ and $Y_2=U_1^{1/\beta}$, and If $Y_1+Y_2&...
4
votes
0answers
645 views

Interpreting GBM interact.gbm

I am learning GBM with a focus on the interactions side of things I am aware of the H statistic which ranges from 0-1 where large values indicate strong effects. I ...
4
votes
0answers
62 views

What statistical test should I use? (GLMM and comparing 4 groups)

I'm analyzing the following case: I have a continuous response variable (named Vueltasmin), that allows positive, negative and null values, and factors as explanatory values (the explanatory variable ...
4
votes
1answer
2k views

Generalized least squares results interpretation

I checked my linear regression model (WMAN = Species, WDNE = sea surface temp) and found auto-correlation so instead, I am trying generalized least squares with the following script; ...
4
votes
0answers
264 views

Understanding svycontrast in R with simple random sampling

I'm taking a class on survey sampling and I have some problem understanding the R implementation of simple random sampling (SRS). Please look at this piece of code: ...
4
votes
0answers
2k views

Influence plot for potential outlier detection from logistic regression in R

I am looking into identifying extreme values from their contribution to a binary outcome model. I have an unbalanced set and some extreme values which are part of the smaller set to predict (i.e ...
4
votes
0answers
268 views

Non-Linear modelling in R

I have a dataset which contains Retention (DV) and Customer Satisfaction data (IV, 7 variables, scale 1-10) for 55000 observations. Now I want to know which increase in number has the biggest impact ...
4
votes
1answer
69 views

Modelling % cover that do not add up to 100% : GLM distribution families

I have an experimental set-up that consists in studying the impact of diversity of plant mixtures on the development of invasive species. On each plot, we recorded the % cover of each species which ...
4
votes
0answers
153 views

How the Error() term in aov() decides what goes in which stratum?

I am trying to understand how the principles of nested anova in R, but I am having extreme difficulty with the error term. Imagining the simplest case. I measured plant growth in two places, A and B. ...
4
votes
0answers
539 views

Why using offset for a Gamma (link=log) glm doesn't yield the same predicted average response as the average observed?

One of my analyst asked me why his Gamma/link=log glm with offsets was always overstating his observed data points. I was able to reproduce the behavior in R with intercept only glm using offsets. ...
4
votes
0answers
924 views

How to write mathematical formula describing my lmer model?

I have the following model fitted using the lme4 package in R: mod <- lmer(var1 ~ var2 * var3 + (1|var4) , data=s1, REML=F) ...
4
votes
1answer
364 views

How to judge whether to model a time series additively or multiplicatively?

I don't know how to to identify whether my time series is additive or multiplicative using decompose() command in R. It is a monthly time series.
4
votes
0answers
2k views

Which gam.check() output is most reliable in mgcv R package?

I have been studying Simon Wood's excellent book to aid my understanding and analysis of GAMs to my data, in addition to looking at some application papers of mgcv. The gam.check() function outputs ...
4
votes
0answers
214 views

The method of knock-offs by Barber & Candes for variable selection and FDR control

The knock-off method is a recent approach to variable selection and FDR control presented in two papers to be found here https://statweb.stanford.edu/~candes/papers/FDR_regression.pdf and here https://...
4
votes
0answers
235 views

Custom metric for model selection in auto.arima

I'm using the auto.arima function of theforecast package. I would like to perform the model selection using a custom metric ...
4
votes
1answer
316 views

Mclust: Data frame order affects solution

I've come across some behavior in mclust::Mclust that I would not have expected, which is that the order of variables in the data passed to ...
4
votes
0answers
494 views

Interpreting intercept of parametric AFT survival model (predict.survreg output)

I am trying to work out under what circumstances you would use the 'response' function in the survreg.predict function in r. I have read an excellent response by Tery Therneau, author of the survival ...
4
votes
0answers
186 views

Samples size with sample proportion close to 0 or 1

For a future monitoring program on small water bodies we want to calculate the sample size. The bodies of water are so small that their number easily exceeds 100.000 in the monitoring area and ...
4
votes
0answers
942 views

Copula-based Value-at-risk in R

I'm working on a value-at-risk calculation using copulas on different stock market indices. I know how to fit the copula, but I can't figure out how to apply the VaR approach in the next step. The ...
4
votes
0answers
124 views

Choosing between two available packages for multinomial logit on panel data in R

There are two available packages for estimating multinomial logit models in R, namely mnlogit and mlogit. I am wondering whether someone who used both can share his experience. Which one is better / ...
4
votes
2answers
227 views

Why can a regression tree not identify a perfect predictor?

If a dataset contains a perfect predictor a linear regression is able to identify this variable. Why is it that a tree model cannot do the same? In the R code below, the dataframe df contains an ...
4
votes
0answers
899 views

Beta regression in R (betareg) - parameter intepretation

In a simple model, x is a continuous (normally distributed) variable predicting y. Since y ...
4
votes
0answers
216 views

Modern approaches to nonlinear regression which are available in R

I would like to fit a complex nonlinear regression model: basically, I have a complex computer code which has an input vector $\mathbf{x}$, a vector of calibration parameters $\boldsymbol{\theta}$ and ...
4
votes
0answers
237 views

R bayesglm: Estimates depends on order of variable

I did a logistic regression with bayesglm from package arm. I got different results depending on the order of the variables in the model: ...
4
votes
0answers
351 views

Post hoc comparison in GAM models

I'm analysing some roe deer biological traits with a gam in mgcv. One of my variable is a factor with nine levels (i.e represents a combination of litter size and sex: M, F, FF, MF and so on) and my ...
4
votes
0answers
406 views

Quantile approximation using Cornish-Fisher expansion

I am trying to approximate a set of quantiles from the estimated mean, variance, skewness and kurtosis of a random variable with unknown distribution. I tried to apply the Cornish-Fisher expansion of ...
4
votes
0answers
67 views

GLMM for binomially distributed outcome, testing differential hypothesis

I am trying to find a way, to investigate differences between conditions in an experiment. The design is as follows: Depended Variable: Logical (answer is correct [correct accepted or correct ...