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
1 vote
1 answer
5 views

How to use MAPE with auto.arima model?

The code below gets a: error in mean(abs((y_true - y_pred)/y_true)) : argument "y_true" is missing, with no default I've seen MAPE used on forecasts. Can one use this and similar methods on ...
Ray Tayek's user avatar
  • 141
1 vote
1 answer
19 views

Calculate log-likelihood of logistic regression

I am trying, without success, to calculate the log-likelihood of the most basic logistic regression model - a constant probability model (i.e. only $\beta_0 \ne 0$). For the simplest model with 1 ...
s5s's user avatar
  • 641
1 vote
2 answers
19 views

regression modeling - logistic

My task is to run a logistic regression that models the probability that revenue is non-zero (in the logistic regression parlance, a positive revenue is a success). Revenue variable is numeric and ...
user avatar
0 votes
0 answers
8 views

Use of t_family distribution in glmmTMB

I am trying to use t_family(link="log") distribution from the glmmTMB package. The package allows fixing the shape parameter using ...
Rouz's user avatar
  • 1
1 vote
0 answers
7 views

Interpret results of a mixed effects model analyzing a 2x2 cross-over study?

I have conducted a randomized 2x2 cross-over trial of 8 participants measuring the effect of a specific diet (intervention) vs normal diet (control) on the number of sleep hours. The study design ...
Wandering_geek's user avatar
0 votes
1 answer
41 views

Generate survival data with functional data using R

I am reading this article here and trying to regenerate their simulation study. Here is this scenario here, among others, but if I can figure out one, the rest follow. That is, Simulation set-up we ...
ADAM's user avatar
  • 107
0 votes
0 answers
9 views

I am trying to visualize the NHANES dataset using the PAXINTEN of the individual which is intensity recorded by accelerometer [closed]

I am running the following code: ...
Parneet's user avatar
  • 11
0 votes
1 answer
22 views

Why does the best fitting Weibull distribution for this survival data deviate further from the actual data than a poorly fit distribution?

I started working with the Gumbel distribution and fit it to the lung dataset to try it out. I then compared it with the survival curve using the Weibull ...
Village.Idyot's user avatar
0 votes
0 answers
15 views

What does predict.cv.glmnet actually do with new data? [closed]

This might be a dumb question but I am struggling to figure out what predict.cv.glmnet actually do under the hood, let's say for example for a Lasso regression. Does it actually train a new model with ...
Josephine_Herzberg's user avatar
5 votes
2 answers
183 views

Is there a clean way to derive the start parameters for running the `fitdist()` function for the Gumbel distribution?

I've begun working with the Gumbel distribution and started with the example in the package documentation at https://cran.r-project.org/web/packages/fitdistrplus/fitdistrplus.pdf. For the Gumbel ...
Village.Idyot's user avatar
0 votes
0 answers
18 views

Code issue with plot-x and y lengths differ error [closed]

For the code below: Error in xy.coords(x, y, xlabel, ylabel, log): 'x' and 'y' lengths differ Traceback: 5. stop("'x' and 'y' lengths differ") I tried ...
Jin Lim's user avatar
0 votes
0 answers
10 views

Statistical test for interpreting negative coefficients in multivariate cross sectional analysis [closed]

I wrote a seminar paper on the conditional ß-convergence (income convergence) of the Solow Model and therefore ran several cross sectional regressions in R. Thus, I regressed the variables "GDP ...
Mankiwsclerk's user avatar
1 vote
0 answers
16 views

Bounded uniform prior in R

I have been fitting a bayesian GLM using brms. The code works well but when I loop this over several data and make it a bit more complex, R encounters a fatal error and crashes. This seems to be ...
blackandwhite's user avatar
0 votes
0 answers
9 views

How can I format a double entry table into a long table in R to run a linear model? [closed]

I need to run a linear model of some data. I was given a 'double entry' table. Until today I was not familiar with them. This is how it looks: Every row has a value of the dependent variable, except ...
HernanLG's user avatar
  • 201
-1 votes
0 answers
17 views

How to create a dataframe from the result of a for loop in R? [closed]

I want to obtain from a for loop a dataframe in which i can visualize better the result of the code. I'm in the context of Random survival forest, so I leave an example to explain me better. ...
Caterina Venturelli's user avatar
1 vote
0 answers
17 views

Testing signifiance of random effects on large dataset

I want to do a mixed linear model, with two hierarchical random effects. I want to determine wether if these random effects are worth including in the model. I have tried so far doing : ...
Dimitri's user avatar
  • 41
0 votes
0 answers
21 views

How to accomodate for missingness in column dependent on value of other column

Please run this code in order to create a reproducible example: ...
Sebastian Gerdes's user avatar
0 votes
0 answers
14 views

How to simulate variability (errors) in fitting a gamma model to survival data by using a generalized minimum extreme value distribution in R?

As shown below and per the R code at the bottom, I plot a base survival curve for the lung dataset from the survival package ...
Village.Idyot's user avatar
0 votes
0 answers
6 views

Box Cox Back transformation of coefficients/LSMEANS and confidence intervals IN R [closed]

I have made a simple gls model with a continuous variable as the response and a categorical as the predictor. I have used box Cox transformation to the response because it was highly skewed. How can I ...
les2004's user avatar
0 votes
0 answers
9 views

how to estimate the lognormal distribution 3 parameters using maximum lq likelihood method in R/Rstudio

i've tried to find the equation for lq likelihood equation is: lq_likelihood <- ((f^(1-q))-1)/(1-q) and with f is pdf of lognormal distribution and q is distortion parameter(i'm using q=1-(1/n)) ...
Bisma Adhira's user avatar
0 votes
0 answers
33 views

How do I determine which variables to pick in a binomial GLMM using lme4?

I'm still pretty new to modelling but essentially, the dataset is consists of the following (the first observation only): ...
Christopher Agnus Lam's user avatar
0 votes
0 answers
14 views

Computing a variogram in R using a distance matrix [closed]

My question is to an extent a copy of this question, although that question is now 8 years old. I have geographical data with values distributed according to lattitude and longitude (in degrees). geoR'...
Mr Lolo's user avatar
  • 111
1 vote
1 answer
11 views

Kernel Smoothing for Time Series data

I have generated a time series data set of measurements that are a bit noisy and I want to apply kernel smoothing to the data. My time series data is not regular however, meaning that the time ...
Jade131621's user avatar
0 votes
0 answers
15 views

Understanding Optimizer Options Using tidysynth

Under the generate_weights() command using the {tidysynth} package for executing the synthetic control method in R, users are given a number of optimization options. However, I cannot find ...
Brian Lookabaugh's user avatar
4 votes
2 answers
641 views

How do I deal with many zero values in terms of correlation?

I am currently working on my master thesis. I have determined a simulation model for tax returns and to verify this I would like to use true values. I would like to determine the correlation between ...
Leo's user avatar
  • 43
0 votes
0 answers
7 views

What's the correct way to report location and spread descriptive stats when you have repeated observations and unequal sampling?

Objective: Report summary statistics for each treatment x timepoint x condition sub-grouping when there is unequal sampling and repeated observations per subject. It is assumed that all the subjects ...
myfatson's user avatar
  • 183
1 vote
0 answers
14 views

dataset used in replication of Bernanke, Boivin and Eliasz (QJE, 2005) in R

I am trying to work on FAVAR model but can't find the dataset used for this replication https://jbduarte.com/blog/time%20series/r/favar/2020/04/24/FAVAR-Replication.html. I looked everywhere but can't ...
Rai Zel's user avatar
  • 11
0 votes
0 answers
24 views

How to sample from the generalized extreme value distribution in survival analysis?

In the image below and per the code at the bottom of this post, I plot a base survival curve for the lung dataset from the ...
Village.Idyot's user avatar
1 vote
0 answers
25 views

bootstrapped confidence interval for glmer model with identity link

In an experiment Subjects decide as fast as possible whether letter strings presented on screen are real Words or non-words and reaction time (RT) in milliseconds is recorded. We want to know for ...
Jorge Witman's user avatar
1 vote
0 answers
9 views

What does the neuralnet error reported in plot mean?

When fitting a simple MLP neural net on the Credit dataset by the package neuralnet in R and then plotting it, we get an error reported at the bottom of the plot, ...
Antonio Piemontese's user avatar
1 vote
2 answers
38 views

DAG - why is the path open?

I have this DAG As I understand it, the paths D <- Ed -> St -> P -> Su and D <- A -> P -> Su are both closed because the contain the collider P. If I condition on P, both these ...
user654345678's user avatar
0 votes
0 answers
11 views

How to test for size (Typ one error probability) on Breusch-Pagan Test in R?

The data i created contains heteroscedasticity. I already calculated the power so my idea was to basically do the same but switch the hypothesis so that H0: Heteroscedasticity and H1: Homoscedasticity ...
user avatar
1 vote
0 answers
9 views

Can the limma package be applied to Log2 RUV-normalized data? [closed]

So I have a dataset that consists of the batch correction through RUV-normalization of several microarray datasets containing tumoral and non-tumoral samples. The data is in Log2 RUV-normalized ...
Rui Marques's user avatar
0 votes
0 answers
11 views

Calculate confidence intervals of ratio calculated from four values using R [closed]

I have four numeric variables (A, B, C, D), each with confidence intervals, and I want to calculate the CI of the ratio between these four values. The ratio is calculated by (A + B)/ (C + D). Is there ...
Sammi Choi's user avatar
0 votes
0 answers
16 views

dev.ratio in glmnet

After running glmnet I can get a pseudo R-squared with glmnet.fit$dev.ratio. Does this take into account the complexity of the ...
locus's user avatar
  • 1,159
0 votes
0 answers
6 views

What is a reasonable range of penalty values to try in PELT changepoint analysis?

I have a simulated a time series data set several predictor variables and response class that I created to practice different analytical techniques before I apply methods to my real (very large) ...
Jade131621's user avatar
0 votes
0 answers
12 views

How to determine contrasts in combinations of categorical variables with emmeans

I have some data with a continuous outcome that is measured among 4 categorical variables: treatment group, gender, collection date, and sub_type. Gender is M/F, collection date can just be Mon/Wed, ...
Gmiller's user avatar
0 votes
1 answer
20 views

Multiple events in Cox PH with time varying data

I study coups d'etat. I would like to understand the relationship between leader/country characteristics and the likelihood of coup attempts. I have a leader-country-year dataset with one entry for ...
Rabbit's user avatar
  • 101
9 votes
1 answer
369 views

Why doesn't R output for a paired t-test match the formula for a confidence interval in the t-distribution?

My understanding is that the formula for a confidence interval when using a t-test is as follows: $\bar x \pm t_{n-1,\alpha / 2} \frac{S_d}{\sqrt{n}}$ where $S_d$ is the standard deviation of the data....
Dan W's user avatar
  • 173
2 votes
1 answer
56 views

Non-linear regression. Need some help implementing a model from a paper

I found this paper very useful for my research, however, I'm not familiar with non-linear regressions and I'm finding it tricky replicating it. Using the first f=model for example: ...
Favour Onyido's user avatar
0 votes
1 answer
8 views

Feature importance/model exploration in a large survival model

I've built very-well performing survival model (weibull proportional hazards model for interval censored data, modelled with IcenReg) with many covariates, some ...
Wojty's user avatar
  • 51
-2 votes
0 answers
16 views

Create a graph in R [closed]

Hello I want to create a graph like that in R. Any help with the code I have to write to create it?
Superd's user avatar
  • 1
0 votes
0 answers
12 views

Implementing bootstrap for sequential target trial emulation [closed]

I am currently working on sequential target trial emulation and have been stuck in the step of bootstraping. I would greatly appreciate any assistance, recommendations, or sample code that you could ...
Chloe Laurent's user avatar
0 votes
0 answers
22 views

Autocorrelation returning non-significant values despite an apparent pattern

I have just finished Chatfield and Xing's The Analysis of Time Series, 7th edition and I'm beginning to play around with some simple analysis. I have this graph representing the grand mean value ...
grace.cutler's user avatar
1 vote
1 answer
30 views

How should I scale data that has been assembled from different data sources?

The data I'm woking with consists of 3 types of data: 1- binary features: those features are either 0 or 1. I have about 6 or 7 columns. 2- cells: the values here range from 0 to 0.8 at max. Here I ...
Programming Noob's user avatar
0 votes
0 answers
10 views

Running the same mixed model with different contrasts to explore different hypotheses

I'm running the following mixed model to explore the relationship between Condition (3 levels; Predicted, ...
Chantal's user avatar
  • 65
1 vote
1 answer
63 views

Multiple predictors that measure the same concept in regression

I have used three questionnaires in a study that all measure musical training. Each of these three questionnaires (MT1/MT2/MT3) consist of various Likert scales that are averaged to calculate the ...
Pearson's user avatar
  • 61
3 votes
1 answer
25 views

What are the possible solutions to do matching on very large dataset

Hi I would like to match a group of treated patients with an untreated group. I have about a million patients in the treatment group and ten times that in the control group. Conventional matching ...
Seydou GORO's user avatar
0 votes
0 answers
27 views

power analysis for glmer mixed models

I want to know an appropriate way to conduct a post-hoc power analysis for several glmer models built in R using the lme4 package. A reviewer asked for this. What I did: I used the R package simr ...
Alaa's user avatar
  • 13
1 vote
1 answer
16 views

How to convert R output from auto.arima function into mathematical model?

I'm building a model using the auto.arima function in R, and it gives the following output: ...
statsq55's user avatar

1
2 3 4 5
578