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`.
33 questions from the last 30 days
3
votes
1
answer
120
views
Advice on regression approach
How should I handle a mass-point in the dependent variable when running OLS regression in R?
I’m working with a a household expenditure dataset (Living Costs 2019) where the dependent variable is the ...
0
votes
0
answers
13
views
Imputation with mice for multilevel data that is only missing level 1 values [closed]
This is my first time attempting data imputation with the mice package. I've read some tutorials but am still confused about how to apply the different examples to ...
0
votes
0
answers
32
views
Comparing to zero in emmeans pairwise comparisons?
I'm analyzing data on daily foraging dynamics of animals in different treatments feeding on a diet consisting of two different qualities (high and low) using R. The problem arises when there are days ...
1
vote
1
answer
39
views
Plot ARIMAX model with confidence interval in R
I fit an ARIMAX model on the data here (this is annual copepod phenology influenced by seasonality of water temperature).
Here is my model formula:
...
0
votes
0
answers
32
views
Can an estimated marginal mean be used to calculate an effect size for a power analysis?
I'm interested in calculating the required sample size for detecting a future hypothetical 30% increase in a marginal mean from a model based on pilot data (accounting for covariates and random ...
2
votes
1
answer
115
views
How do I estimate the linear effect for a factor so that my estimate doesn't depend on the sample size?
I’m trying to use the R poly() function with degree 1 to force glm to interpret a factor linearly. I’m puzzled by the fact that the size of the sample seems to increase the coefficient of the ...
0
votes
0
answers
47
views
Is it possible to fit a GEE that accounts for two crossed (non-nested) clustering levels?
It appears to be possible to fit a GEE when the clustering levels are nested, but is it possible when they are not?
1
vote
2
answers
66
views
Null hypothesis for likelihood ratio test (logistic regression)
Perhaps a silly question. I’m performing a likelihood ratio test in R using the mdscore package and the lr.test function, comparing a binary logistic regression model with one predictor to a null ...
3
votes
1
answer
76
views
Should I use glmer or glmmTMB (family = gamma (link= "log") for repeated measures experiment?
For my experiment, I exposed fish to one of two treatments (n = 10 per treatment) and repeatedly measured their metabolic rate at seven different timepoints. Unfortunately, at the last time point, ...
8
votes
1
answer
172
views
Different CIs for the same linear mixed model emmeans, ggemmeans, ggpredict
I fitted a linear mixed model in R and tried to compute marginal means using emmeans, ggemmeans (from ggeffects), and ggpredict (also from ggeffects). The predicted means are similar, but the ...
0
votes
0
answers
36
views
True slope parameter for quantile regression with heterogeneous error
I am trying to perform a Monte-Carlo simulation on quantile regression using R. Currently I am getting stuck simulating the data from the model below.
...
3
votes
1
answer
75
views
Confounding due to minimal covariate overlap in glmm
I'm analyzing an ecological dataset of nutrient concentrations (continuous) across seven stations (each station is nested within one of three sites). We also have ~60 samples from each station where ...
6
votes
1
answer
164
views
Calculate confidence intervals for spline after change in reference- manually
How do I calculate confidence intervals for a spline function after changing the reference?
I would like to plot the spline with reference at age=52 along with the confidence limits.
...
6
votes
3
answers
178
views
Narrow vs Broad-based U-shape comparisons
I’m modeling mortality using a multivariate logistic regression model with a nonlinear effect of X1 and I’m examining whether this relationship changes across ...
0
votes
0
answers
35
views
ANCOVA or GLMM for logistic regression with fixed and random effects
I'm running an experiment where subjects need to determine if a test-image is identical or different from their (memorized) target-image. The images are divided between categories (e.g. ...
5
votes
0
answers
106
views
When should I use which smooth/spline in GAMs (for non-mathematicians)?
I delved a bit deeper lately into GAMs and I have the feeling, the more I go into detail the more questions are popping up (well, as usual, I'd say).
I recognized here and there, that there are plenty ...
1
vote
1
answer
76
views
(simulated) residual check for binary GAMM
I've got a dataset describing the infestation of an insect on plants in a very large area. The data were collected using several transects. Each transect is composed of 4 plots, with multiple plants ...
4
votes
4
answers
331
views
Borderline interaction p value
I’m working on a logistic regression model where I want to examine whether the effect of one continuous predictor (X1) on a binary outcome depends on another ...
2
votes
2
answers
123
views
Why is my simulation not showing bias?
I am trying to observe the Nickell bias (https://www.jstor.org/stable/1911408) in simulation. For example, its said that using a lagged response as a predictor in a regression model can create a bias.
...
2
votes
0
answers
25
views
comparing smooths in smooth-factor interaction: can I include the intercept?
It might be a bold question, but I wanted to be sure that I am on the right track with my thoughts, since I am no mathematician or something close :)
When using GAMs with a smooth-factor interaction, ...
0
votes
0
answers
29
views
LMest - Reference of the multilogit - how to know the significance
We run latent transition analysis with covariates using LMest and with the help of the available Literature (e.g., Bartolucci et al., 2017) and what we found on the web, we were also able to interpret ...
1
vote
0
answers
38
views
Analyzing full factorial experiments: pros and cons of running a model with two climate factors vs one climate factor?
I have a full factorial experiment with 4 treatments: ambient (control), drought, warmed, and warmed & drought. I sampled these treatments 4 times: pre-drought, peak drought, post drought, and ...
1
vote
0
answers
34
views
Confidence threshold for random forest type = "prob" new data
I have a nice multiclass random forest model in R (using the packages ranger and caret) but I think this question applies to any random forest logic.
When I use my RF to label unknown data I want to ...
2
votes
0
answers
64
views
Interpretation of multiple p-values and spline x continuous interactions for splines terms
I’m fitting a binary logistic regression model that includes a continuous variable modeled using natural splines, and I’ve also included an interaction between that spline variable and another ...
5
votes
1
answer
222
views
Number of knots in splines (internal vs total)
I’m trying to understand how natural cubic splines (splines::ns) and restricted cubic splines (rms::rcs) handle knots — ...
1
vote
0
answers
28
views
Creating Estimation Plots in R with multiple variables
I have a mixed model that includes three different variables: Treatment, Stimulation, and DRG, as well as a random effect with DRG nested under a group ((1|Group/DRG)). I am looking to assess how each ...
1
vote
0
answers
41
views
Understanding rcbin() function to create binary variable with ICC in a multilevel context [closed]
This question is related to an earlier post.
I have been trying to create a binary variable with ICC in a multilevel context.
In R there is the ...
0
votes
0
answers
31
views
Why are week and weekday fixed effects not identifiable in a mlogit logit model (R)? What am I doing wrong?
I am estimating a multinomial logit model using R’s mlogit package based on scanner data (store-level purchases).
For each product category, I estimate a choice model conditional on purchase: each ...
7
votes
1
answer
264
views
Why does my fixed effect model perform better than my random effect model?
I've written a small simulation below to try and understand the differences in performance between fixed and random effects in a model.
I am imagining a bunch of eggs incubated together in a clutch (i....
0
votes
0
answers
19
views
How can I test the proportional odds assumption for cumulative logit models estimated with svyVGAM?
I'm trying to estimate a cumulative logit model with partial proportional odds while taking into account sampling weights (to make the sample representative of the population). My best option seems to ...
2
votes
1
answer
106
views
How to test whether the addition of a random intercept is statistically significant from a glmer() model to glm()
I'm getting back into mixed effects models and have forgotten a lot. I know this is a doable test for linear regression but have forgotten if there is an equivalent for logistic regression. If I have ...
2
votes
1
answer
190
views
ICC of predictors too high in multilevel data generating process
I am currently working on a data-generating function in R that creates multilevel data, where I want to control the intraclass correlation coefficients (ICCs) for both the outcome and predictors. ...
2
votes
2
answers
101
views
lm() and glm() equivalence for log-transformed response variable [duplicate]
I can't seem to wrap my head around this:
What is the glm() equivalent for lm(log(y) ~ x1 + x2, data=data)?
Is it?
a. ...