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

7,544 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
0answers
499 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
108 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
626 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
461 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
830 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 ...
6
votes
1answer
767 views

How do I compare date-ranges from a time series?

I have a time series which contains monthly readings for air pollution in a city. The seasonality from this time series has been removed. Given two date ranges, for example Jan-Aug 2008 and Jan-Aug ...
5
votes
0answers
109 views

Chow Test: Do you need stationarity to model a time-series for identifying structural breaks?

What am I trying to achieve? I am trying to test whether there is a structural break in a time-series of proportions at a known break date (21 Dec 2019) . Below is a plot of the original time-series (...
5
votes
0answers
181 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 ...
5
votes
1answer
247 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, ...
5
votes
0answers
401 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
341 views

“Hierarchical” Random forests?

Background I am using Random Forest to classify ~900 objects based on a large number (> 80) predictors. I split these 70:30 for training and testing. The overall model does fairly well, giving an ...
5
votes
1answer
114 views

Evaluating if time series need differencing

I am a total beginner with time series analysis. I use R. I understand that time series data need to be stationary for analyses like cross-correlation or modeling. I am, however, struggling with ...
5
votes
0answers
74 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
177 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 ...
5
votes
1answer
224 views

How do I simulate a random valid correlation matrix of ordinal variables given a list of marginal probabilities?

I am trying to use R to simulate random variations in a real dataset with a known number of categorical and continuous predictor variables, as well as known marginal probabilities for each ordinal/...
5
votes
0answers
1k views

What is the difference between Lasso regression in glmnet (in R) and Sklearn lasso (in Python)?

A similar post was discussed here regarding Ridge Regression: What are the differences between Ridge regression using R's glmnet and Python's scikit-learn? My question is what is this ...
5
votes
0answers
122 views

Does it makes sense to calculate a correlation between two binary variables?

I have a data set with 14 binary variables. I conducted a survey and there was a question with 14 elements of a specific method to which the respondents had to check if they used the element. Now I ...
5
votes
0answers
474 views

Longitudinal mixed model: What random effects are possible?

I'm faced with analyzing the following design: In a longitudinal study, the muscle tissue of about 25 subjects are analyzed at 8 timepoints. Specifically, 7 measurements are taken during a race ...
5
votes
0answers
1k views

Odds ratio MLE calculation: unconditional vs conditional?

I am running an odds ratio calculation for site methylation amongst cases and controls. In this situation is it preferable to use a conditional or unconditional MLE? I am asking because R uses a ...
5
votes
0answers
569 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 ...
5
votes
0answers
854 views

Can a factor be regarded as both random and fixed effect?

I have a question about nested mixed effect model. For example I have species A with different populations; these populations belong to two kinds of habitat types (with or without predators). So I ...
5
votes
0answers
299 views

Optimum approximate theory D-Optimal design

I am using optFederov, from package AlgDesign, to create D-Optimial designs. However, I am a bit confused on what measure to use as efficiency measure. I'd like to use D-Optimal but I don't know which ...
5
votes
1answer
269 views

Ensemble learning with time-varying covariates and effects

We are interested in replicating several duration studies in the literature using ensemble learning methods. After some experimentation, we opted for random survival forests (Ishwaran et al. 2008) for ...
5
votes
0answers
1k views

ROC curves for repeated measures

I am trying to model ROC curves for a longitudinal dataset where participants were measured between 1-13 times. Time is not of interest but the fact that the measurements are autocorrelated an issue. ...
5
votes
0answers
2k views

Interpreting Negative Binomial Time-Series

I'm working with time-series data for someone else that counts events related to emergency departments over a 48-month period during which closures occurred and would like to investigate the effect of ...
5
votes
0answers
1k views

Linear mixed effect model with fractional/proportional outcome: choosing between binomial and beta

I'm looking to run a linear mixed effect model using lme4, where my dependent variable one_syllable_words / total_words_generated is a proportion and my random ...
5
votes
1answer
823 views

Multivariate differences between groups controlling for one factor (MANOVA)

I have a sample of 100 participants who have scores on 5 different variables (V1-V5). Some participants took part in a workshop, others did not. I am interested in investigating the influence of ...
5
votes
0answers
632 views

Interpretation of glmmPQL() spatial autocorrelation output

I am modeling binominal data with random effects and spatial autocorrelation using MASS::glmmPQL(). Plotting the residual semivariogram of a model fit without ...
5
votes
0answers
694 views

Missing value imputation in huge dataset

I have a huge data (4M x 17) that has missing values. Two columns are categorical, rest all are numerical. Given the huge amount of data, running any imputation method runs forever. What should I do? ...
5
votes
0answers
482 views

Spinograms vs. conditional densityplots

I have a binary response variable (hail) and multiple continuous predictor variables. My aim is to understand the linear/non-linear relationship of the predictors to the response to be able to justify ...
5
votes
0answers
1k views

Will Tukey multiple comparison be the same for different types of Sum Of Squares of ANOVA for an unbalanced design

I am working on Two-Way ANOVA for an unbalanced design. Will Tukey multiple comparison be the same for different types (I, II & III) of Sum Of Squares of ANOVA for an unbalanced design. I am ...
5
votes
0answers
3k views

Is it possible to do a time series analysis with more than one explanatory variable?

I am working on a project, and I am absolutely new to forecasting and not so strong in statistics. I have an employee data for the last 7 years, along with the other variables like economic growth, ...
5
votes
0answers
755 views

Seasonally adjusted data used in time series forecasting

I am looking at two time series, from 01/01/2000 to the present: The ISM Manufacturing: New Orders Index, only available seasonally adjusted The manufacturing industry unemployment rate, only ...
5
votes
1answer
3k views

How probabilities are calculated for SVM model?

I would like to know, how probabilities are calculated in support vector machine. I have used Iris data set and here is my decision values for three "SupportVectorMachine" (please find the PMML below ...
5
votes
0answers
711 views

creating random variable with certain auto-correlation in R

I want to create a random variable with a given autocorrelation in R. The target autocorrelation is defined by: $$acf_{target}=(lag+1)^{(-b)}$$ with $b=1.41519$ which I derived from a natural ...
5
votes
0answers
624 views

Survival analysis with Frailty on large dataset

I am trying to fit a survival analysis in R with non-recurrent events and time-varying coefficients. The baseline distribution is exponential or Weibull and the ...
5
votes
1answer
549 views

Calculating and plotting confidence interval for Theil-Sen estimator

I'm using Wilcox's R functions (specifically, regplot) to plot a Theil-Sen estimator with a single predictor. However, regplot ...
5
votes
0answers
233 views

Kaplan Meier estimate for data with unequal numbers in treatments

Is it possible to estimate Kaplan-Meier medians, CIs and difference with unequal sample size in treatments or do I have to do coxph? For example, in my dataset, ...
5
votes
0answers
552 views

Intepreting p values from R mediate() output

In the output below, the ACME p value shows that it is significant. But the p-value for Prop. Mediated Average is >10%. I thought Prop. Mediate is the proportion of the total effect mediated by the ...
5
votes
0answers
407 views

Ideal statistical or machine learning technique to model highly cross-correlated data

I'm trying to build a model that can predict streamflow for an alpine (snowmelt-fed) watershed using snow albedo (roughly, the energy reflectance of the snow) data. Albedo controls the melt of the ...
5
votes
1answer
194 views

What is the “pdm” stat in the “rms” R package?

I am building an ordinal logistic regression model (ORM). In order to fit my ORM model, I am using the 'orm' function of 'rms' package from R (http://cran.r-project.org/web/packages/rms/rms.pdf). Now ...
5
votes
0answers
560 views

Solving non-linear equations in R with optimal inital values

I am using the rootSolve package in R to estimate parameters of non-linear equations. The basic formula is ...
5
votes
0answers
537 views

Where can I find resources to learn about change-point analysis ?

Where can I find resources to learn about change-point analysis ? Hopefully, someone can advise me a textbook to read and it will cover both univariate change-point analysis and multivariate change-...
5
votes
0answers
557 views

Is this longitudinal data too complicated for GLMM or GEE?

After writing this post, I've realized that I am running around in circles, chasing my tail. Any help approaching this problem would be greatly appreciated, as I think I just need to bounce ideas ...
5
votes
0answers
2k views

Interpreting MANOVA and redundancy analysis of a canonical correlation analysis

I have done a canonical correlation analysis using the American Community Survey Dataset. The analysis is done between Ancestry and ...
5
votes
0answers
2k views

Frequency weights, rare events and logistic regression

I'm working on a model that requires me to look for predictors for a rare event (less than 0.5% of the total of my observations). My total sample is a significant part of the total population (50,000 ...
5
votes
0answers
132 views

R packages that work with biased samples

I'm working with a biased sample of web users. I'm only able to track responses of users who have navigated my site in a certain way, and I'd like to run an analysis to determine how certain factors (...
5
votes
1answer
2k views

creating contrast matrix (limma) for two factorial in R

I am attempting to construct a contrast matrix that I can run in R, using the limma bioconductor package, but I am not sure that I have coded the contrast matrix correctly. A previous post and the ...
5
votes
0answers
656 views

Different estimates of crossed random factor variance using nlme and lme4

I want to fit a model with two crossed random factors that also allow heteroscedasticity. Whereas nlme4 allows non-constant error variance, I was not sure how to ...