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

14
votes
3answers
12k views

Area under the ROC curve or area under the PR curve for imbalanced data?

I have some doubts about which performance measure to use, area under the ROC curve (TPR as a function of FPR) or area under the precision-recall curve (precision as a function of recall). My data is ...
2
votes
1answer
1k views

Comparing two means using permutation test and bootstrapping with the boot() function in R

I would like to know how to do a permutation test using the boot function in R. The goal is to compare means of two groups of people: some of them drink beer and the other one drink water. The ...
0
votes
0answers
8 views

Strategies for balancing the test/train split for modeling applications?

I am about to embark on a modeling project where I want to split up my data into test and train groups. Initially I was planning on doing a random assignment of each record according to an 80:20 ...
0
votes
0answers
10 views

Multiple state transition probabilities in Markov model

I have a problem where, in a multi-state Markov model with monthly timesteps, I have a state X where, in an average of 1 year, individuals exit from the state in this proportion: 56% of individuals ...
0
votes
1answer
355 views

What is a quasi F ratio and how to compute it in R?

I've been reading this classic study (free pdf) of false memories by Loftus & Palmer (1974) and do not understand their analysis in Experiment 1 (p. 586), particularly— a) the use of subjects as ...
1
vote
0answers
10 views

ksmooth function in R

I'm trying to understand how ksmooth function in R works (I haven't really taken much statistics other than an introductory one at college, so sorry if this is a ...
0
votes
1answer
21 views

Longitudinal Cox Regression analysis?

So I have a dataset that is currently in wide format and I have multiple waves recording data such as age, death, diagnosis etc. I have done a simple Cox regression analysis: ...
0
votes
0answers
424 views

Vector autoregressive models in R

Can anyone recommend a good tutorial/blog/books which introduces the theory behind vector auto-regressive models but also shows some example code snippets in R?
0
votes
0answers
9 views

Power analysis, moderated mediation, SEM, R

Using R, I am trying to estimate a sample size for the following structural equation model defined using lavaan syntax (R): ...
0
votes
0answers
17 views

Which model type for a distribution of discrete outcomes?

I am doing work on predicting household types (income group, number of workers, presence of children) based on a forecast of a number of economic variables from a regional economic model, such as a ...
0
votes
1answer
9 views

What is the proper analysis to run when trying to compare means between multiple years?

I am trying to figure out the proper statistical analysis for my problem. I have a data set that has many variables but I am interested in how the mean deer density changes over time. I have multiple ...
2
votes
2answers
304 views

Test to identify outliers with R

I would like to identify outliers in a sample of 6,000 observations. My variable doesn't follow a normal distribution and my series is spread out on the right. So an extreme value is not necessary an ...
0
votes
0answers
7 views

Simulating data in JAGS “ones trick”

I am trying to simulate data to use for posterior predictive checks in JAGS running through R, which is relatively simple for pre-loaded distributions, but I am looking to simulate data when I have ...
0
votes
0answers
9 views

Changing the alternative of roc.test in R-package pROC to compare two AUC curves

In my data I wish to show that one of those marker, which can be easily extracted from patients, is not a worse predictor as another, which puts patients under more stress. I thought to evaluate this ...
-1
votes
0answers
36 views

R prcomp and KNN different correct classification rate

I'm performing a classification task using KNN and PCA to pre-process the data. The dataset contains 101 continuous variables and the column of the labels (here the link to download the data filebin....
1
vote
0answers
13 views

Hierarchical clustering on principle components for multidimensional scaling

Essentially I have a data set of distant objects in which I've loaded onto factors using a multidimensional scaling technique. From my understanding, the factor loadings only differ between MDS and ...
1
vote
2answers
100 views

How to specify an autoregressive correlation structure in a linear model when the data has multiple observations at each time step?

I want to fit a multiple regression model that accounts for temporally-correlated errors (i.e., some sort of autoregressive correlation structure, like those provided by ARMA or ARIMA models). However,...
7
votes
2answers
9k views

Selecting knots for a GAM

When selecting an appropriate number of knots for a GAM one might want to take into account the number of data and increments on the x-axis. What if we have 100 increments on the x-axis with 1000 ...
2
votes
1answer
268 views

Plot the contribution of each variable in a model

I'm looking to plot the contribution of each variable in a regression model incrementally, and display how that impacts accuracy and the residuals. Given the model $$ y \sim \text{trend} + \text{...
5
votes
2answers
2k views

Encompassing Tests to compare models in R

I recently read a paper in which an academic compared two competing models of voting theory. One of the advanced diagnostic tests he did was to try and see whether either of the models could "formally ...
0
votes
2answers
306 views

derivative from regression model in R

My regression model is this: R2 <- lm(lnwage ~ educ + exper + hrswk + educ*exper + educ2 + exper2) and I want to estimate: $\frac{\partial ln(wage)}{\partial ...
0
votes
0answers
43 views

How to get non-standardized factor scores [on hold]

I applied principal component analysis to reduce dimensionality of my data. I need to use factor scores for descriptive analysis. However, because factor scores I get from ...
-1
votes
0answers
13 views

How to do a multi scatter graph in one plot [on hold]

I would like to create a graph similar to this one shown in the picture. I am not familiar with the specific name of this plot. How can I combine multiple data frames and then plot the data of five ...
0
votes
0answers
12 views

Problem with Principal component (PCA) and Partial least squares (PLS) using R

I'm trying to reduce highly dimensional data with factor methods. I'm using Principal component analysis and Partial least squares. From these methods I'm using the first component as a Common factor ...
2
votes
1answer
237 views

Classification in real time without prior knowledge of the number of classes

Is there an implemented algorithm (with python/R or java in preference) that can classify incoming data from an unknown generator with absolutely no prior knowledge or assumption. For example: Let G ...
0
votes
0answers
9 views

games-howell test with multiple independent variables

my data doesn't meet the homogeneity of variances criterium. After a welch one way test I wanted to perform a post hoc games-howell test since it doesn't require the homogeneity of variances criterium....
0
votes
0answers
4 views

BLUPs post-hoc analysis

When a model with only random effects is fitted using any package (i.e. lme4 glme()), BLUPs can be obtained for the factors with ranef. Using those values for bivariate correlations, principal ...
0
votes
0answers
11 views

How to get just date when the time comes like this? [on hold]

I want to get just the dates because I'm modeling my problem as a markov chain. I've already created a matrix with all the dates (without time) using a seq and I'll compare it later. How can I get ...
0
votes
0answers
8 views

Interpretation of marginal effects multinomial logit R

I'm not really sure how to interpret marginal effects when calculated with mlogit and effects function from R Here is the code ...
0
votes
1answer
22 views

How to choose best multiple regression model (Poisson/quasipoisson/negative binomial)? - R

I'm creating some multiple regression models on some national statistic data checking whether there is a divide in infant deaths between the north and sound of the UK. I have created models for males,...
0
votes
0answers
26 views

What do ellipses of PCA analysis (factoextra) mean?

Biological question: do plants that have been attacked by insects differ in their characteristics from plants that have not been attacked by insects? Data frame includes six numerical variables ...
0
votes
1answer
24 views

Cox regression model - testing the proportionality assumption for an interaction term?

I'm interested in testing sex differences in the outcome Y (e.g., mortality), and if there are sex differences in the effect of BMI on mortality. I planned to use a Cox regression model primary<-...
0
votes
0answers
16 views

Bootstrap to determine confidence interval of a dependent (ID) sub-sample [on hold]

Found method to deal with this issue at: Statistics 5601 (Geyer, Fall 2013) Subsampling with the main document related to course with Notes by C. J. Geyer with the main reference at Subsampling ...
0
votes
1answer
45 views

Circular smooths within a GAM-GEE framework

I have a predictor variable which I fit in a GAM as a circular smooth term: ...
0
votes
0answers
7 views

Spatial modelling: raster calculation from covariate estimates of GLMs produce some negative values in raster distribution data

I am constructing spatial distribution models/maps for soil carbon using coefficient estimates from a GLM. The GLM is made up of a mix of continuous and categorical variables and the response is a ...
0
votes
0answers
18 views

Power analysis, moderated mediation model, SEM, R [on hold]

Using R, I would like to estimate a sample size for a structural equation model consisting of 13 latent variables (x1...x7, x9...x12, y=outcome) and an observed variable (x8). There are 2 moderations ...
2
votes
3answers
44 views

Not convinced about normality based on QQ plot, Shapiro and KS $p <0.001$

I have about 1000 data points, I'm trying to run a $t$-test because my points are divided in 2 groups and I want to compare them. The results of Shapiro-Wilk normality test: ...
16
votes
5answers
9k views

For classification with Random Forests in R, how should one adjust for imbalanced class sizes?

I am exploring different classification methods for a project I am working on, and am interested in trying Random Forests. I am trying to educate myself as I go along, and would appreciate any help ...
1
vote
1answer
383 views

researching non linear correlations through scatter matrix

I am trying to understand the correlations among three explanatory variables of commercials and response variable sales through the scatter plot matrix. It seems like there are non linear ...
0
votes
0answers
11 views

Effect of two time series over a different one

I have three time series $X_1$, $X_2$ and $Y$. All of them starting from the same date and with the same length. I know that $Y$ contains information of $X_1$, $X_2$ and other variables that I cannot ...
1
vote
1answer
22 views

LDA by hand gives different results than MASS

I'm performing LDA by hand in R by following this formula: $\delta_k(x) = x^T\Sigma^-1\mu_k-0.5*\mu_{k}^T\Sigma^-1\mu_k+log(\pi_k)$ where $\pi_k$ is the proportion of the data that's in the group $k$...
0
votes
0answers
23 views

Why is my set.seed in R and RStudio giving diffirent results [on hold]

I was trying to use a seed for a sampling problem but I kept getting the wrong result using R studio. I tried it by simply opening R and I got what I was looking for. Why is this? What is wrong, and ...
1
vote
2answers
49 views

Which statistical significance test should I use to solve this?

Which statistical significance test can i use. all are binary outcomes. Here is my table. I would like to know if there is a significant difference in mortality between the two groups (kidney injury ...
0
votes
0answers
4 views

Feedback regarding dependability of duplicate and near-duplicate detection [on hold]

Good morning all, I recently completed building a script that does the following: Stores a list of all .jpg images existing in specified drive. Cleans/ids duplicates through md5sum Iterates through ...
0
votes
0answers
182 views

Manually setting reference levels in glm of categorical variables [on hold]

I have a data set with variables that have 3 or more levels for example pen size: small, medium, large. I know that if you don't set a reference level, R will just pick one and then compare the other ...
0
votes
0answers
21 views

Which statistical methods to be used?

I am analyzing data in order to show the reasonings of interindividual variabilities of the results of a laboratory data that was measured repeatedly over 100 hours in a single group. But the timings ...
1
vote
2answers
25 views

Units of emmeans output?

I have values of relative humidity on a scale of 0 to 1 (e.g., 0.9 = 90% RH). I also have two cities (A or B). My model is as follows: ...
0
votes
1answer
9 views

How to address a detected nesting structure using emmeans

I'm analysing the results of a M BACI experiment. When trying to estimate means using emmeans, I'm getting this message: NOTE: A nesting structure was detected in the fitted model: BurnType %...
0
votes
0answers
7 views

Factor analysis with categorical variables(FAMD)

I'm using the FAMD(factor analysis for categorical and numerical variables) function from the FactoMineR package in R. The cumulative variance of my first 4 dimensions is very small. The first 4 ...
1
vote
0answers
11 views

MCA in FactoMineR: all variables are the same on Dim 1?

My data is ordinal (1, 2, 3, 4, 5, NA from a likert scale) and doesn't have any obvious pattern looking at the raw data. My code looks like this: library(FactoMineR) df <- data.frame(Var1 ...