Tag Info

Accepted

Issue with bootstrap confidence and prediction intervals of mixed effects model predictions

Since this is a programming question, it would be better suited on StackOverflow. However, I found out the issue: In lines l.22, ...
• 12.5k
Accepted

How should I analyse TV episode popularity while accounting for time?

I would try fitting a heteroscedasticity-robust Poisson model of streams on episode age calculating the expected number of streams at each age, along with a 95% CI (or 99% if you want more stringency)...
• 37.2k
1 vote

Estimate Weibull Shape and Scale function from lifetable data in R

Technically, you might consider your data to be "interval censored": you know the range of times within which individuals dies, but not the actual times. With some care, interval censoring ...
• 95.2k
1 vote
Accepted

Reproducing model with fractional polynomial predictions

Just posting the answer here to close the topic: The fp function has the parameters shift and scale and I was ignoring them. I've read the documentation before but I was not able to figure it out ...
• 33

non-positive-definite Hessian matrix/non-convergence problem with glmmTMB

Hard to say, exactly. If your response variable is positive with exact zeros then indeed using a zero-inflated Gamma or a Tweedie distribution as the response would make more sense and might work ...
• 44.4k
1 vote

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

TLDR: check that the method works on toy-data; check that the predicted conditional distributions at any $x$ are a good fit to the data. You already have several great technical answers. I want to try ...
• 2,461
Accepted

If measured in different time across days, should it be crossed or nested random effects?

I am not sure whether the time of day and days should be nested or crossed. Neither. You have repeated measurements of subjects, but the effect of date (or time) is fixed. Only include a random ...
• 12.5k

Correlation alternatives / How to go about testing this relationship?

If I get it right what you do is measuring water temperature at different spots of a river, beginging right behind a dam and repeating the measurement at multiple spots further downstream. This means ...
• 340
1 vote

Issue fitting and plotting GAM with soap film smoother

I have gone through your posted code and have a couple of comments/ideas here: The boundary object that you're supplying does not have the variable f in each ...
1 vote

GLM for longitudinal or time-series -- how to model and interpret a binary logistic regression over time controlling for covariates using R

You can use emmeans to calculate contrasts: library(emmeans) em <- emmeans(mod_longitudinal_covariates, ~ year_completed_cat) ...
• 221

Creating ROC curve for multi-level logistic regression model in R

This question is super old, but for those coming to it now I believe the author is purposely referring to multi-level models, not multi-class models. Some info regarding multi-level models: https://...
• 101

Analyzing review rating using R STM package - sample balance issue

The simple answer to your question is: no, you don't need to imbalance your own data by randomly eliminating values. Start by reading the discussion here: When is unbalanced data really a problem in ...
• 63.6k
1 vote

Issue fitting and plotting GAM with soap film smoother

One thing I notice here is that the model is not predicting all zeros, there is a hotspot around x = 495000. So it is actually working it is just overestimating in that one spot. You might consider ...

How to fix intersection of cluster distributions in R

I don't see why you are using cluster analysis (CA). CA is unsupervised learning. Its goal is to find ways that observations "go together" or cluster, with no dependent variable. So, it is ...
• 125k

Interpretability for chi-squared test?

I'm responding to this post for future reference and to expand on a potentially interesting aspect that has not been fully covered in previous answers (i.e., the selection of an appropriate ...
• 151

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

Here is the best I could do I fit a zero-one inflated beta regression and allows the mean and the dispersion to be a smooth. The brms syntax is ...
Accepted

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

The Problem My interpretation of the problem is that you want to know how the difference in the number of contacts depends on the demographic variables you listed. What you have tried now is to take ...
• 12.5k
1 vote

Best subset selection with categorical data

As detailed so many times on this site, variable selection is a really bad idea. Spend time specifying a complete model rather than juggling models.
• 95.7k

lmer with random effects that is also associated with fixed effect

As Frank's answer (+1) already mentioned, you can even statistically test which of the two models fits best to your data. Use: anova(model1, model2) to obtain a ...
• 1,808

Date as random effect in mixed model strongly changes coefficient estimates

If you want to take into account the effect of time, you should do so by including a fixed effect. Using a common rule of thumb: Days cannot be reasonably assumed to come from some larger population ...
• 12.5k

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

This began as a comment but grew a bit long. I guess it's at least the start of a kind of answer. Y can't have an actual exponential component; it's bounded at 1. You must mean something else there (e....
• 286k
1 vote
Accepted

AR(p) model in R not fitting data

I've run a Dickey Fuller test on unit root stationarity and reject the null. Always carefully check what the null and alternative are! Note that for the Dickey-Fuller test the null is that there is a ...
• 286k
Accepted

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

First a correction: the roc function of pROC (for simplicity, let me simply refer to it as "pROC" from now) doesn't ...
• 3,819

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

There is no such thing as the way to analyze a data set. Analyses start with a research question. The right way to analyze the data depends on what that question is (and any peculiarities of the data)....
• 12.5k
1 vote

When can I substitute an inverse with a pseudo-inverse in an estimator?

Yes, this might be possible. Say your vector parameter is $\beta$ and your interest is in some component (or linear function) $\alpha =a^T \beta$. Let the covariance matrix of $\hat{\beta}$ be $C$, ...
• 81.3k

Imbalanced binary classification with skewed features

Think of using best statistical practices and spending a lot of time specifying the model. And don’t make the mistake of making forced-choice classification your goal. Think instead of modeling ...
• 95.7k
1 vote

Imbalanced binary classification with skewed features

category_ratio Min. : 0.0003 1st Qu.: 0.5916 Median : 0.9665 Mean : 1.3522 3rd Qu.: 1.4554 Max. :782.4587 This looks like great news to me! You have ...
• 64.7k

Mixed Model for Repeated Measurement (mmrm) - Assumptions

thanks for your question, I just found it by chance - I would recommend considering posting questions specifically on mmrm in the corresponding GitHub issues page ...
Accepted

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

Because am is a binary (0/1) variable, avg_slopes() computes the difference between the average adjusted predictions udner each ...
• 34.9k

Hypothesis testing with control and treatment group - which statistical analysis to use?

If your data is arranged as it seems, then you can simply subtract the t1 measurement for each participant from the t2 measurement and then use a Student's t-test to compare the mean differences. That ...
• 16.2k
1 vote
Accepted

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

is this to be expected? I would say yes. Form a quick look, relWT implements Johnson's (2000) relative weight computation. calc.relimp implements various metric, but I don't see a reference to ...
• 4,754

Test of significance for glmer

The anova() command is doing a likelihood ratio that compares the two models. This is analogous to an omnibus F-test of a factor in a typical one-way ANOVA analysis with 4 groups. You would look at ...

lme4 Inconsistency

The important part of Robert Longs answer was because group is coded uniquely across district ...
• 2,817

Discrepancy between ggsurvplot predicted survival curves and raw data

The power of survival analysis comes from the number of events, not the number of total cases. The usual rule of thumb, to avoid overfitting, is to estimate no more than 1 coefficient per 15 or so ...
• 95.2k
1 vote
Accepted

Model comparison or beta coefficient of full model?

It's true that a comparison between two nested models is often exactly equivalent to testing the null hypothesis about a particular coefficient (e.g. $\beta_1 = 0$), in which case it is usually more ...
• 44.4k

Analyzing lists and variables of multiple answers

Your data structure is called categorical multiple response set (MRC). Each variable is "next answer" and the values are the responses (or, better, numeric response codes). Another structure ...
• 58.3k

Regression Modelling using lme4 in R

I would like to model the effect of temperature on the daily movement patterns of the animals using a regression model in lme4 The model: ...
• 63.8k

Quantile regression with sampling weights in R

The weights in rq work like frequency weights, so you get the right point estimates. Using withReplicates will then get you ...
• 41.3k

Visualizing categorical data with 7 variables

@MaartenPunt has provided a good start. Let me expand on those ideas. The notion of a stacked bar chart stratified by another variable is very close to a mosaic plot (see also here). The primary ...
Accepted

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

The Beta regression family is not a generalised linear model (in any of the strict senses) and so glm can't give you the maximum likelihood estimators (not with the ...
• 41.3k
Accepted

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

This is called a log-linear model in my field, since you have a logged outcome and an unlogged covariate. Exponential regression usually entails an untransformed outcome with $\exp()$ wrapped around a ...
• 37.2k
Accepted

Extrapolating standard error of logistic regression in R

Strange rule, never seen it before. I also highly doubt that produces valid confidence intervals for non-normal responses, as that ribbon looks suspiciously narrow for such a small sample size. Anyway,...
• 12.5k

cor_mat , cor.test , and adjusting p values

This is not correct. The two should give exactly similar results. Note that cor_mat calls cor_test which calls ...
• 516

Validating Model Setup for Differential Abundance Analysis Using ANCOM-BC in R

Model Configuration and Random Effects: The main challenge you're facing with the (Trimester | subject) model stems from the complexity and number of parameters ...
• 63.8k
1 vote

Interpretation of main effects under the presence of interaction terms in fixed-effect models and using plot_predictions

Here you see more interpretations in terms of one of the variables being a moderating effect https://stats.stackexchange.com/a/590620/ You can rewrite $$y = a_0 + a_1 x_1 + a_2 x_2 + a_3 x_1x_2$$ as \$...
• 82.1k

Hard in calculating predictor‘s Relative Importance for GAM?

you can try a new package gam.hp in R: ...

Interpretation of R output for stratified cox-ph model

When you use strata(sex), coxph should estimate a separate hazard for males and females. There is no need to include ...

GAM: Smooth and factor interaction

What Not to Do I will start by saying that it is generally not wise to dichotomize a numeric variable. Generally it results in a loss of information and produces bias in your standard errors. It also ...
• 15.8k