# 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,062
questions

**0**

votes

**1**answer

8 views

### LOOCV in Caret package ( randomForest example) - not unique results

I pose you my doubts:
For what I know there is only a single way to perform a LOOCV for a model (i.e. testing each one of the N elements vs the model trained with the other N-1 elements).
Namely, ...

**0**

votes

**0**answers

18 views

### Statistical Model used for predicting number of deaths due to COVID-19 [closed]

What statistical model is used to predict number of deaths due to COVID-19? Suppose I have a dataset with number of deaths for last two months and would like to predict number of deaths for next month?...

**1**

vote

**0**answers

7 views

### How to analyze repeated measures when condition changes at each time point?

I have a dataset from a repeated measures experiment that I am trying to analyze. The experiment had 4 possible conditions. Participants were measured on 1 condition and then again on a second ...

**0**

votes

**0**answers

5 views

### cox frailty model in R

I run a cox frailty model(model 1) in R, by adding new co-variate to model(model 2) The ACI decreases that show the new model is better than model 1, but the variance of random effect of model 2 is ...

**0**

votes

**0**answers

9 views

### What is the ACF plot of $x_t = 0.9 x_{t-2} + w_t$

I am just learning time series,
and I am wondering about the following AR(2) model:
$x_t = 0.9 x_{t-2} + w_t, w_t \sim N(0, \sigma_w^2)$
Please show me the plot of its Autocorrelation Function,
or ...

**1**

vote

**0**answers

5 views

### How to calculate correlation coefficient and AIC for non-linear estimation in R or Statistica?

I need to compare two non-linear models of growth. The first one is calculated with nls function in R and with non-linear estimation function in Statistica - both programs gave identical results and ...

**0**

votes

**0**answers

10 views

### R: read.csv imports my numeric columns with lots of missing as NULL, how to prevent? [closed]

My data has 63 columns, and for a column, 'hours' has more than 50% of missing values and it's converted as NULL when importing.
But the column is very important and needs to be used after cleaned....

**1**

vote

**0**answers

19 views

### No significant p values after multiple comparison of 126 tests

I am wondering if there is any reasonable other ways to adjust for multiple comparisons when you have such a large number of tests. I have a study with 126 brain regions being scanned in a group (N=20)...

**0**

votes

**0**answers

6 views

### variation partitioning with a GAMM model including an auto-correlation structure in R

I would like to undertake variation partitioning in a GAM framework in R, as described here: http://r.789695.n4.nabble.com/variance-explained-by-each-term-in-a-GAM-td836513.html
However, my gam ...

**0**

votes

**0**answers

17 views

### Using the STAN math library [closed]

I would like to use a Matern Covariance Function for gaussian process regression in STAN. (Through RStan)
The standard exponential covariance function works withouth issues
...

**1**

vote

**0**answers

7 views

### How to test Multinomial Logistic Regression assumption in R

So I'm currently trying to use a multinomial logistic regression model in R on a data set with 13 variables (mix of continuous and categorical) and 33,000 observations, where the dependent variable ...

**1**

vote

**1**answer

23 views

### R: Question about central limit theorem

Hello everyone :) can you help me please, I really don't understand my teacher's videos and it is the last part of our 20-pages work :O
In the question 1 they ask us to create a Poisson distribution ...

**1**

vote

**1**answer

15 views

### syntax of gam longitudinal dataset

I would like to have some help on gam syntax in R, not sure if I should ask here or in stackoverflow but because I also have difficulties to understand how the model handles random effect I start here,...

**5**

votes

**1**answer

26 views

### Calculating Diagonal Elements of $(X^TX)^{-1}$ From R Output

With $X$ being the design matrix, calculate the diagonal elements of the matrix $(X^TX)^{-1}$ using only the R output.
I found the diagonal elements to be $$\frac{1}{n SSX} \bigg[n,\sum X_{i1}^2, \...

**0**

votes

**0**answers

6 views

### Use predict function for average over all levels with contrast.sum

I have a model with Machine as factorial variable. The contrast is set to "contr.sum".
...

**1**

vote

**0**answers

4 views

### Parameter estimation for time-varying autoregressive processes in R

I want to estimate the parameters of an autoregressive process with time-dependent coefficients. For example TVAR(1) model with 1 lag: $$ X_t = \phi_t X_{t-1} + \sigma_tW_t $$ where $\phi_t$ and $\...

**1**

vote

**0**answers

8 views

### Interpreting and troubleshooting nls in R with quadratic plateau model

I am trying to run a quadratic plateau model on some proportion data where values are bound between 0 and 100. I would like some help troubleshooting some errors I have encountered, and correctly ...

**0**

votes

**1**answer

16 views

### Frequency of a value in R [closed]

If there is a data set in R and I want know how many of one value is in it, is there a command for this? thanks

**0**

votes

**0**answers

12 views

### Creating a plot for twoway fixed effects regression on how estimator changes over time

I am running a twoways (individual and time) fixed effects within model.
Is there an econometrically sensible way to plot how the within effect of the independent variable changes over time?
Or ...

**0**

votes

**0**answers

16 views

### Do you need all the p values for Benjamin-Hochberg multiple comparison correction?

I am wondering if you need to input a vector of p values for the benjamin-Hochberg multiple comparison correction. I am planning on using this correction and was wondering if all p values need to be ...

**0**

votes

**1**answer

10 views

### Calculating a spearman correlation matrix from clr transformed data [closed]

Lets say I have some relative abundance data, like this:
...

**0**

votes

**0**answers

10 views

### 3-way between*within*within random effects structure lmer

I'm confused regarding how to structure random effects for a 3-way mixed effects model in lmer. I've found a couple of helpful sources:
e.g. http://www.dwoll.de/rexrepos/posts/anovaMixed.html#two-way-...

**2**

votes

**1**answer

21 views

### Propensity score adjustments for nonprobability surveys

I recognize that propensity scores are often used for causal inference. Just to clarify from the outset, that's not what I'm interested in here.
Instead, I'm looking at using propensity scores to ...

**0**

votes

**0**answers

10 views

### How to code in R ellipses for two grouping variables using line type and colour? using vegan or ggplot2 [closed]

I am using the ordiellipse function in vegan to plot ellipses on my NMDS. The points in the NMDS consist of a community analysis of soil and root microbes from forests representing different ...

**2**

votes

**1**answer

33 views

### auto.arima vs arima.sim

I noticed auto.arima is frequently giving a different model than simulated with arima.sim, so I tested it crudely:
...

**0**

votes

**0**answers

13 views

### GAM scaled t family for heavy tailed distributions

I have some heavy tailed data I wish to model using the mgcv package in R with a t-distribution.
Reproducible example:
...

**0**

votes

**0**answers

11 views

### Estimating values of Empirical Density Function [closed]

I have a bivariate dataset and trying to estimate density value for each pair. On R, I tried the kde function of np package, instead it gives me a contingency table according to the gridsize. Also I ...

**5**

votes

**1**answer

37 views

### Best practices in the selection of distance metric and clustering methods for gene expression data

I have been reading about this on various channels including here and Stack Exchange, but I'm still not sure how to choose the best approach for clustering gene expression data. As a Ph.D. molecular ...

**0**

votes

**0**answers

11 views

### Conjoint Analysis in R and SPSS result in Different Standard Errors using Same Data

I have been going through the tutorial by the author of the conjoint library in R (Tomasz BartÅomowicz) which can be found here. Specifically I have been going through example 1 (Ice Cream) and trying ...

**1**

vote

**0**answers

18 views

### Modeling nestedness in terms of repeated measures AND site in lme4 in R?

I have $30$ students from $4$ schools (named: W, X, Y, Z). Two of the schools (X and Y) have received a Treatment (...

**0**

votes

**1**answer

27 views

### I want to compare a forecast with actual inventory, what statistical tests can I use?

I have two datasets, both are .csv files:
Forecast- Marketing team's forecast of inventory levels that would be required in 2019
Inventory - Factory's records of actual inventory values recorded in ...

**0**

votes

**0**answers

7 views

### Use a Bayesian approach to construct a 95% confidence/credible interval for the mean and variance using conjugate priors

I am looking for information on how to solve this problem above in R. It does not have to be solved using any specific dataset but I would appreciate an example. I am unsure of conjugate priors. ...

**1**

vote

**1**answer

15 views

### linear fit using gam in R (mgcv)

I compare different gam model fits, and I want to know if supposing a null smooth term dimension argument (k = 0) is equivalent to a linear regression.
lets take ...

**1**

vote

**0**answers

15 views

### Are there any practical differences in fitting a random slope vs. fitting an interaction term in the intercept in lmer

I am trying to fit a few models with the form
...

**0**

votes

**0**answers

12 views

### Is this approach the right one in Cox with time-dependent covariates in R?

first of all I would like to thank you for reading my post. Then let me describe my situation:
I'm trying to develop a Cox model with time-dependent covariates. I have a dataset of patients with ...

**0**

votes

**0**answers

21 views

### colour outliers from box plot in scatter plot r [migrated]

I captured outliers of Days variable of a dataset usairnew in bout as given below:
...

**2**

votes

**1**answer

18 views

### Inverse Regression vs Reverse Regression

I'm aware there's a great number of questions which deal with the mathematical difference between the two, but I'm still confused as to best practice.
Basically I'm looking at a situation where we ...

**0**

votes

**0**answers

13 views

### Impute Continuous Predictor which 0 or median is not an option

I have a dataframe of the following patients:
PatientID Days.To.Develop.Symptoms
1 0
2 1
3 3
4 NA
...

**0**

votes

**1**answer

22 views

### Using caret::sbf to apply feature selection where features are selected over different threshold scores

I'm aiming to use caret::sbf to filter a large number of predictors before using different machine learning models to predict a binary outcome. I would like to filter for variables that are identified ...

**3**

votes

**0**answers

16 views

### Can I adjust the relative influence of observations in a mixed model in nlme or lme4?

Is there an equivalent of lm's "weights" argument for nlme or lme4 ?
Here's an example to illustrate my question in case it isn't clear enough:
I have data taken from 3-5 trees at 3 sites. From each ...

**2**

votes

**2**answers

27 views

### Interpreting interaction from two-way anova table

I've conducted three pairwise comparisons of variables and the results were as below:
...

**1**

vote

**0**answers

22 views

### R: Help: model selection when summary(lm) shows significant effect BUT anova(model2, model3) does NOT?

All is in the title, but here are the details:
...

**0**

votes

**0**answers

8 views

### Difficulty obtaining fit for piecewise SEM (structural equation models)

I have been trying to run Piecewise Structural Equation models on my community mesocosm experiment. I am using piecewiseSEM package, along with the packages lme4 and nlme. I have tried two different ...

**0**

votes

**1**answer

25 views

### A statistical function that compiles a curve to a number? [closed]

My title reads itself...If that's even what that means. Forget it.
I need to compare some data curves over time for each of the 50 states and see which state is the closest to say, New York. I am ...

**0**

votes

**1**answer

14 views

### How to compare linear vs negative binomial vs random fit for data?

I'm trying to plot number of offspring (x-axis) vs size of offspring (y-axis). I want to check if the size of offspring has a linear, or negative binomial or randomly fit. I'm trying to statistically ...

**0**

votes

**0**answers

14 views

### How to draw bar plot using frequency table in ggplot2 [migrated]

data.frame format:
a <- data.frame(c(1,2,3),c(3,2,1))
colnames(a) <- c("A","B","C")
rownames(a) <- c("X","Y")
A B C
X 1 2 3
Y 3 2 1
How to use this ...

**0**

votes

**0**answers

33 views

### Stepwise regression in R - what's my alternate?

Details
I'm building what is called a direct demand model for predicting boardings at rail transit stations. The most available example is Transit Cooperative Research Project report 16 (TCRP 16). I ...

**-1**

votes

**0**answers

6 views

### How to install ConvergenceConcepts in R? [closed]

So, I have a R 3.6.3 version and I need to install ConvergenceConcepts package but I am thus far unsuccessful. When I try to install this package, R throws me this message:
...

**0**

votes

**0**answers

12 views

### Which statistical method to use? Two way ANOVA?

I need some help determine which statistical method is best to use:
In a mine expansion a forest is destroyed. Prior to the expansion 10 plots were established to measure the deadwood volumes.
Three ...

**0**

votes

**0**answers

8 views

### Suggestions of Spatio analysis using areas with no neighborhood

I'm looking for some technique that allows me to make a spatial analysis in areas with no neighborhood. I'm working with some cities in different countries, some cities have neighbors, but there are ...