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
0 votes
0 answers
7 views

In R, when presenting data (RCT) in a table (preferably gtsummary), how to include tests of significance both within group and between groups? [pic] [closed]

I am learning how to analyse the data and present the results of an RCT using R. I have tried reading the package documentation, and searched online but did not find a solution for this. I have 2 ...
Muhammad Aaqib Shamim's user avatar
1 vote
0 answers
21 views

hierarchical regression in R with heterocedasticity

I performed a hierarchical regression in R using lm. I evaluated the assumptions with statistics and visually, using the performance package. Visually, I observe heteroscedasticity, although Breuch-...
María Victoria Ortiz's user avatar
0 votes
0 answers
9 views

What is the average number of students looked at for a quantitative education study? [closed]

On average, how many students are looked at for a quantitative education study?
new guy's user avatar
0 votes
0 answers
5 views

coef/vcov not consistent with basis matrix [closed]

I am trying to run a non-linear Distributed Lag Non-Linear Model (DLNM) with data structured using the nested case-control methodology, incorporating five lags (years 1-5). Each case has exactly two ...
Nitzan Sagie's user avatar
0 votes
1 answer
61 views

How to do log subtract (just like logsumexp) with probabilities? [closed]

To subtract a small probability from another, this answer has constraint on log probabilities l1 > l2: Subtracting very small probabilities - How to compute? but I need a function that works for ...
monotonic's user avatar
  • 181
0 votes
0 answers
7 views

How to calibrate and simulate a copula-garch model in R using rmgarch package

So I have been trying to calibrate and simulate cryptocurrencies for VaR and ES analysis using the rmgarch package in R. I have been using the t-copula, my reason being that cryptocurrencies' ...
Xerium's user avatar
  • 1
2 votes
1 answer
29 views

Hypothesis tests in summary of glm() are always Wald tests?

The summary output of glm() in R uses t-statistic when dispersion is estimated and z-statistic when dispersion is not estimated. I want to know if both tests are ...
quibble's user avatar
  • 1,482
0 votes
0 answers
15 views

GLM dispersion based on Pearson residuals

In R's glm, the dispersion parameter can be automatically derived using a quasilikelihood model. When I manually compute it, the values are slightly different. The difference is very small and will ...
quibble's user avatar
  • 1,482
0 votes
0 answers
12 views

One-tailed Bayesian correlation hypothesis with BFcorrelation, interpretation output?

For the following command: correlationBF(df$var1, df$var2, nullInterval = c(-1, 0)) I get the resulting output ...
rbeginner's user avatar
2 votes
1 answer
35 views

Confidence interval for GLMM

I am conducting a GLMM for my bachelors thesis and I am wondering, how I can calculate and whether it is common to report confidence intervals for the models' estimates. This is the model I fitted on ...
Johanne's user avatar
  • 31
0 votes
0 answers
12 views

Flexible covariance structure of the nested term in linear mixed model

Linear mixed model with one grouping factor nested in the other is commonly specified as mod1 below, using the Oats data from ...
Patrick's user avatar
  • 227
0 votes
0 answers
24 views

Outlier and influential analysis for multilevel meta-analysis with robust variance estimation

I am conducting a three-level meta-analysis where I have different dependency structures in my data. I model the dependency by approximating the var-cov matrix, followed by estimating a three-level ...
user408318's user avatar
1 vote
1 answer
56 views

Non-linear regression with very noisy data with nls() in R

I am trying to fit noisy data to a specific model with two parameters which I would like to estimate. Unfortunately, the model fit is just terrible with added noise. Is there anything I can do to ...
leze's user avatar
  • 11
0 votes
0 answers
15 views

Interpreting results with a cox test

I am trying to compare 2 non nested models using coxtest from lmtest library. Lamentably I can not find some explanation about the results from this test. My first goal was use anova(model1, model2) ...
Rodrigo Badilla's user avatar
0 votes
0 answers
14 views

Comparing regression slopes between two groups that have differing number of variables [closed]

I've been asked to compare the slopes between two multiple linear regressions in R. (e.g. find the p-value between the slopes) with age as a covariate in the model. Is this something that is typically ...
Silvia's user avatar
  • 1
0 votes
0 answers
5 views

How to interpret AggregateExpression() in R?

I am new to scRNA-seq analysis and cell type deconvolution. I am attempting to create a 'pseudobulk' matrix (where rows = genes, columns = cell types, and cell values = TPM) from my scRNA Seurat ...
user avatar
1 vote
2 answers
76 views

Subgroup analyses after propensity score matching

Assume an already propensity score matched cohort. One of the variables included in the propensity score model is sex. The main cox model investigates the comparative effect of two drugs for cancer ...
geek45's user avatar
  • 39
0 votes
0 answers
5 views

Can I restrict the predicted values in Partial Least Squares -model?

I'm using the r-package pls, and I want to use the Partial Least Squares method to create a prediction of my data. The input I'm using is land cover percentage (bare soil cover-%, "soil") as ...
user avatar
1 vote
1 answer
12 views

After matching: How do I interpret the value of the type ‘distance’ (=Propensity score) in the balance measures table of the r-package cobalt bal.tab?

I have used the R-package ‘MatchIt’ to perform (1) a nearest neighbour propensity score matching (NNM) based on the Framingham Heart Study and (2) for comparison, an optimal PS matching (OM) for the ...
user19939387's user avatar
0 votes
0 answers
15 views

How can I improve my R code for a two-way repeated measures ANOVA to produce the correct degrees of freedom? [closed]

I am running a two-way repeated measures ANOVA in rstudio and I find that the output of the analysis produces some strange degrees of freedom and I worry that the analysis is not accurate as a result. ...
user avatar
0 votes
0 answers
14 views

Showcasing Generalized data with data using matplotlib

Price of Bread in Afghanistan with Average We are currently looking into prices of food throughout the world. We want to show the general trend of a price in a certain country (In the example ...
user avatar
2 votes
1 answer
37 views

Nested, Crossed or both random effects

I am building a GLMM model with a binomial response variable, and I am having trouble determining which combination or nested or crossed effects to use. My situation is the following: 1.) I have ...
geoscience123's user avatar
2 votes
0 answers
18 views

Difference between reghdfe and fixest for a multiple FE regression?

I am estimating the following equation using fixest: $$ Y_{i,f,s,t} = \beta_1 treat_i + \beta_2 post_t + \beta_3 treat_i*post_t + \alpha_i + \alpha_{s,t} + \alpha_{f,t} + \epsilon_{i,f,s,t} $$ where ...
ladyp's user avatar
  • 31
0 votes
1 answer
30 views

The repeated measures, mixed effects models

My dataset contains participants who have been treated with intervention or placebo, the outcome is salivaflow (continous) and is measured at 0, 4 and 12 months. The outcome variable ($Y_{i}$) is the ...
A_Carl's user avatar
  • 1
1 vote
0 answers
14 views

Is it possible to control for autocorrelation within individuals and families using GLS corCAR1?

I have a sample of twins with repeated measures of BMI. I want to determine whether intake of a nutrient is associated with BMI trajectories. I have been using GLS in the ...
Gaby's user avatar
  • 11
0 votes
0 answers
33 views

Describing data structure and specifying a linear mixed model in nlme with nested and crossed effects

I am trying to specify a linear mixed model to analyse data with the following structure and have several questions about correctly describing the structure of the data and how to specify the model. ...
Pratorum's user avatar
0 votes
0 answers
6 views

Monitoring the Evolution of Inequality in Time-Dependent Distributions

I created a self-contained example in R that you find at the end of the post. I would like to be reassured that what I do makes sense. I have a dataset with 2 variables: year is a time variable, ...
larry77's user avatar
  • 203
5 votes
2 answers
70 views

How to write a function for the normal copula in R?

How can I write the following function for the normal copula in R? $$ C_\theta(u, v)=\Phi_\theta\left(\Phi^{-1}(u), \Phi^{-1}(v)\right), $$ where $\Phi$ is the $N(0,1)$ cdf, $\Phi^{-1}$ is the ...
Aria's user avatar
  • 51
0 votes
0 answers
25 views

Calculating a certain probability in R

On a circle of length $t$ there are given $n\ge2$ arcs of length $a$ whose centres are chosen independently and at random. The probability that these $n$ arcs cover the whole circle is $$ \sum_{v=0}^n(...
Cm7F7Bb's user avatar
  • 299
0 votes
0 answers
11 views

Visualizing restricted cubic splines in glm.nb

I am trying to visualize the relationship between a continous variable ("marker") and a count variable ("count") using a negative binomial regression with a restricted cubic spline ...
Fabian's user avatar
  • 49
1 vote
0 answers
60 views

Bread freshness in bread basket, Multi-Level Analysis in R; 2 time points [closed]

This is my first attempt with multi-level analysis. My research question is; How does the freshness of different types of bread (6 level) within a bread basket, change over two time points (ranging 4-...
Jackson's user avatar
  • 11
0 votes
0 answers
29 views

Why is denominator df missing? Why is my numerator df deemed infinite? [closed]

I have a few questions about the dfs I received from the below. I will try to keep this explanation short. Please see this post: How to tweak my glmmTMB model to address several items? i.e. ...
bribina's user avatar
  • 43
2 votes
1 answer
28 views

How do you model the two-way interactions between a continuous variable and two factors but not the three-way interaction with GAMs?

For the example, let's suppose I'm trying to model the level of activity of some frogs depending on a continuous variable (water temperature) and two factors : their sex (M or F) and the period of the ...
Boussens-Dumon Grégoire's user avatar
1 vote
0 answers
23 views

Same p-value of overall model and binary predictor level 2 versus Intercept (lm function in R)

I have a response variable PC1 (it is PCA scores for a bunch of observations). I have a response variable category with two ...
Shakir's user avatar
  • 143
0 votes
0 answers
11 views

Multivariate Probit Model gives warnings in R

I have a set of agricultural practice adoption data for a set of plots, and demographics and other survey variables associated with each farmer. Some points to note - a few farmers have multiple plots ...
cha116's user avatar
  • 1
1 vote
0 answers
10 views

What is the difference between model\$pred and model\$finalModel\$votes in a random forest model trained by caret?

I trained a random forest model as below: ...
Robin's user avatar
  • 119
0 votes
0 answers
9 views

Timepoint lsmeans post-hoc mean comparisons

Can anyone suggest which is the most appropriate test? I have changes from baseline (4 timepoints including baseline) in the Y axis and the timepoints in the X axis, 4 treatments. I want to see, if ...
pepe84's user avatar
  • 1
0 votes
0 answers
15 views

HAC for plm object in r [closed]

I want to estimate a fixed effects model (with both country- and year fixed effects) and ADDITIONALLY apply HAC standard errors. Although I didn't get any error message after running the following ...
TFT's user avatar
  • 193
0 votes
0 answers
13 views

Identical SE values for different groups using emtrends [closed]

I'm using emtrends to extract slopes and do pairwise comparisons between the groups of my independent variable, controlled for the other variables in the model. ...
Mike's user avatar
  • 131
3 votes
1 answer
33 views

Identical SE values for different groups using emtrends

I'm using emtrends to extract slopes and do pairwise comparisons between the groups of my independent variable, controlled for the other variables in the model. ...
Mike's user avatar
  • 131
0 votes
0 answers
6 views

Behavior of clustered SEs for cross-level interaction with a 0 cell in fixest

I am using fixest in R for fixed effects logistic regression with clustered SEs. I am not able to share my data but hope I can explain the question well. I have 11 clusters with between 29 and 493 ...
dianishhh's user avatar
1 vote
2 answers
82 views

How to model a controlled experiment (three time points, two groups) in lme4?

We conducted a behavior change field experiment using the following variables: Three time points (T0, T1, T2) Two groups (intervention vs. control) Individual ID Workshop ID The intervention was ...
AnnaBosshard's user avatar
0 votes
0 answers
9 views

Linear Probability Model in a hazard framework (right censored data) [closed]

As I am working on a paper, I need to run a Linear Probability Model (LPM) in a Hazard framework. I have almost 1 million mortgage loan data with their characteristics and monthly payment performances ...
mystabilos's user avatar
0 votes
0 answers
40 views

Constructing nomogram from approximate model in Regression Modelling Strategies

In section 19.5 in Regression Modelling Strategies by Frank Harrell we make an approximate model using linear regression with ols. Since this is an ols object we have to calculate survival quantities ...
ScapeProf's user avatar
2 votes
1 answer
33 views

When to include random-effects in zero-inflation model component?

Is it appropriate to specify random-effects (RE) in zero-inflation (ZI) component of the model? My intuition is that whatever RE is appropriate for main component should be appropriate for ZI ...
Suhas Bharadwaj's user avatar
0 votes
0 answers
11 views

Help me figure out my identifying assumptions and threats of identification and robustness checks [closed]

I'm studying how droughts and floods impacts unemployment rate (baseline specification), mean weekly hours worked per employed person (baseline specification). And then, to extend my analtsis I will ...
zeinab hassano's user avatar
0 votes
0 answers
24 views

Inconsistent Results with SEATS and X-11 Decomposition Models in R using fpp3

I’m experiencing inconsistent behavior when applying time series decomposition models in R using the fpp3 package and would like some guidance. I have a time series of Broad National Consumer Price ...
Fam's user avatar
  • 1,007
0 votes
0 answers
30 views

Plotting interaction by logistic regression

I have used R to plot the interaction term from the logit function I computed. I use the standard cat_plot() to plot the interaction. I clearly see that the two ...
Devi Sita's user avatar
  • 309
1 vote
1 answer
24 views

How do I resolve singularity issues related to my random effect term in LMM

I am trying to run a linear mixed model (LMM) to observe how CH4 and CO2 fluxes change over time. I have a randomized block design with repeated measures over time. I also have an unequal sample size, ...
user avatar
0 votes
0 answers
35 views

Understanding (0 + Days | Subject) in lme4

The vignette "Translating lme4 models to sommer" of the sommer package explains fm1 <- lmer(Reaction ~ Days + (0 + Days | Subject), data=DT) as "...
Patrick's user avatar
  • 227

1
2 3 4 5
598