Skip to main content

New answers tagged

2 votes
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, ...
Frans Rodenburg's user avatar
8 votes
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)...
dimitriy's user avatar
  • 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 ...
EdM's user avatar
  • 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 ...
kKodorna's user avatar
2 votes

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 ...
Ben Bolker's user avatar
  • 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 ...
Guillaume Dehaene's user avatar
2 votes
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 ...
Frans Rodenburg's user avatar
0 votes

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 ...
LulY's user avatar
  • 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 ...
Benjamin Hlina's user avatar
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) ...
Axeman's user avatar
  • 221
0 votes

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://...
Kelley Brady's user avatar
3 votes

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 ...
AdamO's user avatar
  • 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 ...
Robert Lennox's user avatar
0 votes

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 ...
Peter Flom's user avatar
  • 125k
0 votes

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 ...
NewAtGis's user avatar
  • 151
5 votes

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 ...
Demetri Pananos's user avatar
4 votes
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 ...
Frans Rodenburg's user avatar
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.
Frank Harrell's user avatar
0 votes

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 ...
BenP's user avatar
  • 1,808
2 votes

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 ...
Frans Rodenburg's user avatar
5 votes

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....
Glen_b's user avatar
  • 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 ...
Glen_b's user avatar
  • 286k
6 votes
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 ...
Calimo's user avatar
  • 3,819
2 votes

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)....
Frans Rodenburg's user avatar
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$, ...
kjetil b halvorsen's user avatar
2 votes

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 ...
Frank Harrell's user avatar
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 ...
Dave's user avatar
  • 64.7k
0 votes

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 ...
Daniel Sabanes Bove's user avatar
3 votes
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 ...
Noah's user avatar
  • 34.9k
0 votes

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 ...
Michael Lew's user avatar
  • 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 ...
dariober's user avatar
  • 4,754
0 votes

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 ...
Nathan's user avatar
  • 1
4 votes

lme4 Inconsistency

The important part of Robert Longs answer was because group is coded uniquely across district ...
Lukas Lohse's user avatar
  • 2,817
0 votes

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 ...
EdM's user avatar
  • 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 ...
Ben Bolker's user avatar
  • 44.4k
0 votes

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 ...
ttnphns's user avatar
  • 58.3k
2 votes

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: ...
Robert Long's user avatar
  • 63.8k
4 votes

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 ...
Thomas Lumley's user avatar
0 votes

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 ...
gung - Reinstate Monica's user avatar
0 votes
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 ...
Thomas Lumley's user avatar
2 votes
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 ...
dimitriy's user avatar
  • 37.2k
3 votes
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,...
Frans Rodenburg's user avatar
0 votes

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 ...
Onyambu's user avatar
  • 516
3 votes

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 ...
Robert Long's user avatar
  • 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 $...
Sextus Empiricus's user avatar
0 votes

Hard in calculating predictor‘s Relative Importance for GAM?

you can try a new package gam.hp in R: ...
user412439's user avatar
5 votes

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 ...
Demetri Pananos's user avatar
0 votes

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 ...
Shawn Hemelstrand's user avatar
0 votes

How do I perform a permutation test on a machine learning model to obtain a p-value for its performance?

It was already said in the comments, but you can proceed roughly as follows. State your null-hypothesis. This null-hypothesis should be sufficiently detailed to generate random data of reasonable ...
Cryo's user avatar
  • 743
2 votes

One way ANOVA on compliance rates (by time period) with different lengths

As per the previous answer, yes, you can use an ANOVA (DV=compliance, continuous variable; IV=Group, catehorical, with 3 levels). But... Your sample size is very small (4, 5 and 3). It is unlikely you ...
jginestet's user avatar
  • 1,747

Top 50 recent answers are included