Skip to main content

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

Filter by
Sorted by
Tagged with
1 vote
1 answer
91 views

Analyzing review rating using R STM package - sample balance issue [duplicate]

For the online reviews datasets, one of the tasks is to investigate the difference in topic proportion (e.g., topics as positively vs. negatively commented). Because of the positively skewed J-shaped ...
James's user avatar
  • 43
3 votes
1 answer
220 views

Can I include a variable related to the outcome variable into statistical analysis?

My research question is about the contact patterns during the pandemic and what characteristics of people who contacted more person during the national lock down. The outcome variable is a variable ...
Chao's user avatar
  • 83
0 votes
0 answers
27 views

Sampling distribution of the proportion of events

For categorical variables with $l \ge 2$ categories, what is the sampling distribution of the proportion of events in each category? These are obviously not independent, since they add up to 1. Does ...
Jessica's user avatar
  • 1,251
1 vote
1 answer
67 views

Date as random effect in mixed model strongly changes coefficient estimates

I am struggling with the structure of a mixed model that I run with lme4. I have measured a behaviour (let's say reaction time) and another variable that might impact it (let's call it "mood, ...
BRB's user avatar
  • 33
1 vote
1 answer
21 views

AR(p) model in R not fitting data [closed]

I have a set of data that I am trying to model with a simple AR(p) model. I've run a Dickey Fuller test on unit root stationarity and reject the null. However, when I run a simple ar command in R I ...
hmmmm's user avatar
  • 539
0 votes
0 answers
46 views

Steps to conduct a linear mixed model and post-hoc comparison test

I would like to ask for your help with the best way to analyze the following experiment within R. Here is my design: there are 15 treatments, in four blocks. For each treatment, in each block, we have ...
Caio Mattos Pereira's user avatar
1 vote
0 answers
31 views

Degrees of Freedom in Emmeans

I am using the 'emmeans' package in R to compute estimated marginal means for my (liner mixed-effects) model. However, I am enountering a warning message related to the number of observations ...
babygould's user avatar
1 vote
0 answers
32 views

Looped Regression and Inference in Stata or R

I have a sample of panel data and am running regressions on a loop for values of a specific categorical variable. For illustration: $$ y_{it} = \alpha_i + \eta_t + \beta^C D_{it} + \epsilon_{it} $$ ...
Darken Economics's user avatar
3 votes
1 answer
41 views

How to analyze this data in R, where there is no clear distinction of the response variable and the predictor variable? [closed]

Is there a statistician out there who knows how to analyze psychology surveys? Due to the way my response variable is structured in my data frame, I'm struggling to analyze it in R. Please, I ...
user avatar
0 votes
0 answers
30 views

Quantifying effect-size and correlation between two data frames

I am conducting an effect-size analysis on dam release and downstream temperature measurments. To do this, I am comparing the gauge temperature (the temperature of the water released from the dam) ...
Matt Schaaf's user avatar
0 votes
0 answers
19 views

Is this the correct way to go about determining correlation between upstream and downstream temperature?

I am new to stats and R in general, so please bear with me. I have been trying to find an answer to this question for about the past week and have spent a ton of hours researching but am still ...
Matt Schaaf's user avatar
4 votes
3 answers
108 views

How to fit a Bayesian model to a mixture of Beta and One-Zero inflated data?

I have very noisy data, which I believe is created through interactions of multiple physical processes. In the mapping $Y = f(X),$ $Y$ is a ratio $[0, 1]$ and $X \ge 0.$ While $Y$ is a function of $X,$...
PPR's user avatar
  • 101
0 votes
0 answers
42 views

How can i make a simple visualization of my result from a two way fixed effects regression model?

I am trying to understand the effect of the variable x1 on the dependent variable y1, and for that i have panel data. I decided to use a two way fixed effects model to estimate the effect of variable ...
user413005's user avatar
2 votes
1 answer
76 views

What are the `estimates` returned by `avg_slopes()` in modelsummary?

I have an interpretation question of R's marginaleffects avg_slopes function for logistic regression models. Consider the ...
spindoctor's user avatar
0 votes
0 answers
28 views

Linear mixed model, negative information criteria values and Hessian matrix not positive definite?

I'm trying to perform this operation in R. ...
Maley's user avatar
  • 1
0 votes
0 answers
9 views

Repeated-Measurements Analysis with Cross Correlation

I am trying to find the cause-and-effect relationship between water release from dams and downstream temperature. I have a data frame containing all of the temperature measurements from various sites ...
Matt Schaaf's user avatar
0 votes
0 answers
41 views

Selecting degrees of freedom in stepwise regression (stepAIC function in R)

Context: I have data available on water quality in a number of catchments, for example the concentration of Zinc (Zn). For each catchment, I also have a range of characteristics (n=16), such as the ...
Matt Tomkins's user avatar
1 vote
1 answer
54 views

Correlation alternatives / How to go about testing this relationship?

I have a large set of temperature data from upstream and downstream gauges. I am trying to find the influence of dam release on downstream temperatures. To do this, I am comparing correlation between ...
Matt Schaaf's user avatar
0 votes
0 answers
32 views

Correlation alternatives / How to go about testing this relationship? [duplicate]

I have a large set of temperature data from upstream and downstream gauges. I am trying to find the influence of dam release on downstream temperatures. To do this, I am comparing correlation between ...
Matt Schaaf's user avatar
2 votes
1 answer
44 views

Key driver analysis in R - different packages produce slightly different results: Is this to be expected?

I am doing a key driver analysis with customer experience data. I have run the analysis with three different packages in R: rwa, ...
user13716's user avatar
  • 123
0 votes
0 answers
15 views

Tradeoff between autocorrelation and memory in a GLMM

I am working with a large dataframe in R. It is a BACI design (Before-After-Control-Impact). I am interested in seeing if the interaction between Treatment (0 = control, 1 = impact) and Period (Before,...
Elise Miller's user avatar
0 votes
0 answers
30 views

Determining the p-value of a test statistic, which is not distributed according to a commonly known distribution under the null hypothesis

Currently I am working in R on a project that aims to identify Dragon King events (massive outliers) in large datasets. These outliers appear for example in the city sizes in England, where London is ...
user25936873's user avatar
1 vote
0 answers
26 views

How to simulate this AR(1): Xt =2+0.8(Xt_1 −2)+εt series in R? [duplicate]

I want to simulate an AR(1) model defined as follows: $$X_t = 2 + 0.8(X_{t-1} −2) + \varepsilon t$$ but I do not know how to interpret the constant $2$ in this term. How do I simulate this in R?
Maurice Pape's user avatar
1 vote
0 answers
19 views

Grid-level spatial fixed effects (with time and seasonality)

I have panel data with reported human-wildlife conflicts with a date and grid cell location: I'm trying to isolate the impact that extreme precipitation and temperature have on conflict rates. I am ...
spes's user avatar
  • 11
3 votes
1 answer
111 views

Why would `pROC::roc` calculate $\max\{AUC, 1 - AUC\}$ by default?

There is some interesting behavior in the pROC::roc function in R. ...
Dave's user avatar
  • 65k
2 votes
1 answer
212 views

lme4 Inconsistency

We aim to model how reaction times (RT) differ between groups in a fully between-subjects design. We also expect item difficulty to affect responses, and to interact with group. Each subject (n=120) ...
James Scott's user avatar
1 vote
0 answers
49 views

How to prove that the dependent variable is explained by the two independent variables (which are correlated)?

I would like to show that the dependent variable Y is mainly explained by the two independent variables (A1 and A2). Theoretically, an increase in A1 increases Y, and an increase in A2 decreases Y. ...
Wei Liao's user avatar
0 votes
0 answers
27 views

post-hoc test for multinomial logistic regression brm model (categorical response)

I apologise as I am very new to this package and I really appreciate any help I can get. I have a brms model with a categorical response variable (Species) with the ...
user avatar
2 votes
1 answer
23 views

Analyzing lists and variables of multiple answers

My current issue lies within EMR extracted data for medications. There are multiple variables named: Medication_1, Medication_2, Medication_3, etc... This data may overlap and analyzing each column ...
Abdallah Al-Ani's user avatar
1 vote
1 answer
26 views

Model comparison or beta coefficient of full model?

my question is a rather theoretical one. I have to decide in advance how I want to analyze my data (I'm going with the lme4 package in R) and feel torn between doing a model comparison by creating two ...
Sahila's user avatar
  • 25
0 votes
0 answers
12 views

Post-hoc tests for repeated measures ANOVA with aligned rank transformed(ART) data

I'm working on a 2x3 factorial design with two within-subject variables and I'd like to test for both main and interaction effects. Since the data is not normally distributed, I've performed an ...
fr000g's user avatar
  • 1
0 votes
0 answers
10 views

How can I calculate the confidence interval for ACF

I have found multiple sources. One is claiming that the confidence interval is estimated by: qnorm((1 + ci)/2)/sqrt(x$n.used) (How is the confidence interval ...
NickM's user avatar
  • 1
0 votes
0 answers
20 views

Calculate model with two sets of survey weights for the same population

I am working with a double set of survey weights for the same population X. The survey is probabilistic, stratified, multi-staged. Respondents have to answer two sets of questions: questionnaire A and ...
YouLocalRUser's user avatar
1 vote
0 answers
19 views

Ask a coding problem for the equivalence of unconstrained Optimization with L1 Regularization [duplicate]

I recently read a statistics paper. It has an unconstrained problem: $$\min_\theta F(\theta)+\lambda || \theta||_1$$, where $$F(\theta)=L(\theta)+\frac{\rho}{2}|h(W(\theta))|^2+ \alpha h(W(\theta))$$ $...
PiVoyager's user avatar
0 votes
0 answers
31 views

Correct test for regression with more than two factor levels?

Is it correct to use a "post hoc test" (e.g. a Tukey test) to analyse differences among factor levels in a linear regression or is there another method that is preferred? In my case, I have ...
Picapica's user avatar
  • 493
5 votes
1 answer
60 views

Quantile regression with sampling weights in R

I am trying to implement quantile regression with sampling weights in R for my analysis. I know in lm() and glm() in R, standard ...
Cate's user avatar
  • 51
0 votes
0 answers
38 views

How to plot the theoretical Lorenz and Bonferroni graphs for custom distribution [closed]

This is the CDF and donot have closed form quantile function. Any help will be appreciated CDF=((alpha)**(1-exp(theta*x))-(beta)**(1-exp(theta*x)))/(alpha-beta) I ...
Sid's user avatar
  • 1
1 vote
0 answers
14 views

penalized package [closed]

Has anyone used penalized package? I was using it for lasso in Cox regression, with time-varying coefficients. The problem is when I made a plot with ...
Danny's user avatar
  • 11
0 votes
1 answer
39 views

How to approach GLMs using data with beta distribution in R?

I'm trying to run some models on bee presence with five predictor variables. A snippet of the data is attached, but essentially I measured floral abundance and richness, calculated floral evenness and ...
alexia m's user avatar
0 votes
0 answers
17 views

Tobit estimation on panel data in combination with an IV approach in R?

I have panel data (country by year) and my dependent variable is left-censored (many countries have zero values, other countries have very large numbers). So, I think that I should implement a Tobit ...
TFT's user avatar
  • 345
3 votes
1 answer
48 views

Extrapolating standard error of logistic regression in R

I'm trying to extrapolate the mean and standard error range of a logistic regression using the predict function in R, splitting the x axis range up into small pieces and predicting the value at each ...
js4032's user avatar
  • 75
0 votes
0 answers
38 views

Why am I getting Negative Marginal Effects for Coefficients that are Positive?

I've run a hurdle Poisson model in R on the pscl package and used the marginaleffects package for the marginals and I'm getting ...
Terrie's user avatar
  • 1
0 votes
0 answers
19 views

correlations and adjusting p-values

I want to determine the correlation and p-value between one variable and all of the others in an R data frame, so I created a correlation matrix with cor_mat, and ...
Steven Morrison's user avatar
2 votes
1 answer
28 views

Exponential Regression dependent variable with dummy variables or numerical average of each category?

My dataset includes toxin concentrations (continuous, dependent variable) for different size classes (5mm increments) of juvenile fish (categorical, independent variable). The smallest size class is ...
96jtaylor's user avatar
1 vote
1 answer
25 views

cor_mat , cor.test , and adjusting p values

I want to determine the correlation and p-value between one variable and all of the others in an R data frame, so I created a correlation matrix with cor_mat, and ...
Steven Morrison's user avatar
0 votes
0 answers
14 views

Reproducing model with fractional polynomial predictions

I'm fitting a gamlss model using fractional polynomials. My x variable is a positive real number, including zero, and y is also positive real number ranging from 1000 to 2000. When I try to reproduce ...
kKodorna's user avatar
0 votes
0 answers
12 views

Time-varying coefficients based on binary variables

I am doing a survival analysis, and for each individual i have one event occuring (the one of interest), then i have baseline events (inc1 & ...
BPeif's user avatar
  • 143
0 votes
0 answers
19 views

Negative average marginal effect for positive estimate in ordinal logistic regression

I'm running an ordinal logistic regression with eight indepdent variables and the dependent variable has five categories (1 = Not at all and 5 = To a great extent). To interpret the coefficient ...
silje's user avatar
  • 1
0 votes
0 answers
36 views

How to calculate confidence interval using the delta method in R?

I'm trying (struggling) to calculate the delta method for a confidence method in R. Does anyone know how to do it? Any advice would be most welcome. In the literature, there's a simple IV/2SLS model ...
user avatar
0 votes
0 answers
12 views

Choosing number of classes in LCA

I'm an undergrad student, a little confused about goodness of fit tests. I'm trying to choose the appropriate number of classes for a latent class analysis using ...
dancing_monkeys's user avatar