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
0answers
6 views

Test for nonlinearity in cross-sectional time series data in R

I have a cross sectional time series dataset that looks like this: ...
0
votes
0answers
8 views

Characteristic-Based Clustering of Time Series

I'm trying to teach myself how to apply clustering algorithms to time-series data. I've recently come across a paper (https://robjhyndman.com/papers/wang.pdf) about using time series characteristics ...
0
votes
2answers
34 views

Beta regression fitted values

I have a beta regression model in R, have generated predicted (fitted) values based on my data, and plotted lines of those fitted values on a scatter plot of the actual data. I'm most used to GLMMs, ...
0
votes
1answer
28 views

Including a weighting variable in a linear regression

I'm looking at how temperature affects length. My length variable is the mean length calculated for every year, it is derived from ~10,000 data points. Not every year had the same sampling effort (e.g....
0
votes
1answer
18 views

Moving average (running mean) - how to keep all observations in smoothed time-series?

Let's suppose I have a time-series of 100 daily values and I want to compute a 5-day moving average of this time series. I would do as follows: ...
3
votes
1answer
56 views

Dealing with quasi-complete separation in General Additive Model?

I am modelling influence of fire on occurrence of certain bird species (count response variable) in Before/after control/impact experiment design. I've got intact and burned sites and count data both ...
0
votes
1answer
31 views

Combine Two Numbers that Satisfies these Five(5) Conditions with R

I want two(2) numbers $\phi_{1}, \quad \phi_{2}$ such that the following five(5) conditions will be satisfied using R: $ \phi_{1} + \phi_{2} < 1 $ $ \phi_{1} - \...
0
votes
0answers
4 views

Question on lagging environmental variables

I am trying to test environmental variables against fish catch data to see how they impact the species composition. for environmental data, I have river discharge, temperature, rainfall, and salinity. ...
5
votes
1answer
73 views

How is this connection between Beta and Binomial possible?

I'm learning stats, and I've reasoned about this for many days and I'm losing sleep over it. Say I have a binomial distribution B(k; n, p) simulating a hypothesis <...
0
votes
0answers
6 views

How to model proportional data of >2 categories on continuous predictor variables

I am trying to model data in which I have 2 continuous predictors and a proportional response, but it isn't a single proportional value, but rather 5 different categories, whose proportions all sum up ...
0
votes
0answers
14 views

Golang equivalent of fitdistrplus in R? [closed]

I'm trying to reproduce fitting a beta distribution in Go, given an input of floating-point rates: rates = [0.20, 0.15, 0.002, 0.017, 0.181, 0.004, ...] You can do ...
0
votes
0answers
5 views

Environmental Vector Fit to NMDS Data

I am new to doing NMDS in R, and I have a question about how the vectors that characterize the fit of environmental data. I am exploring how the concentrations of metals in sediment affect benthic ...
0
votes
0answers
8 views

How can I reproduce this Stata comand in R? confa / cfa [closed]

I need to reproduce this Stata command in R. But I don't understand so much about confa and don't know stata at all. ...
0
votes
0answers
17 views

Can the same range of priors from a linear regression be applied to a logistic regression?

I have trial level data from a study in which participants responded to a series of stimuli. I have a predictor of interest. For the sake of this example, let's call it the size of the stimuli. There ...
0
votes
0answers
7 views

Help interpreting F test in ivreg diagnostics in R

I'd like to ask a question about the diagnostics for ivreg() objects in R. Specifically, the weak instrument test, where the following post 1 speaks about the test having the null that the instrument ...
1
vote
2answers
21 views

I got the same adjusted p values (p adj) at different confidence levels (conf.level=0.95 and conf.level=0.90) when I run TukeyHSD in R

I am learning the TukeyHSD in R. The following operations and results got me confused. I got the same adjusted p values at different confidence levels (0.90 and 0.95). Should the adjusted p values ...
0
votes
0answers
16 views

Package to fit HYGARCH in R or Matlab [closed]

Is there any package to fit and estimate parameters for the HYGARCH model? In R it seems garchOxFit is not available with fGarch ...
0
votes
1answer
22 views

mediation in R - impossible proportion mediated values, output interpretation

I am using the mediation package in R and would appreciate assistance with several questions. One path (let's call this the first model) involves a dichotomous predictor -> continuous mediator ->...
-1
votes
0answers
20 views

Advice in which R package to use for a Beta Analysis with Repeated Measures Design [closed]

I have conducted an experiment and am unsure how to go about the data analysis. I have a limited sample size (n=13). My experiments investigated the duration a subject looked in the 10 seconds ...
0
votes
0answers
34 views

Multivariate quantile regression group lasso in R

I'm trying to fit a multivariate sparse quantile regression model with group lasso. The regression is multivariate as there are several dependent variables, $Y=(y_1,\dots,y_k)$. The selected $X$s must ...
2
votes
1answer
65 views

Why does median() differ from quantile()[“50%”] in R and doesn't honor the type? Is this an estimator or sample quantile?

I just found, that when I want a specific type of quantile in R, say the number 3, it doesn't agree with median calculated in the "traditional way" in R. ...
31
votes
14answers
2k views

If R were reprogrammed from scratch today, what changes would be most useful to the statistics community? [closed]

Many people in the statistics community and other academic fields use R as their primary language for data analysis and statistical computing. It is a wonderful ...
0
votes
0answers
15 views

Optimal Binning - How to implement a few variables to function from DataFrame in Python Pandas? [closed]

Hellow! How can I calculate Optimal Binning in Python for the list of variables, not only for one variable ? I havce example DataFrame like below: ...
0
votes
0answers
6 views

Performing GLMM on community data with manyglm

I'm analysing some arthropod community data with generalised linear mixed models (GLMMs), using the manyglm function from the mvabund package. This data has arthropods sampled from multiple trees in ...
1
vote
1answer
29 views

Inaccurate parameter estimates for state-space models?

I'm modeling time series using dynamic linear/state-space models, and was surprised by how inaccurate the estimates of model parameters can be, even for fairly long series. In particular, I'm ...
2
votes
1answer
82 views
+50

R - generate deviate using probability based on known occurrence of event

In R, I want to simulate an event using a probability $p$ based on a known occurrence $k$ of the event. If I have a population of $n = 100$ individuals in a given area, and I know over a period of ...
0
votes
0answers
13 views

Significance for R squared change of individual variables in R

I have two regression models and I have computed the change in R squared for individual variables in R. with "getDeltaRsquare" ( see output below ). However, I want to see if these changes ...
0
votes
0answers
13 views

Which is the better model by adjusted R squared or number of insignificant variables

Which is the better model and why? I'm going by the Pr value and comparing the number of insignificant variables and Adjusted R-squared. Based on my understanding the number of insignificant variables ...
1
vote
1answer
24 views

3 models which I have built result in the exact same result, how can it be? [closed]

I have 3 models which I have built, I have used the following libraries: ...
0
votes
0answers
16 views

How do you interpret the instantaneous causality test of the causality()-function? [closed]

I have used the causality()-function to test a VAR(3)-model for granger causality. The test found that H0 could not be rejected for the Granger causality test, but for the instant causality test with ...
1
vote
0answers
11 views

How to assess the impact of an exogenous on endogenous variables in VAR

I fitted a VAR model that includes an exogenous variable, and I am interested in assessing the impact of the exogenous variable on the endogenous variable. As far as I know, IRFs (impulse response ...
2
votes
1answer
23 views

Adding a Dummy Variable to glm in R?

I'm running a glm in R with two categorical variables, one of which is binary, the other of which can take on five values. I would like it so that my model returns an intercept value that reflects the ...
1
vote
0answers
22 views

Is it possible to convert a pdf obtained with density() to an ecdf?

Consider the following code that gives us (an estimate of) the pdf of a random variable $X$: X = rnorm(100,10,1) XDensity = density(X) I want to obtain the ecdf of ...
0
votes
1answer
17 views

What can I do to address the violated assumption of linearity in my simple linear regression model?

Overview I built a linear regression model using the lm() function in R, and the linearity assumption has been violated. All other assumptions have been met. I tried a multitude of transformations on ...
2
votes
1answer
21 views

Mediation in R Package lavaan: Total effect of the IV has a different p-value than the same variable in a Multiple Regression

i am really confused with the results of my mediation analysis using lavaan. I am using one predictor and several covariates. Is there any reason why lavaan could give me "wrong" p-values? ...
0
votes
1answer
33 views

Simulating a simple queueing problem to calculate $\Pr(B > 4).$ If-statement not working as I expect it

I have the following problem: Consider an M/M/3/4 queuing system with $\lambda=\mu=1$ that is the arrival time is exponentially distributed with parameter $\lambda = 1$ and the service times are ...
1
vote
0answers
14 views

Difficulty in understanding how to include covariates in random forest for timeseries data

I read this tutorial on how to use random forest for forecasting using timeseries data ( https://petolau.github.io/Ensemble-of-trees-for-forecasting-time-series/ ), and I have some difficulties to ...
0
votes
0answers
31 views

Calculate forecast Arimax model step by step

I am making a model in R, Arima and I want to replicate the forecast in excel, but at the time of doing it I cannot continue due to the MA. this is just an example data to understand how the R ...
1
vote
1answer
23 views

Which test to run … probit or logistic?

IV's: categorical School, categorical Grade Level, categorical Living Arrangement, categorical Race, categorical Illness, continuous Time. DV: withdrawn status (withdrawn or not withdrawn) I want to ...
0
votes
0answers
27 views

I am doing a Survival Analysis, using R on patients survival in an intensive care. What is the correct procedure for data preparation?

I have collected, and still am, data on survival in an intensive care. In essence, I have collected demographics, say, age, gender etc, and length of stay in the Unit, and outcome, namely died or ...
1
vote
0answers
19 views

T-test and tree don't match logically

I would like some help in a machine learning homework. First I want to make clear that I don't think this is considered cheating as I am just asking for help in understanding a result, rather than ...
0
votes
0answers
9 views

Is there any sense of applying cross validation to quasibinomial variable?

We can apply without any doubts cross validation for linear models as well as for binary models. For linear models for example we can output RMSE and MAE and Accuracy for binary models. But I have ...
0
votes
0answers
9 views

NLS more consistent than GMM

I'm trying a simple code to test whether NLS has better performance than GMM. The R code looks like this ...
1
vote
0answers
11 views

insignificant gamma1 parameter in EGARCH(2,1) model in rugarch package in R. By default? [closed]

I have built an ARMA(2,2)-EGARCH(2,1) model in R using the ugarchspec function from the rugarch package. The model is very good ...
2
votes
0answers
32 views

Correcting for robust/clustered standard errors within the lm function or replacing the results

Cross posted on Stackoverflow with a bounty of 200. EDIT: I think I have to clarify this question a little bit more. So what I am looking for, is a function in which I can provide both the vcov matrix ...
0
votes
0answers
16 views

Post-hoc tests for lmer for two and three-way interactions performing ANOVA type III

In R, I am trying to perform post-hoc tests on a significant three-way interaction involving two 2-level factors (bodymanipulation, soa) and a continuous variable (prosthesis_partofbody). The model I ...
0
votes
0answers
4 views

Imputation method for weather data

I have weather data (time series) which has variables like rainfall, air temperature, relative humidity etc. About 6% of the total records are missing (2191 total records). After data cleaning, what I ...
2
votes
0answers
24 views

Roughness penalty matrix for the Fourier basis functions

I am trying to understand how the roughness penalty matrix for the Fourier basis functions is calculated in R using the fda ...
3
votes
2answers
41 views

Interpretation of Cubic Spline Coefficients in R

I am using the titanic_train data set in R to build a logistic regression model. ...
2
votes
1answer
35 views

Variance of the Product of Correlated Random Variables?

I would like to multiply two correlated random variables, but I'm getting a negative variance. Please point out where I'm wrong. Variable1 and ...