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

28,861 questions
Filter by
Sorted by
Tagged with
12 views

### How to determine contrasts in combinations of categorical variables with emmeans

I have some data with a continuous outcome that is measured among 4 categorical variables: treatment group, gender, collection date, and sub_type. Gender is M/F, collection date can just be Mon/Wed, ...
22 views

### Multiple events in Cox PH with time varying data

I study coups d'etat. I would like to understand the relationship between leader/country characteristics and the likelihood of coup attempts. I have a leader-country-year dataset with one entry for ...
372 views

### Why doesn't R output for a paired t-test match the formula for a confidence interval in the t-distribution?

My understanding is that the formula for a confidence interval when using a t-test is as follows: $\bar x \pm t_{n-1,\alpha / 2} \frac{S_d}{\sqrt{n}}$ where $S_d$ is the standard deviation of the data....
56 views

### Non-linear regression. Need some help implementing a model from a paper

I found this paper very useful for my research, however, I'm not familiar with non-linear regressions and I'm finding it tricky replicating it. Using the first f=model for example: ...
10 views

### Feature importance/model exploration in a large survival model

I've built very-well performing survival model (weibull proportional hazards model for interval censored data, modelled with IcenReg) with many covariates, some ...
16 views

### Create a graph in R [closed]

Hello I want to create a graph like that in R. Any help with the code I have to write to create it?
13 views

### Implementing bootstrap for sequential target trial emulation [closed]

I am currently working on sequential target trial emulation and have been stuck in the step of bootstraping. I would greatly appreciate any assistance, recommendations, or sample code that you could ...
22 views

### Autocorrelation returning non-significant values despite an apparent pattern

I have just finished Chatfield and Xing's The Analysis of Time Series, 7th edition and I'm beginning to play around with some simple analysis. I have this graph representing the grand mean value ...
1 vote
31 views

### How should I scale data that has been assembled from different data sources?

The data I'm woking with consists of 3 types of data: 1- binary features: those features are either 0 or 1. I have about 6 or 7 columns. 2- cells: the values here range from 0 to 0.8 at max. Here I ...
10 views

### Running the same mixed model with different contrasts to explore different hypotheses

I'm running the following mixed model to explore the relationship between Condition (3 levels; Predicted, ...
1 vote
63 views

### Multiple predictors that measure the same concept in regression

I have used three questionnaires in a study that all measure musical training. Each of these three questionnaires (MT1/MT2/MT3) consist of various Likert scales that are averaged to calculate the ...
28 views

### What are the possible solutions to do matching on very large dataset

Hi I would like to match a group of treated patients with an untreated group. I have about a million patients in the treatment group and ten times that in the control group. Conventional matching ...
27 views

### power analysis for glmer mixed models

I want to know an appropriate way to conduct a post-hoc power analysis for several glmer models built in R using the lme4 package. A reviewer asked for this. What I did: I used the R package simr ...
1 vote
17 views

### How to convert R output from auto.arima function into mathematical model?

I'm building a model using the auto.arima function in R, and it gives the following output: ...
46 views

### Variable (frequency) transformation in R from (0;1) range

I have variable with a range (0;1). I want to do a transformation, so that later I can use this variable as a dependent variable in my multiple linear model. For example, can I use logit ...
62 views

### The QF function in R does it calculate the area to the right or to the left (like a normal distibution)?

I am a bit confused regarding this issue. From my understanding the normal distribution and t distribution we look at the left tail for a one tail test and for the f and chi-squared we look at the ...
43 views

### What kind of regression model describes an x-y relation that y decreases at an increasing rate as x increases, and how to do it in R? [closed]

I have 5 dependent variables, y1-5, one independent variable, x, and two grouping covariates, m1, m2, and my goal is to look at which of y1-4 is more responsive to the change in x. I wanted to use ...
13 views

### How can I code an ordered logistic regression for panel data in R?

I am writing my thesis, and I am trying to test the relationship between transnational counterterrorism and state repression in countries of intervention. My independent variable is counterterrorism ...
1 vote
40 views

### Statistical analysis for sensory datasets

I am relatively new to statistics and dealing with a dataset where I’ve studied 3 different treatment groups on color change in bell peppers. I scored the bell peppers every day for one week based on ...
93 views

### Schoenfeld residuals for factors with cox.zph

The cox.zph function of the survival package computes the Schoenfeld residuals for each variable and tests the porportionality assumption with a score test, but I ...
29 views

### Can the confidence interval of an odds ratio be negative? [duplicate]

I am running logistic regression. The odds ratio estimate I got is positive but the lower bound of my 95% CI is negative (close to -1) and the upper bound is greater than 1. Would this mean that my ...
28 views

### Comparing frequency of events between two groups?

I have an analysis question that I need some help on. I received an analysis request to identify events that have statistically different frequencies between two groups. For example, assume I have ...
18 views

### Can an ADF-test distinguish between stationarity and trend stationarity?

I am learning Time series analysis and I am studying the augmented Dickey Fuller test. My understanding of the null hypotheses is clashing with all the explanations I find online and in books. I refer ...
23 views

### How to deal with a large dataset when implementing clustering?

I am working with what I believe is quite a big dataset, with $17$ columns (each corresponds to one variable) and $41714$ rows (each corresponds to one observations). My goal is to implement ...
40 views

### How to determine Seasonal periods in MSTS function?

I am seeking assistance in analyzing whether there are any discernible trends, seasonality, or cycles present in the monthly data represented by the following figures: I would greatly appreciate it ...
11 views

### Contour plots of a patio-temporal covariance function

I would like to plot contour plots of covariance functions in R: one for a fitted separable spatio-temporal covariance; one for the empirical covariance function, similarly to Figure 4.4 in Wikle et ...
1 vote
33 views

### How to make an correlation analysis in Python or R beetween two strings? [closed]

I want to make a correlation analysis of two nominal columns, the "advocates" column and the "company" column, the advocates in this case are processing the companies, the data ...
1 vote
23 views

### How to assign reasonable scale parameters to randomly generated intercepts for the Weibull distribution?

This is a follow-on to post Correctly simulating an extreme value distribution for survival analysis?, as I work towards adaptation of that code to the Weibull distribution. In the below code I ...
16 views

### What is the best way to impute missing data at the individual level for each hour of the day using R interpolation in Rstudio? [closed]

I have a data panel, which contains data for 5 months of the year observed for 3 different years. We have many individuals observed through these periods. The problem is that many individuals are ...
1 vote
41 views

### How interpret Pr(>|t|) results?

How interpret Pr(>|t|) results? Can I consider the "speed" significant for regression despite the "intercept" having no statistical difference? Or the linear regression model is ... 15 views

### What should I do with structural breaks at return time series?- R

Let say I have the below time series data(It is a return data of a financial derivative): ...
17 views

### Why are the estimated denominator degrees of freedom differ so much between lme and lmer models?

I want to run a linear mixed model (LMM) testing the effects of two continuous variables (FD and FI) over time (Year:FD, Year:FI) on my response variable (QMD). For LMMs I typically use lmer4 but as ...
21 views

### Test if different coins are distributed evenly on both sides in R [closed]

I need help to statistically test a uniform distribution of a toss of 7 independent coins. Here is the table : ...
1 vote
22 views

### How to check for homoscedasticity in a mixed effect model with longitudinal data in r

I am new to using mixed effect models and all the information online has me quite confused. I hope someone can help me. I have data of patients who did the same test at three different timepoints. I ...
39 views

### Variance of Weighted Mean: Formula vs Bootstrapping

I am interested in learning about how to calculate the Standard Deviation of the Weighted Mean. From Wikipedia (https://en.wikipedia.org/wiki/Pooled_variance, https://wikimedia.org/api/rest_v1/media/...
1 vote
15 views

### Transform Second Difference Predictions from VAR model back to levels

I am currently working with a VAR model in R using the second difference of some variables (it only becomes stationary after differencing twice). So far I'm trying to see if the model fits one of the ...
1 vote
32 views

### I want to know how this graph is being created? [closed]

I found this plot in a paper. I have found similar plots in other papers from the same team. It is basically the comparison of MODIS C6 and C5 products with AERONET. I wanted to understand what that '...
1 vote
73 views

### Mixed effects model to explore the linear relationship between two variables for each level of the repeated-measures in Rstudio using lme()

Background: I did an experiment in which 30 people watched 3 movie clips ("A", "B", and "C") in a random order. For each song and participant I measured one continuous ...
1 vote
14 views

### auocorrelated pseudo random data in R

I've seen attempts to answer this particular question before, but I'm either not understanding something (often a priori correct), or I'm missing a better way. Essentially, what I want to do is draw n ...
18 views

### standard error of the median survival time using r

I would like to find the standard error of the median survival time and do some approximation to estimate the density function around the median survival time according to equation (5) of this: http:/...
1 vote
50 views

### Interpretation of lme4 output with different contrasts for variables

I have data assessing reaction time (RT) with 2 variables: Variable 1: 'HighLow', with 2 levels ('High' and 'Low') Variable 2: 'Condition', with 3 levels ('Predicted', 'Implausible', 'Plaus/Unpred') I ...
16 views

### R: Selection probabilities with panel users (complex survey data)

I am calculating the weights for a survey, but I don't know what to do with my selection probabilities. Let's say I want to ask people from some country what their opinion is about several subjects. I ...
31 views

### R: Linear regression testing for β = 1 [closed]

I basically have the same question as this and this thread. In short: I want to test in R if the slope of a linear model equals 1 (β = 1). I know how to do it for β = 0, but the answers from the ... 79 views

### odd ratio interpretation in R with a random slope model

I have a graph like this above and I used the tab_model function in library sjPlot to report the results of my model. My Model is random intercept and random slope model. I am quite new with advance ...
80 views

### How to plot angular time series?

I am trying to inspect a circular time series (a long time series of angular measures in 0-360°). The main aim would be to identify abrupt changes in the time series, but as a start I would like to ...
16 views

### Introduce noise in a simulation [closed]

I am working on a simulation study. I need to simulate data with a specific matrix of correlations and I would like to introduce some noise (a confounder). So for example I simulate V1 and V2 with a r=...
42 views

### Classic TWFE model: treatment is collinear with the fixed effect

I am conducting a study to estimate the effect of Medicaid expansion on the uninsured rate using a classic Difference-in-Differences (DID) design with two-way fixed effects (twfe) model. My ...
1 vote
20 views

### IRT anaylsis with imputed datasets in 'mice' library and pooling the item parameters [closed]

I have "0=incorrect" and "1=correct" coded questionnaire, including 28 questions. There are missing data and I imputed the missing data with the Multiple Imputation method. After ...