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

20,775 questions
Filter by
Sorted by
Tagged with
64 views

### What is the correct effective sample size (ESS) calculation?

I wish to compute the effective sample size (ESS) for a posterior sample of size $M$. I have looked at several documentations (e.g. WinBUGS p11; Stan sec 15.4) and several other Stack Exchange ...
16 views

### ANCOVA baseline as covariate

just a simple question, to make sure this is correct. I watched some videos with similar study questions and I'm following them. I have 4 groups of treatments(Ct+A1+A2+A3), and two different moments, ...
31 views

### What is a Good Error Target

I am modeling a forecast for product categories using auto Arima in R. I'm getting MAPE of between 9-15% on average. We don't have any historical records of forecasts vs actual so I don't know how ...
32 views

### Inquiry: Obtaining equivalent results between binom.test() in R and Proc Freq?

Problem I am reading the Wikipedia article on the binomial test and I have been unable to duplicate the purported R and SAS code showing they are equivalent. The p-value I get for R code is ...
6 views

### How To Feed Un-Scaled Data Into a Model That Was Trained on Scaled Data

I have a data frame that contains time series data. I split the dataframe into test and train. I want to prevent leakage so I split the data frame before doing any scaling. On the train data set, I ...
14 views

### How do I extract VaR estimation from DCC-GARCH model in R?

I have estimated a DCC-GARCH model in R and I need to extract the Value at Risk for an equally weighted portfolio from the estimated model. ...
12 views

### How can I deal with multilevel logistic regression with a well fitted null model?

My null model have 80% of correct predictions. (multilevel with binary outcome). That happens because 80% of respondents had answered "no" for the dependent variable. Then, after add some ...
26 views

### Calculating SMD from posttest only - is this possible?

I am performing a meta-analysis (with 'metafor' R-project) as described by Becker (1988), and I compute the standardized mean change for a treatment and control group. I compute a (standardized) ...
14 views

### How to perform FrF2?

I'm about to perform an experiment therefore I want to use FrF2 to construct a proper experiment design. 2^6 would be a full factor design (without repetitions and replications). So far, my goal is ...
40 views

### What test can I use to compare intercepts from two or more regression models when slopes might differ?

I wish to test whether intercepts in linear regression models differ between two or more groups, when group-specific slopes might themselves differ (i.e., an interaction term may be present). ...
22 views

### RStan v.s. simple lm for multivariate regression [closed]

I want to fit a multivariate linear regression, with Y1 ... Y4 as the response and X1 ... Xn as the explanatory variables. X1 and X2 are two components of a mixture, and X3 ... Xn environmental ...
31 views

### R survdiff interpretation

When I use survdiff in R for survival analysis, I know how to interpret the term labeled ...
21 views

I'm trying to estimate a semiparametric binary response model with index heteroscedasticity in R. That is, I have a model defined with $y_i = \mathbf{1}\{\beta_0 + \beta_1 x_{1i} + \beta_2 x_{2i} + \... 0answers 25 views ### Mixed-effects model for categorical within- and continuous between-subjects variables I'm using a model to simulate how tree growth rates vary with different traits, but I'm not sure how to correctly account for the non-independence in the data in my statistical tests. I generated ... 1answer 19 views ### Why is the standard error of regression parameters not decreasing? I know that the standard error is calculated from looking at the sum of squared errors divided by square root of n. However, as we add more and more variables, we expect the sum of squared errors ... 0answers 30 views ### R time series data how to use AR(1) in glm() I've got a multivariate time series data that's recorded on hourly basis (hourly counting data), and I want to predict count based on other variables: ... 2answers 106 views ### Is it possible to fit a Dirichlet Regression to changing response variables? A toy problem to illustrate my issue: We put a 100 people in a room with 10 candy bars. Each bar is different and has a different brand, flavor, size, color, etc. We ask each person in the group to ... 0answers 15 views ### How to verify t-test assumptions in R? [duplicate] I'm using the built-in sleep dataset. I'm trying to verify the t-test assumption that the data follows a normal distribution. I ... 1answer 20 views ### My R plot of the F distribution doesn't seem right [closed] In order to simulate two independent variables, so that$\beta=0$in their linear regression model, I wrote the following code: ... 0answers 29 views ### Correct GAMM function for binary dependent variable I am looking for help for how to implement a correct syntax for my Generalized mixed effect model. I have data for 4 independent transects set along an altitudinal gradient. I placed, at several ... 0answers 11 views ### Convert the frequencies of a list elements (table) to data frame in R [migrated] I have a list like this: x = c(0,0,1,1,2,3,1,0,4,5,6,4,3,2,1,1,0,2,3) and I need to create a dataframe with frequencies, where col names are the unique elements ... 0answers 45 views ### Trying to fit a poisson that's dispersed enough but not too dispersed [closed] I'm trying to fit some count data for the number of fish purchased by anglers(grey in the image) with a distribution using optim in R. I've fit both a poisson (red) and negative binomial distribution (... 0answers 8 views ### Training of SVM with polynomial kernel with RMSE superior to 1 I am training a SVM with polynomial kernel to do mineral potential modelling. I am using the caret library in R. I created a search grid for the three parameters for the polynomial kernel and used a ... 0answers 17 views ### Calculation of I-squared in meta-analysis of diagnostic accuracy I would like to calculate heterogeneity statistics (Cochran's Q, I-squared) for a meta-analysis of diagnostic accuracy. I successfully used the 'mada' package in R to calculate these statistics, but ... 1answer 22 views ### comparing variance in random effects: crossed ranom effects or different models? I am interested in making sure that a predictor I include into a regression actually explains the type of variance it should. To be more specific: in an experiment in which a number of people sees a ... 0answers 18 views ### How to add the diagonal line on a ROC curve plot from PRROC? [migrated] Here is a sample of ROC curve in PRROC ... 0answers 14 views ### Three-way clustered robust standard errors in R Suppose I have the following data: ... 0answers 11 views ### How to use caret package in r to tune the detailed structure of neural network I am new to ANN, and I am struggling on how to tune my ANN. My question is how can I determine the ANN structure (like how many hidden layers and nodes in each layer) is the best, or at least good ... 0answers 21 views ### Which statistical test to use in this case? I’m working with a nassCDS dataset trying to solve a group of exercises of a task in R. In a previous step I create a new column (vehClassif) on the dataset from the continuous variable weight ... 0answers 15 views ### doing bernoulli in r The question might be too simple, but sometimes I see an extra "+1" in parameters passed to distributions, For example for Bernoulli I would do: ... 0answers 11 views ### Simulate recurrent events data where last observation is censored I would like to simulate a recurrent events dataset for survival analysis with cox regression in R. The data should have the following properties: multiple, varying number of observations per ID only ... 1answer 21 views ### R: MTP in multtest creates different estimates from glm for test=“lm.YvsXZ” I apologize if I am completely missing something fundamental about what I am trying to do here. I am trying to use MTP to estimate adjusted p-values for a much more complex regression, and I keep ... 1answer 66 views ### GLMM for continuous response in$[0, 1]\$

I am looking into GLMMs because my linear model residuals' plot has a weird pattern (some residuals form a diagonal pattern), and a lack of normality was also confirmed with a Shapiro test. ...
17 views

### Why the huge difference between the results from pca and spares pca using R [closed]

I am using "elasticnet" package to do the sparse PCA in R. I could get the percent of explained variance of each PC. However the explained variance from sparse pca is much smaller than that from ...
18 views

### finding the within-person SD from a null model lme output

I just wanted to make sure I'm interpreting my lme() output correctly. I've set up a null model because I was told I could find the within-persons SD this way (...
10 views

### How to show performance of one machine learning model is significant to other model? [closed]

I have 3 different models trained and tested on same dataset, and evaluated by Pearsons R, Root Mean Square Error (RMSE) and so on... I see that evaluated scores of one model are better than others, ...
21 views

### Why forecast::accuracy() mape is working with 0/0?

I'm learning now some metrics of goodness about time series forecasting, using the forecast package, but I'm stuck in something that surely I've not understood well....
24 views

### auto.arima with an input of another series

Two time series, which are related to each other. I want to see if "order" helps in predicting sales, by running auto.arima ...
14 views

### How to obtain different values of “parameter k” in a mixed-effects negative binomial model?

I have a dataset with two level factors - fertilizers ("Nitrogen" or "Phosphorous") that differed in their concentration level("...
36 views

### PowerSim function (simr package) indicates 100% power for small sample dataset, regardless of effect size, alpha level, or if fixed/random slopes

I am using the simr package to do power analyses for lmer multilevel models I have run, to determine the power of a pilot dataset for future research. The dataset consists of 46 subjects with ...
29 views

### How to combine the results from two poisson regression analyses into one

I am very new at both R and statistical analysis and thus have very limited knowledge, so please bear with me! I have a dataset with country-year data based on event counts, but data for about half ...
15 views

### Finding stability in a time series of success/failure data — Mixed Model Random Effects

I have a very large data set of success/failure data for hundreds of subjects. The chance of success is rather small but does/should stabilize over time. Subjects have varying levels of observations/...
20 views

### How to analyse an impulse response function with more than 2 variables?

I am running an impulse response function in R, using the package vars. My data has 3 variables, the inflation (Brazilian CPI, or IPCA), the exchange rate and the output gap. My goal is to calculate ...
26 views

### Statistical test to compare two proportions

I am performing a meta-analysis comparing proportions of patients diagnosed with a disease based on 2 different diagnostic criteria. I have collected and pooled proportions rates (patients with a ...
13 views

### How to get adjusted explained variance of PC using Sparse PCA in R

I am using "elasticnet" package to do the sparse PCA. However I could only get the percent of explained variance of each PC. I am wondering can I get the adjusted explained variance of each PC using "...
11 views

### Cross-validation vs. F-test : Curve fitting using penalized spline regression

This question relates to a previous post here. I have a curve with a disturbance in the middle (at t=9) which causes a downturn (t<9) and an upturn (t>9) in my data. I would like to use curve ...
53 views

### Simple Bayesian meta-analysis in R [closed]

Is there a simple way to conduct a Bayesian meta-analysis in R in order to support equivalence between the effects of two study types? E.g., Bayes factors would be perfect. So, for example I have ...
25 views

### AIC and BIC values by auto.arima and manual ARIMA

A time series of yearly data, I want to compare the AIC and BIC values by auto.arima and manual ARIMA. ...