# 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,618 questions
Filter by
Sorted by
Tagged with
1 vote
52 views

### How to find variance of multivariable expression

I have an expression of this form $W_i = a * X_i * (1 - Y_i * (1 - Z_i))$, where $a$ is a constant, $X_i \sim Bernoulli({p_x}_i)$, $Y_i \sim Bernoulli({p_y}_i)$, and $Z_i \sim N(\mu_i, \sigma)$ ...
1 vote
56 views

### Fitted Gamma model doesn't go through first datapoint

I have a dataset which looks like this ...
7 views

### Interpretation and examples for unit vs time fixed effects (oneway)

I seek to understand the difference between unit / entity / individual fixed effects and time fixed effects. Both are oneway. Many questions surround them in contrast or addition to twoway fixed ...
• 284
6 views

### How do I know if the function lavCor from the lavaan package in R computes the polychoric or the polyserial correlation?

to compute the pairwise correlation matrix for my variables I used the lavCor function from the lavaan package in R. I have 9 variables, from which 8 are ordered variables and one is metric. So I ...
• 31
45 views

### Predicting with GAM (mgcv) and categorical/factor covariate in R

I have some data for multiple users and I want to generate some marginal effects for each user using GAM modelling. If I do this exercise for just a single user (John) as: ...
87 views

### Restricted cubic spline looks like a linear curve, but p for nonlinear < 0.001

I am analyzing a association between a frailty index and care needs using the cox model. I use R and use rms package to fit restricted cubic spline. This is my R code. ...
• 35
124 views

### Disagreement between studentized Breusch-Pagan test and the plots "residuals vs fitted" and "scale location"

Given the model: > Durée <- c(6, 5, 3.5, 3, 5, 3, 2, 8, 2.5) > Note <- c(18, 16, 14, 10, 15, 13, 8, 19, 12) > model <- lm(Note ~ Durée) I was ...
1 vote
39 views

### Forest function error - "argument 1 matches multiple formal arguments'

I created the following random-effects model, and am hoping to -for now anyway- generate a very basic forest plot, using the forest function from metafor. This is the code I used: `res <- rma(yi=...
• 11
1 vote
21 views

### Power of Bernoulli likelihood in Jags (R2jags) [closed]

In a fixed power prior model, the model is set up as: $$\pi(p_i \mid \alpha,\mathcal{D}_0) \propto L(p_i\mid \mathcal{D}_0)^{w} \pi(p_i)$$ Suppose that the event follows a Bernoulli distribution ...
14 views

### Control for the effect of an outcome in proportion tests: a Bayesian case

I’m having some difficulties in data analysis plan for my research. I want to check if people do not have a preference between two objects. Therefore, I’m conducting a Bayesian binomial test. I choose ...
1 vote
25 views

### Cox PH model HR - is it possible to measure against the general average?

Reproducible example: ...
• 677
59 views

### Comparing standardised values of microbial colony perimeters

I’m having a statistical problem (a rather major one) and I was wondering if you could help. I’m researching microbial chemotaxis and analysing colony perimeters by scanning their fluorescence. ...
64 views

### Failing to find optimal linear fit in R with lm

I have three linear regression models in R: 1. lm(Y~X1) 2. lm(Y~X2) 3. lm(Y~X2+X3) Of note, in this data mathematically ...
• 463
1 vote
40 views

### Multifractional polynomial with mixed-effects logistic model

Dataset I am working on a dataset collected from more than 20 hospitals. I used the glmer command to estimate a mixed-effects logistic regression model with the ...
35 views

### Is survival analysis appropriate for forecasting time series data?

I have 32 months of historical data and I am testing forecasting methodologies. I assume that only 12 months of data are available, I forecast months 13-32, and then compare actuals for months 13-32 ...
1 vote
33 views

### ARIMA D coefficient for seasonality lesser than frequency

Lets suppose we have a time series with monthly data (frequency=12) my_tS <- ts(my_monthly_data, start=c(2002,1), frequency=12) When I plot it, I can see a ...
• 115
40 views

### Can I predict values from a multiple regression model with fewer predictors than there are in the model?

I have built a linear regression model with three predictor variables: the model predicts forest growth (y = stand volume) with stand age, stand basal area and site type (x1, x2 and x3 respectively). ...
• 31
14 views

### Can I use Dominance analysis (using r package domir for instance) with a negative binomial (nb.glm)?

I want to examine the relative importance of the predictors in my model. I know the domir package in R allows for the ...
8 views

### Not sure how to define effects in MEM in R

I have looked through all the online material about fixed vs random effects, and I have not been able to make head or tail of most of that which I have read. I am not a statistician, and unfortunately,...
16 views

### If I use anova() in R to compare two nested models, do I get a one-sided or two-sided p-vlaue?

I'm running a likelihood ratio test to check whether or not a condition has a significant outcome for subjects performing an experiment, and I'm using lmer in R to do this. So I run something like <...
10 views

### Panel data regression with time periods that are unaligned

I want to run a regression with panel data involving data from variables that are collected at different periods. Is there a way to do this, and if so, is it legitimate to do this or should panel data ...
10 views

### R gamsel for generalized additive model - interpretation

I have set up a gamsel like this ( X has ~ 60 different independent variables). I am struggling to interpret the summary and plots: ...
1 vote
44 views

### Using GAM Gaussian family to Examine Significance in Data Pattern Across Two Categorical Variables

I came across this post in using GAM with the default Gaussian family to examine the significant difference of the patterns across two categorical variables Statistical differences between two hourly ...
• 159
18 views

### What Bayesian priors are diffuse on the log scale?

I am trying to come up with priors for the intercept and coefficients of a Bayesian regression model on the log scale, but I can't get the resulting distribution of the prior to be diffuse once I log ...
1 vote
15 views

### Elbow plot and plot of average silhouette width disagree with each other

I am fairly new to using clustering. On the data science course I am on, we recently covered agglomerative clustering and k means clustering. I have created a toy example to see if I can use R to ...
• 101
40 views

### Interpreting interaction coefficients from categorical predictors in lmer

I have 4 mixed effect models that I want to compare - each one has exactly the same structure but a different outcome variable (see summary plot below). I need a statitical test of whether the effects ...
• 1
24 views

### One-way ANOVA F-test is significant but none of the Tukey pairwise test is significant

I made up this example myself: Three geoscientists from China, USA and Europe were interested in exploring the mineralogical and textural characteristics and organic carbon composition of carbonate ...
• 21
14 views

### Does including random effects in CLMM alter the calculation of OR?

I'm having trouble using the output of a model to find OR and 95% CI. I've created two models. Model 1 has no random effects (clm) and model 2 includes random 1 random effect of participant ID ...
• 1
68 views

1 vote
13 views

### Split block design with crossed main effects and a random effect in R

I am having trouble specifying a model in lme4. Your help with be greatly appreciated!! And please let me know if I can improve how I ask this question. I am looking at the impact of light, ...
• 11
49 views

### Why is the order of factors (order of samples in dataset) affect PERMANOVA results with adonis2?

I am trying to run PERMANOVA tests on multiomics datasets collected from coral samples using adonis2 (v 2.6-5). I found when the order of samples in my dataset change, the pvalues change, sometimes ...
36 views

### Weigthening social media sentiment scores

I struggle to understand how to implement a logical weighting of sentiment data. I predicted the sentiment for multiple Reddit comments. How can I weight them according to their scores? The problem is ...
13 views

### Efficient way to compare 2 similar datasets

I am a grad student who is fairly new to all of this. I have a matrix likert table that I was wanting to compare across 3 different relationships to the land. I got the means and standard error for ...
1 vote
35 views

### How to compare linear mixed models that do not satisfy the assumption of Gaussian errors?

I have fitted two linear mixed models, A and B, to a data set using lme4::lme: model ...
1 vote
26 views

### Gaussian Process posterior distribution

I'm trying to find a way to get the posterior covariance function for a mgcv::gam fit. Assuming I have a simple model y ~ s(x), ...
• 41
43 views

### Calculare Risk Ratio with CI in R from Odds ratios

I have performed a multiple logistic regression because I wanted to see the association between Death and Cardiovascular disease. I adjusted using age, sex, risk factors. The result came in ODDS RATIO ...
21 views

### Calculate percentual slope

I have the following dataframe (dput below): ...
• 291