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
0 votes
0 answers
5 views

pdfs via marrangeGrob [closed]

Here's a function to print a couple of pdf's: all necessary data and libraries have been provided; n1 and n2 are used to split a long data frame in two. ...
Phil Viton's user avatar
1 vote
1 answer
18 views

How to Interpret scatter plot for binary response?

I have come to know about scatterplot matrices, where pairwise scatterplots for covariates are built and then binary responses are jittered. This plot is helpful to give an idea about how each ...
Ly T's user avatar
  • 41
0 votes
0 answers
7 views

Struggling to understand lme4 model syntax and nesting

I am working on implementing a model in R. I thought I had a pretty good approach, but one of my collaborators has pointed out that the model degrees of freedom from lmerTest don't make sense for the ...
Isaac's user avatar
  • 23
0 votes
1 answer
32 views

Why are the performance of LASSOs implemented via glmnet in R going down after cross-validation?

This question is a follow-up to this question I asked here last week. I got an important and useful answer to it, but what that led to was surprising. And once again, here is a link to the GitHub Repo ...
Marlen's user avatar
  • 123
0 votes
0 answers
6 views

Simulate new data based on existing data of people nested within groups in r

I have a dataset of people nested within groups (6 people per group). People within each group are assigned either a condition A or B and the proportions within each group change. Each person in the ...
chagag's user avatar
  • 1
0 votes
0 answers
13 views

Detrending these time series

I have the following time series. Its clearly not a simple linear trend. I want to explore the relationship among these variables using a VAR, or even a time-varying VAR. The biggest issue in my data ...
Marg's user avatar
  • 11
0 votes
1 answer
15 views

How to interpret W value of a wilcoxon test in R

I did a wilcoxon test in R but I don't understand how to interpret the W value and what this means in comparison to another I did result on 2 data sets and the results are: W = 9, p-value = 0.1 ...
Ali's user avatar
  • 1
1 vote
0 answers
7 views

Hypothesis Test on Three proportional data with different sample size

I have three proportional data H1, H2, and H3. And my null hypothesis H0 would be H2-H1=H3-H2. What would be the test statistics here? I tried to use the proportional test for H_0:P2=P1. But the test ...
user15716547's user avatar
0 votes
1 answer
32 views

Difference between four random effects structure

What is the difference between the following four random effect structures in R? ...
SanMelkote's user avatar
3 votes
1 answer
35 views

Random Forest with Test Accuracy of 1

I am running a random forest for classification of a data with three classes in R, and each class has around 20 samples. I am partitioning data into train and test in 80:20 ratio using caret package. ...
eraysahin's user avatar
3 votes
1 answer
45 views

How to specify random effects for panel/longitudinal data with level 2 predictor?

In the study of tweets pre- and post- metoo (set as Nov 2017), we are looking at whether there is gender differences in the use of masculine language in tweets for male and female social media users. ...
Sunsan's user avatar
  • 31
0 votes
0 answers
14 views

How to specify time series window in r as a fraction of the length? [closed]

I want to use the window function to analyze some time series like the code below does: ...
Ray Tayek's user avatar
  • 151
1 vote
0 answers
13 views

How to improve the accuracy of time series forecast using stlf()

I am new to working with time series and have tried several methods on my data including SARIMAX, Croston and forecastHybrid. The most accurcate result I've gotten so far is with stlf(), based on ...
Rina Tse's user avatar
1 vote
0 answers
8 views

Seasonal differencing applied to exogenous variable (xreg)? Forecast package R by Hyndman

Im currently working on specifying a seasonal ARIMA model with an exogenous variable. I'm using the forecast package developed by Hyndman for this. I have specified the following: ...
Nathan de Bruijn's user avatar
1 vote
1 answer
60 views

Calculating Sample Size When Wanting To Analyse Proportions & Proportions Sizes are Unknown

I have similar recurring use case at work whereby we are wanting to understand attributes/features of a datasets such as 'how many customers talk about this', 'how many customers do that' and ...
K-J's user avatar
  • 11
2 votes
1 answer
54 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
  • 151
1 vote
1 answer
29 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
  • 643
1 vote
2 answers
45 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 ...
Sally Nelly's user avatar
0 votes
0 answers
13 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
13 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
0 answers
10 views

GARCH fit to the residuals of AR/ARMA mean equation previously fitted

Suppose I have an ARMA (p,q) (let it be ARMA (2,2)) fitted to my original returns series and have the residuals of said ARMA model extracted. Next, it is my understanding that I need to fit a GARCH ...
Ghada's user avatar
  • 1
1 vote
1 answer
72 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
  • 119
1 vote
0 answers
10 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
  • 21
1 vote
1 answer
28 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
238 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
18 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 vote
0 answers
19 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
1 answer
26 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
1 vote
1 answer
52 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
7 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
10 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
36 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
15 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
12 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
654 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
17 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
1 vote
0 answers
27 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
11 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
40 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
12 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
10 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
17 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
8 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

1
2 3 4 5
578