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

27,147 questions
Filter by
Sorted by
Tagged with
2 views

### Degrees of freedom when comparing models applied in a secondary (test) dataset

Two models in R: mod_a = lm(height ~ age) mod_b = lm(height ~ age + sex) Those models have different degrees of freedom. Once they are applied in a separate set, ...
• 359
4 views

### SUR regression gets error "LU computationally singular: ratio of extreme...": can work around but still concerned about error margins

I originally posted this to stackoverflow, and was advised by I_O that the question would be appreciated more here. I am not sure how to reformat this to be appropriate here, so I am copying it over ...
• 121
6 views

...
6 views

### ANOVA interaction effect

https://i.stack.imgur.com/wdXwB.jpg If I'm performing ANOVA using the formula in R: aov(Ileibacterium ~ diet*cage, data) Context - there are 3 cages per diet with 3 ...
• 11
11 views

### Autocorrelation of residuals

I am working with R and I got the following residuals in time series. But I have problem determine if the are autocorrelated or not. Any help?
• 25
4 views

### mediation::mediate does not support more than two levels per model

When I fit a mediation model using mediation::mediate, like this: ...
8 views

### How to make a two-line mediator analysis in R? [closed]

How to make a two-line mediator analysis in R? Please tell me briefly how to do this. What function should I use? I don't know much about data analysis, but I really need to figure out how to do this ...
• 1
1 vote
9 views

### Could someone help me with R code to estimate the Value-at-Risk using the hierarchical Archimedean copula approach? [closed]

To estimate the Value-at-Risk of a two-dimensional portfolio (d=2) by the archimedean copula approach, the process can be for example : x<-mvdc(archmCopula(family="gumbel",param=3),c(&...
• 19
6 views

### Can I use one-way ANOVA for two and for three groups in order to maintain consistency across different sample types?

TLDR: Some of my larger dataset has two levels, while some has three levels. Is it appropriate to test everything using one-way ANOVAs or should I do some as t-tests and some as ANOVAs (Welch's for ...
11 views

### Please, could someone help me with the R codes of goodness-of-fit tests on hierarchical archimedean copulas? [closed]

My question is to know on the one hand which methods are used for goodness-of-fit tests in the case of hierarchical archimedean copulas(dimension greater than two), and on the other hand which R code ...
• 19
8 views

### Three-level Meta-Analyses: correlation comparisons and correction for publication bias?

I'm conducting a three-level meta-analysis on correlations using the {metafor} package on R. I'm quite a newbie when it comes to three-level meta-analyses, so I have two doubts. 1) From each study, I ...
9 views

### Caret ordinalRF error when using classProbs= TRUE: attempt to set 'colnames' on an object with less than two dimensions [closed]

I am trying to train a random forest with caret. All the variables in my dataset (here the link to it) are categorical, and many of them ordered, including the dependent variable. So I added ...
• 101
5 views

### Using the Dunn test to get the CLD grouping for the Skillings-Mack test

I have a set of phenotypic data collected from 9 different assays of a set of different plants. Each plant was assayed at least one time, but each individual assay had a different set of plants. So ...
33 views

### chi-square goodness of fit test on count data

I am performing chi-square goodness-of-fit test on a predicted and observed count data. Some observed counts are very low or zero. I have a two part question, - Does r's chisq.test function exclude ...
• 11
35 views

### Subclassification on a propensity and prognostic score grid with k × k subclasses, using R MatchIt

I would like to perform a joint subclassification of some data on the propensity and prognostic scores as described in this paper "On the joint use of propensity and prognostic scores in ...
8 views

### sample size calculation based on survival rate at 2-year

I encountered a paper which shows the calculation of n=1240 patients: Because the 2-year PFS is very high for the treatment (81%) and control (73%), which means that the median PFS is not reached, ...
• 893
14 views

### Determine how likely a combination of two counts is compared to null models for both counts

I have two zero-adjusted negative binomial regression models fitted via gamlss not necessarily using the same covariates but at paired locations. ...
• 23
1 vote
11 views

### County-level fixed effect model - how to improve the predictive power

I'm doing a linear regression in the hopes of developing a predictive model for fatal drug overdoses at the county level. My data looks like this (note, pc=per-capita), there are 504 total ...
• 141
15 views

### What is the correct way to determine statistical significance for this data?

I'm trying to help a friend with a study over some medical data for his thesis. Facts are, neither him or me are really skilled so I'll try to see if anyone can push me in the right direction. I do ...
1 vote
16 views

### Mean of skew normal distribution with normal prior obtained with Gibbs sampling

I would like to obtain a new mean $\mu$ of a skew normal distribution with a normal prior of the form $N(\delta,\tau)$ on $\mu$, and a given standard deviation $\sigma$ and shape parameter $\alpha$. ...
• 11
10 views

### qrule mathematic interpolation in quantile estimation in R survey package

I've been having difficulty understanding the code for qrule_math in the survey package. This document here says this about it: ...
32 views

### Is my R logistic regression model ok? (NOVICE)

I'm currently training a model for spam detection on a training set with 4757 observations with 3000 variables counting word frequencies. It is taking forever and I have a deadline coming up so I ...
9 views

### Why is the closeness centrality value higher for less connected nodes?

I built an igraph graph from a data frame containing the (symbolic) edge list and weight. This is the data frame: ...
• 187
42 views

### Performing Fisher exact test or prop.test with counts of non-integer numbers? [closed]

If most of my count data are have non-integer numbers like (45.5,88.5), can I still use prop.test or fisher test? how that affect the results? This is how I calculated the counts: Lets say I have 100 ...
40 views

### Most suitable regression line

I have loaded the data set Animals2 from the package library (robustbase) and I have ploted three estimated regression lines (least-squares line, the LMS line, and the line of Siegel). I wanted to ...
1 vote
27 views

### Dealing with a warning message from prop.test in R

I did a prop.test for my data and I got this warning message : ...
22 views

### Difference between cross validation vs model accuracy measures

I have a time series ARIMA model and I want to validate the accuracy my prediction. But I dont understand the difference of using cross validation vs model accuracy measures such as MAPE, MAE, MSE and ...
• 1
11 views

### How can I compute rectangular confidence regions for parameters using R?

Simultaneous confidence regions for multivariate parameters (say, a confidence region for multivariate mean, or for regression parameters) usually find an elliptical region when the parameters' ...
• 1,063
5 views

### Caret: ordinal models with VGAM library

I started to look into the students performance dataset: https://archive.ics.uci.edu/ml/datasets/Higher+Education+Students+Performance+Evaluation+Dataset I would like to train two models with caret ...
• 101
1 vote
39 views

### Interpreting interaction effect with ln(time) in Cox regression

I am fitting a Cox proportional hazards model with the interaction effect dummy:ln(time). How would you interpret the result? Is it a simple exp(x)-1)*100 to receive the percentage increase in y? Edit:...
• 21
5 views

### knitting rmarkdown throws error printing result of contour() [migrated]

I want to knit the following code into an html document. The code runs fine in Rstudio but fails when I attempt to knit - what am I missing here? ...
41 views

### I have a group that contains zero data, and I want to know whether it is considered normally or not normally distributed.?

I have a group (group2) that contains zero data, and I want to know whether it is considered normal or not normally distributed. I used the SPSS software, and it showed this result. I also tried R, ...
• 21
9 views

### How to create the fixed effects model from the data? [closed]

I am working on the data about student's exams scores measured depending on techinque and the day exam was taken. ...
332 views

### QQ plot result doesn't correspond to normality test [duplicate]

I am considering an ANOVA model for such data: ...
30 views

### What is the bias adjustment needed on k-folds CV? (made by cv.glm on R's boot package)

I'm trying to find the equation defined on the documentation of the cv.glm function in the boot package: "When $K$ is less ...
• 21
19 views

• 5,728
22 views

### How to tell if data has homgenous variance? [closed]

I am checking the assumptions of ANOVA model and I want to see if the condition of homogeneity of variances is met in my model. I made such a plot, but I am not sure what to look at here and what ...
52 views

### What is the appropriate test for this type of dataset?

I was wondering which is the best test for a dataset like this (just showing first 3 variables): ...
13 views

### Detecting homogenity of variance from the plot [duplicate]

I am checking the homogeneity of variance of my data (to check ANOVA assumptions). I don't really know how to interpret it though, does it mean there is a homogeneity of variance here?
11 views

### How to choose between one-way, two-anova and multliple regression?

I am working on the data set that consists of Patients' id (after stroke), Time (they can walk after going through the program), the Program they follow and the Visit number when the Time was measured....
9 views

### Is there an R package to calculate global FST, with confidence intervals, for tetraploid populations [closed]

I'm interested in estimating global FST among several populations of a tetraploid plant species. I'm looking for an R package that can do this, and can preferably also produce an upper and lower bound ...
27 views

### How to choose between one-way, two-anova and multliple regression?

I am working on the data set that consists of Patients' id (after stroke), Time (they can walk after going through the program), the Program they follow and the Visit number when the Time was measured....
20 views

### Time series model in production - Re-train on the fly as as batch process?

Let's say I've a time series of phone calls per day over the last three years. I could train a model using exponential smoothing (e.g. HoltWinters) for predicting the future amount of phone calls per ...
• 101
1 vote
15 views

### How to fit parametric distribution to baseline hazard in cox PH model

I develop Cox PH model with time-varying covariates to predict marginal probability of some event. The time frequency is measured in months and I have observations since 3 months to more than 160 ...
6 views

### Best way to assign row of data to a group based on the values of other known groups?

I have a few hundred rows of data that includes the following columns One of 2 species’ names, or no name if the species is unknown (Unknown species have to be one of the 2 known species, they just ...
21 views

### Coding in R for rolling sum of row value [closed]

I have a data frame with columns for nitrogen (N) and the formula for the marginal product (MP). MP <- 9 - 0.20*N N<- c(0:600) data<-data_frame(MP, N) I ...
• 11
8 views

### R: Panel Data Clustered Standard Errors

Hi I have a panel regression and like to proof the robustness of my model. I estimated a fixed effects model with double clustered SEs. I estimated: an OLS - pooled model Fixed effects model Index: ...
1 vote
24 views

### How to extract the penalty term from the GAMM function in R and what is used to estimate the penalty terms

I'm working on some log GDP data and I am testing out a Generalized Additive Mixed Model for it with a penalized cubic regression spline. I am using the GAMM function from the mgcv package in R and I ...
• 179
I have implemented a Gibbs sampler to simulate from the joint posterior: $ln(y_1),...,ln(y_n)|\mu,\sigma^2 ∼_{iid} N(\mu,\sigma^2)$ Where both $\mu$ and $\sigma^2$ was unknown. I have simulated values ...