# 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,521 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0answers
280 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 ...
0answers
92 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 ...
0answers
464 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 ...
0answers
106 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'...
0answers
551 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 ...
0answers
446 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 ...
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 ...
0answers
807 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 ...
1answer
672 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 ...
0answers
196 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 (...
0answers
180 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 ...
1answer
73 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 ...
0answers
46 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. ...
0answers
111 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 ...
1answer
107 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/...
0answers
816 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 ...
0answers
214 views

### Whether to use EFA or CFA to predict latent variables scores?

I have a dataframe of individual observations, that I partitioned to create a training (0.7 prop) and a test set (0.3 prop). I started by running an exploratory factor analysis (EFA) on the training ...
0answers
107 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 ...
0answers
359 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 ...
0answers
554 views

### When and How to Scale Numeric Interaction Variables in Machine Learning Model

I found one similar question on cross validated, but it was unanswered; my apologies if this has been answered. I'm experimenting with feature interaction in a regression model I'm working on in R. ...
0answers
673 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 ...
1answer
133 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, ...
1answer
306 views

### Getting ROC curve from markov chain in r

I've been working on some attribution modeling in R, following the markov chain-based methodology described here. In order to compare the sensitivity and specificity trade-offs of using models of ...
1answer
706 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 ...
0answers
518 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 ...
0answers
545 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? ...
0answers
2k 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, ...
0answers
694 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 ...
0answers
618 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 ...
1answer
394 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 ...
0answers
1k views

### When and why do I have to use “trait” for multinomial multilevel models with MCMCglmm in R?

I want to estimate a multilevel multinomial logit model but I am struggling with the terminology and notation used by the R-package MCMCglmm. There is documentation ...
0answers
193 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, ...
0answers
394 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 ...
1answer
166 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 ...
0answers
493 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 ...
0answers
240 views

### Quantile regression with censored data. Quantiles not fitted

I'm trying to fit a quantile regression model for rigth censoring data and I'm using R with the package quantreg and its function crq. I'm trying the Portnoy method that it's suposed to estimate the ...
1answer
414 views

### testing for mediation of interactions

I am somewhat familiar with various ways of testing mediation for factors in different types of regression analysis. (I'm using R and currently working with a multilevel binary logistic regression.) ...
0answers
519 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 ...
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 ...
0answers
268 views

### Is the following procedure to measure the quality of an imputation ok?

I'd like to compare different kinds of imputation techniques, i.e. methods which allow to fill missing data fields in a data frame. For now, I'm only using the R package ...
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 ...
0answers
109 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 (...
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 ...
0answers
626 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 ...
0answers
342 views

### What is the purpose of working on a logit scale in partial dependence plots?

What is the purpose of working on a logit scale in partial dependence plots (in binary classification)? One could simply go about as follows: Grow a forest Suppose ...
0answers
8k views

### Mixed effect logistic regression in R: choosing random effects

I conducted an experiment which measured a binary response for each subject. The subjects were in 1 of 3 groups. There were two other fixed factors, each of which were continuums (cont1, cont2) ...
0answers
148 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 ...
0answers
1k views

### Diagnostics for GEE in R

I have been checking out which diagnostics to use for a GEE analysis. It seem that influence measures are appropriate (Preisser, 1996). Does anyone know of a package that can be used in R to examine ...
1answer
2k views

### Singularity issues in multinomial logit model with differing choice sets

I am estimating a discrete choice model in which individuals choose which schools to attend. I have a large amount of data on individuals and schools. However, each particular school only appears in ...
0answers
532 views

### Studentized residuals and goodness-of-fit with robust linear regression

Could you please advise whether studentized residuals are meaningful when computed on a robust linear regression model using an M-estimator? I'd like to use it to detect outliers by doing something ...