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

22,600 questions
Filter by
Sorted by
Tagged with
9 views

### Phylogenetically controlled multivariate analyses with both continuous and categorical predictors

My goal is to test whether native and invasive plants overlap in multivariate trait space while accounting for phylogenetic relatedness, and simultaneously determining which environmental variables ...
7 views

### Adjusted survival curves for cox model with time dependent covariate

I have found two ways to get an adjusted survival curve from a cox model with time dependent covariates (A and B). I am wondering which one (or if I am completely wrong how?) would be the appropriate ...
5 views

### How do I specify a 3 level multilevel model in r?

I want to first examine a growth model in my multilevel model. I am examining how reaction time varies across weeks (level 1) across years (level 2) across persons (level 3), and I am not sure how to ...
5 views

### Crossover data analysis

I am currently analyzing data from a cross-over study that I represent below. It is a sample of 20 individuals. Ten individuals received treatment "A" and ten others received treatment "B" from time ...
6 views

### Kruskal's Stress for MDS: How to compute this in R?

I am performing classical MDS on a dataset (Gower matrix returned by R "Cluster" package function daisy). In my field, a measure of fit of the MDS is reported. Other researchers usually perform this ...
29 views

### Using anova function in r to determine whether factors have same effect

I have been asked to construct a linear model where yield is the response and all other variables are explanatory. Here is how I constructed the model: ...
14 views

### cross validation using the SPSE in R

We have implemented an cross validation method in R. But we are not sure whether the error that it puts out is correct. We want it to give us the sum of predicted squared errors (SPSE), but in our ...
6 views

### R models with unequal sample size

I am currently running GLMM in R for comparing correct response and response time in two groups (patients and control), each composed of males and females. I have 3 variables: Group, Sex. (inter ...
8 views

### Is is possible that 2 classifier give me the exact same results?

I'm trying to classify an expression dataset composed by 23 control person and 15 patient, I'm using LDA and RF that actually give me the same result(Sensitivity = 1 Specificity = 0.95 and accuracy 0....
144 views
+100

### Proving that logistic regression on $I(X>c)$ by $X$ itself recovers decision boundary $c$ when $X$ is normal

Backgrounds Suppose that $X \sim \mathcal{N} (0,\sigma^2)$, and define $C\equiv I(X>c)$ , for a given constant(decision boundary) $c$. Now assume we perform a logistic regression: \mathrm{...
13k views

### Difference between fixed effects models in R (plm) and Stata (xtreg)

I'm trying to re-create an analysis done using Stata function xtreg (though I don't have the code) with ...
4 views

### Individual-level factor as predictor in mediate command for multilevel models

I want to run a multilevel mediation model by fitting lmer models and feeding them to the mediate function in the ...
15 views

### Which model is a better fit?

Suppose I have 2 linear model such that: Linear model 1: ...
66k views

### What do the residuals in a logistic regression mean?

In answering this question John Christie suggested that the fit of logistic regression models should be assessed by evaluating the residuals. I'm familiar with how to interpret residuals in OLS, they ...
99 views
+100

### How do I perform an actual “posterior predictive check”?

Note: If you downvote, please explain why so I can improve the question. If you only downvote I have no clue what should be done. This question is the follow-up of this previous question: Bayesian ...
148 views

### Hierachical cluster analysis of ordinal variables?

I have a dataset containing 400 variables (chemical compounds, amount classes) with values 0,1,2, or 3 and 50 entries (species). Can I use hierarchical cluster analysis to get a dendrogram that ...
13 views

### Comparing significance of variables between each other

I would like to determine the significance of my variables in my model and compare them with each other. I have 6 explanatory variables. Here is my summary of the model: ...
7 views

### joint probability density function for multinomial [closed]

Let X and Y have the joint probability density function f(x, y) = {k xy , , 0 ≤ x ≤ y ≤ 1 0, otherwise } Find the value of k and compute the correlation coefficient.
33 views

### (resolved) R: Clarification fisher.test (idem with chisq.test): Different p-values although same sample size, same proportion difference

I would appreciate so much if someone could help me to understand the following comparisons, and tell me if I am doing the tests correctly. I want to compare two districts and their respective ...
50 views

### Linear regression <> survival models in R

I have a question about survival analysis with a gaussian distribution of the response variable. I have interval censored data, that look something like this (just an example): ...
8k views

### How can I generate uniformly distributed points on a circle?

I am looking to generate 450 data points in R. There are three distinct sets 150 of each distributed in a circular band with different radii (at 1, 2.8 and 5). In particular, I'm looking to reproduce ...
25 views

### Reasoning for failure to reject $H_0$

Following up on this question, I would like to make an intuitive explanation of why i'm failing to reject $H_0$ ie that all varieties of wheat have same effect on yield. So, here is a boxplot: And ...
19 views

### Is Chi-square test okay to use when there's low number of individuals in cells in a large sample (n > 1000)?

Pearson's Chi-squared test data: tab X-squared = 61.663, df = 16, p-value = 2.738e-07 R here shows a warning that the approximation is incorrect because of ...
5k views

### Simulate from a zero-inflated poisson distribution

I am trying to simulate from observed data that I have fit to a zero-inflated Poisson regression model. I fit the data in R using zeroinfl() from the package ...
4 views

### Choosing a regression model for proportion data at the school level

I am working on a dataset where I have the percentage of students who passed at a test for each 189 schools in my sample. The data is aggregated, so I have the total number of student who sat the test ...
2 views

### How to provide fixed values for some random parameters in nlme in R?

I'd like to fit a mixed-effects logistic growth curve to grouped data using the nlme package in R. The function has the ...
14 views

### RStudio, Analyzing data with time and quantity given [closed]

i have given dates and quantities arriving at these and are trying to put a distribution on them. Unfortunately the found functions seem to calculate the quantities at the times all by themselves. ...
15 views

### Interpretation of GLM Odds?

I have data on student graduation (1 = graduated, 0 = not graduated), as well as student gender and whether or not they were diagnosed with a disorder (categorical variable where it can be none, mild, ...
26 views

### Simulate data based on linear regression and R squared

I have a small data set of 10 x,y points from which I can derive a simple linear regression. I'm looking to use this data set as a basis to simulate / predict additional "y" points as I have a much ...
21 views

### How can I solve “horseshoe effect” on ordination analysis (Canonical Correspondence Analysis)?

I would like to ask for help in the analysis of Canonical Correspondence Analysis (CCA) that I did in the Vegan package in R, with my dataset of species and environmental parameters. The result ...
690 views

### Need to extrapolate missing monthly data from annual data; the monthly/seasonal index is reasonably well-known

I have a revenue dataset for various businesses. For about half of those businesses, monthly data is available. For the other half, only annual revenue data is present. I know the seasonality of the ...
8 views

### Creating 'most marketable cohorts' from customer data

I have a massive dataset with all sorts of customer data and demographics. My aim is to produce something that might inform our advertising decisions in the future by ranking cohorts of customers most ...
25 views

### How to check if a correlation exists between a continuous independent and a binary dependent variable

So this has been a headache for me. None of the resources I found could explain it in a manner I understand. Having two sets of data: ...
10k views

### R package for multilevel structural equation modeling?

I want to test a multi-stage path model (e.g., A predicts B, B predicts C, C predicts D) where all of my variables are individual observations nested within groups. So far I've been doing this through ...
461 views

### Interpretation of gam.vcomp() results (mgcv package, R)

I'm using the gam.vcomp() function to obtain the variance explained by each predictor in various GAMs fitted using the mgcv package in R. ...
13 views

### Why am I getting NA answers using the Thornthwaite equation when I have monthly temperature and precipitation data?

I'm using the thornthwaite equation from the SPEI package and I'm having a problem where I'm getting NA values for some locations where I actually have mean monthly temperature data and the latitude. ...
10 views

### Next step after building GLMM logistic regresion: LRT, ANOVA?

I am a biologist in the middle of their PhD journey and I'm constantly learning new things about statistics but there are some things that are difficult for me to understand. Until now I had dealt ...
19 views

### Multilevel SEM with three or more levels in OpenMx

I am trying to figure out how to conduct analyses using CFA and SEM models with three or more levels. Pritikin et al. (2017) investigates how to conduct a three-level and up to five-level SEM using ...
12 views

### Using and interpreting nested manova in R

I have measured the concentration of 7 elements in 30 Lakes. I have between 8 and 12 observations per Lake (i.e., I measured the ...
166 views

### What can I say with mean, variance and standard deviation?

I wrote this code in R: ...
50 views

### Random Effects Results in R (plm) Cannot Replicate Results in Stata

I have been working on migrating a current project from Stata to R, where I have encountered difficulties with differing results of random effects regressions. I have panel data from an experiment ...
11 views

### Good online forums or courses where I can learn and practice coding statistics/machine learning methods in R or Python and get feedbacks [closed]

I'm wondering if there are any good online sites, forums or courses where I can learn, practice and discuss coding statistics/machine learning methods in R or Python? It would be great if I could ...
14 views

### Generalized Least Squares for linear regression with continous and categorical predictors

I have a linear regression model in R studio with a continous and a categorical predictor, where the assumption of homoscedasticity is violated: ...
21 views

### Drawing from 2 bags of different size and counting the number of outcomes

I have a combination problem that I can't get my head around. Similar problems were found here and here but are not quite the same of my problem. I have two sets of units and I want to find the ...
18 views

### How to get p-value and SE after ROC analysis with pRoc package? [closed]

After ROC analysis of a set of data, how to calculate the p-value and SE? With the same statistics, I saw that the p-value can be output in SPSS. The sample code is as follows: ...
6 views

### wi (𝒘і) output from regression - what is this? [closed]

I have run a mixed effect model and want to describe the output can someone please explain what the 𝒘і is? thanks!!
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 ...
1k views

### R, glmer(), plot bootstrapped CI in graph

Using the glmer() function in the LME4-library in R I computed logistic models, of the form: $Y ~ cat1 * cont1 + (1|Subject)$ where, obviously, Y is the binomial ...